Membrane.H264.FFmpeg.Encoder (Membrane H264 FFmpeg plugin v0.32.6)
View SourceMembrane element that encodes raw video frames to H264 format.
The element expects each frame to be received in a separate buffer, so the parser
(Membrane.Element.RawVideo.Parser) may be required in a pipeline before
the encoder (e.g. when input is read from Membrane.File.Source).
Additionally, the encoder has to receive proper stream_format with picture format and dimensions before any encoding takes place.
Please check t/0 for available options.
Element options
Passed via struct Membrane.H264.FFmpeg.Encoder.t/0
crf0..63Default value:
23
Constant rate factor that affects the quality of output stream. Value of 0 is lossless compression while 51 (for 8-bit samples) or 63 (10-bit) offers the worst quality. The range is exponential, so increasing the CRF value +6 results in roughly half the bitrate / file size, while -6 leads to roughly twice the bitrate.presetpreset()Default value:
:medium
Collection of predefined options providing certain encoding. The slower the preset chosen, the higher compression for the same quality can be achieved.profileH264.profile() | nilDefault value:
nil
Sets a limit on the features that the encoder will use to the ones supported in a provided H264 profile. Said features will have to be supported by the decoder in order to decode the resulting video. It may override other, more specific options affecting compression (e.g settingmax_b_framesto 2 while profile is set to:baselinewill have no effect and no B-frames will be present).tunetune() | nilDefault value:
nil
Optionally tune the encoder settings for a particular type of source or situation. Seex264encoder's man page for more info. Available options are::film- use for high quality movie content; lowers deblocking:animation- good for cartoons; uses higher deblocking and more reference frames:grain- preserves the grain structure in old, grainy film material:stillimage- good for slideshow-like content:fastdecode- allows faster decoding by disabling certain filters:zerolatency- good for fast encoding and low-latency streaming
use_shm?boolean()Default value:
false
If true, native encoder will use shared memory (viaShmex.t/0) for storing framesmax_b_framesnon_neg_integer() | nilDefault value:
nil
Maximum number of B-frames between non-B-frames. Set to 0 to encode video without b-framesgop_sizenon_neg_integer() | nilDefault value:
nil
Number of frames in a group of pictures.sc_thresholdnon_neg_integer()Default value:
40
Sets the threshold for scene change detection. This determines how aggressivelyx264will try to insert extra I-frames (higher values increase the number of scene changes detected). Set to 0 to disable scene change detection (no extra I-frames will be inserted). See this page for more info.ffmpeg_params%{String.t() => String.t()}Default value:
%{}
A map with parameters that are passed to the encoder.You can use options from: https://ffmpeg.org/ffmpeg-codecs.html#libx264_002c-libx264rgb and https://ffmpeg.org/ffmpeg-codecs.html#Codec-Options Options available in the element options (
Membrane.H264.FFmpeg.Encoder.t/0), likesc_thresholdorcrf, must be set there and not throughffmpeg_params.
Pads
:input
Accepted formats:
%RawVideo{pixel_format: format, aligned: true} when format in [:I420, :I422]| Direction: | :input |
| Availability: | :always |
| Flow control: | :auto |
:output
Accepted formats:
%H264{alignment: :au, stream_structure: :annexb}| Direction: | :output |
| Availability: | :always |
| Flow control: | :auto |
Summary
Types
@type preset() ::
:ultrafast
| :superfast
| :veryfast
| :faster
| :fast
| :medium
| :slow
| :slower
| :veryslow
| :placebo
@type t() :: %Membrane.H264.FFmpeg.Encoder{ crf: 0..63, ffmpeg_params: %{required(String.t()) => String.t()}, gop_size: non_neg_integer() | nil, max_b_frames: non_neg_integer() | nil, preset: preset(), profile: Membrane.H264.profile() | nil, sc_threshold: non_neg_integer(), tune: tune() | nil, use_shm?: boolean() }
Struct containing options for Membrane.H264.FFmpeg.Encoder
@type tune() :: :film | :animation | :grain | :stillimage | :fastdecode | :zerolatency
Functions
@spec options() :: keyword()
Returns description of options available for this module