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
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
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)
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.
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
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?
|
5.3 Render Settings
The render-settings struct determines the available settings when rendering.
procedure
(render-settings? settings) → boolean?
settings : any/c
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