On this page:
5.1 Render API
render
render/  async
render/  pretty
5.2 Render Class
render%
new
setup
start-rendering
stop-rendering
render<%>
5.3 Render Settings
render-settings?
make-render-settings
8.13.0.9

5 Rendering🔗ℹ

 (require video/render) package: video-unstable

The renderer in this section describes the API for rendering Video files. A simpler interface is to use the raco video tool described in Command Line Interaction.

5.1 Render API🔗ℹ

procedure

(render data    
  [dest    
  #:dest-filename dest-filename    
  #:render-mixin render-mixin    
  #:width width    
  #:height height    
  #:start start    
  #:end end    
  #:fps fps])  void?
  data : video?
  dest : (or/c path path-string? #f) = "out.mp4"
  dest-filename : (or/c path-element? string? #f) = #f
  render-mixin : (-> (is-a?/c render<%>) (is-a?/c render<%>))
   = values
  width : nonnegative-integer? = 1920
  height : nonnegative-integer? = 1080
  start : (or/c nonnegative-integer? #f) = #f
  end : (or/c nonnegative-integer? #f) = #f
  fps : (>=/c 0) = 25
Renders a video object. This function is completely synchronous and it is impossible to determine the progress within Racket. If being asynchronous or just determining progress is important, use render/async.

data is any video? object. This can be set with either external-video or any argument that creates a video object, playlist or clip for example.

dest is the output file. If the path is relative it is resolved against current-directory. The output format can be auto-detected by the extension of the dest file. For example, the renderer will produce an MP4 file (with appropriate codecs) for a file ending in ".mp4".

The render-mixin parameter specifics an optional mixin for the renderer. This is useful for altering the behavior of the renderer, such as to render to an OpenGL context.

The start, end, width, and height parameters are all optional, and set their relative properties in resulting output. Additional options exist when using the render% class directly.

procedure

(render/async data 
  [dest 
  #:dest-filename dest-filename 
  #:render-mixin render-mixin 
  #:width width 
  #:height height 
  #:start start 
  #:end end 
  #:fps fps 
  #:mode mode]) 
  
async-channel? (-> void?)
  data : video?
  dest : (or/c path path-string? #f) = "out.mp4"
  dest-filename : (or/c path-element? string? #f) = #f
  render-mixin : (-> (is-a?/c render<%>) (is-a?/c render<%>))
   = values
  width : nonnegative-integer? = 1920
  height : nonnegative-integer? = 1080
  start : (or/c nonnegative-integer? #f) = #f
  end : (or/c nonnegative-integer? #f) = #f
  fps : (>=/c 0) = 25
  mode : (or/c 'verbose #f) = #f
Similar to render, but runs asynchronously. This is useful for determining the status while still rendering.

When called, the render/aync function begins rendering and immediately returns an output channel. While rendering, it places its current status on the channel. The renderer puts eof on the channel to signal that it has finished and will send no more messages.

If the optional mode flag is set to 'verbose, then the renderer will additionally return status messages.

procedure

(render/pretty data    
  [dest    
  #:dest-filename dest-filename    
  #:render-mixin render-mixin    
  #:width width    
  #:height height    
  #:start start    
  #:end end    
  #:fps fps    
  #:port port]    
  #:mode mode)  void?
  data : video?
  dest : (or/c path path-string? #f) = "out.mp4"
  dest-filename : (or/c path-element? string? #f) = #f
  render-mixin : (-> (is-a?/c render<%>) (is-a?/c render<%>))
   = values
  width : nonnegative-integer? = 1920
  height : nonnegative-integer? = 1080
  start : (or/c nonnegative-integer? #f) = #f
  end : (or/c nonnegative-integer? #f) = #f
  fps : (>=/c 0) = 25
  port : (or/c output-port? #f) = #f
  mode : (or/c 'verbose #f)
Similar to render/async, but will run synchronously. Additionally, rather than making a channel and sending data to that channel, the result will be printed to current-output-port.

If port is provided, then the output will be sent to that port rather than #racket[current-output-port].

This function is designed to be used directly when repl-like interaction is desired.

5.2 Render Class🔗ℹ

The render% class interface provides a more low-level access to Video’s rendering interface. Using the render function directly is preferred.

Unlike the previous section, the render% class is unstable. It should remain stable between patch releases, but can change between minor releases.

class

render% : class?

  superclass: object%

  extends: render<%>
The class used for rendering. By default it outputs the video directly to the screen. Mixins can be used to extend this class to change what it outputs too.

constructor

(new render% [source source])  (is-a?/c render%)

  source : video?
Constructs the Renderer for the given video source. The renderer can process the video multiple times, but setup must be called in between uses.

method

(send a-render setup settings)  void?

  settings : render-settings?
Sets up the render properties (width, height, etc.). Must be called between each use of start-rendering.

method

(send a-render start-rendering)  void?

method

(send a-render stop-rendering)  void?

interface

render<%> : interface?

An interface for the render% class.

5.3 Render Settings🔗ℹ

The render-settings struct determines the available settings when rendering.

procedure

(render-settings? settings)  boolean?

  settings : any/c
Returns #t if settings is a render-settings?, #f otherwise.

procedure

(make-render-settings [#:destination dest 
  #:width width 
  #:height height 
  #:start start 
  #:end end 
  #:fps fps 
  #:format format 
  #:video-codec video-codec 
  #:audio-codec audio-codec 
  #:subtitle-codec subtitle-codec 
  #:pix-fmt pix-fmt 
  #:sample-fmt sample-fmt 
  #:sample-rate sample-rate 
  #:channel-layout channel-layout 
  #:speed speed]) 
  render-settings?
  dest : (or/c path? path-string? #f) = #f
  width : (and/c integer? positive?) = 1920
  height : (and/c integer? positive?) = 1080
  start : (or/c (and/c real? (>=/c 0)) #f) = #f
  end : (or/c (and/c real? (>=/c 0)) #f) = #f
  fps : real? = 30
  format : (or/c symbol? #f) = #f
  video-codec : (or/c symbol? #f) = #f
  audio-codec : (or/c symbol? #f) = #f
  subtitle-codec : (or/c symbol? #f) = #f
  pix-fmt : symbol? = 'yuv420p
  sample-fmt : symbol? = 'fltp
  sample-rate : (and/c real? positive?) = 44100
  channel-layout : symbol? = 'stereo
  speed : real? = 1
Constructs a render-settings? object. Every field is optional.