Overview 

An Encoding Profile has the information for the encoder about the number of renditions that will be created for a video and audio file in multiple formats such as mp4 (1080p, 720p, 480p, 360p, 240p), HLS, mp3(128k, 256k, 96k), etc. VIDIZMO allows you to define encoding profiles against any encoder of your choice. These are primarily the output format profiles for any media file.

There are multiple Encoding Profiles available by default in VIDIZMO, which specify certain parameters of what should be the format/properties of the output file after transcoding. However, VIDIZMO allows you to define custom encoding profiles based on your own requirements. A video would be transcoded to multiple renditions depending on the encoding profiles that are configured and enabled in your VIDIZMO Portal.  


To learn more about Encoding Profiles, see Understanding Encoding Profiles in VIDIZMO. 

 

Pre-Configured Encoding Profiles in VIDIZMO On-Prem Encoder

Videos are typically delivered to devices and apps by progressive download or through adaptive bitrate streaming. If you wish to deliver by progressive download, you can make use of pre-configured MP4 encoding profiles or customize them based on your needs. However, if you want to prepare your content for delivery by adaptive bitrate streaming then the pre-configured HLS encoding profiles can be used to encode a digital media file at multiple bitrates (high to low). These HLS encoding profiles can also be customized to fit any further needs. 


Customizing Encoding Profile based on several parameters 

The list of following parameters can be modified or added in order to tweak the encoding profiles to cater to the several video qualities, processing speeds and storage based on the organization's needs. 


Understanding VIDIZMO Specific Tags  

The following tags are specific to VIDIZMO and their values are defined during the runtime operation of transcoding after the video has been uploaded or submitted for encoding job. 

  1. [decoder_fourcc] -> It is defined as the value of any video that is pre-encoded.   
  2. [source] -> It is defined as a path of the source file that is uploaded. This cannot be modified. 
  3. [vid_channel_layouts] -> This tag determines the value of channels used in the file uploaded. 
  4. [hls_key_file] -> The key for encryption is defined in this tag.
  5. [stream-map] -> This tag determines the mapping that is done between audio and video different renditions. 
  6. [output-short-name-master] - It is defined as the path of the master file of different renditions.  
  7. [output-short-name] -> It is defined as the path of the file of different renditions. 

 

Constant Rate Factor  

Constant Rate Factor is a rate control mode that focuses on great quality and cares less about the file size. It allows the encoder to attempt to achieve a certain output quality for the whole file when output file size is of less importance. This provides maximum compression efficiency with a single pass. The downside is that you can't tell it to get a specific file size or not go over a specific size or bitrate, which means that this method is not recommended for encoding videos for streaming. The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default, and 51 is worst quality possible. A lower value generally leads to higher quality, and a subjectively sane range is 17–28.


You can add/modify -crf parameter in the encoding profile as shown in the complete command below:

-y -threads 1 [decoder_fourcc] -i [source] -c:v libx264 -r 29.970 -g 60 -pix_fmt yuv420p -ac 2 -c:a aac [vid_channel_layouts] -filter_complex "[0:v]split=[split-num][240-start][v1][240-end][360-start][v2][360-end][480-start][v3][480-end][720-start][v4][720-end][1080-start][v5][1080-end][1440-start][v6][1440-end][1440-start][v7][1440-end][2160-start][v8][2160-end][2160-start][v9][2160-end];[240-start][v1]scale=trunc((oh*a)/2)*2:240[v1out];[240-end][360-start][v2]scale=trunc((oh*a)/2)*2:360[v2out];[360-end][480-start][v3]scale=trunc((oh*a)/2)*2:480[v3out];[480-end][720-start][v4]scale=trunc((oh*a)/2)*2:720[v4out];[720-end][1080-start][v5]scale=trunc((oh*a)/2)*2:1080[v5out];[1080-end][1440-start][v6]scale=trunc((oh*a)/2)*2:1440[v6out];[1440-end][1440-start][v7]scale=trunc((oh*a)/2)*2:1440[v7out];[1440-end][2160-start][v8]scale=trunc((oh*a)/2)*2:2160[v8out];[2160-end][2160-start][v9]scale=trunc((oh*a)/2)*2:2160[v9out];[2160-end]" [240-start]-map [v1out] -profile:v baseline -level 3.0 -crf 26 -b:v:0 [output-bitrate-200k] -maxrate:v:0 [output-bitrate-200k] -minrate:v:0 [output-bitrate-200k] -bufsize:v:0 [output-bitrate-200k]*2[240-end] [360-start]-map [v2out] -profile:v baseline -level 3.0 -crf 26 -b:v:1 [output-bitrate-512k] -maxrate:v:0 [output-bitrate-512k] -minrate:v:0 [output-bitrate-512k] -bufsize:v:0 [output-bitrate-512k]*2[360-end] [480-start]-map [v3out] -profile:v baseline -level 3.1 -crf 25 -b:v:2 [output-bitrate-768k] -maxrate:v:0 [output-bitrate-768k] -minrate:v:0 [output-bitrate-768k] -bufsize:v:0 [output-bitrate-768k]*2[480-end] [720-start]-map [v4out] -profile:v main -level 4.0 -crf 24 -b:v:3 [output-bitrate-3072k] -maxrate:v:0 [output-bitrate-3072k] -minrate:v:0 [output-bitrate-3072k] -bufsize:v:0 [output-bitrate-3072k]*2[720-end] [1080-start]-map [v5out] -profile:v main -level 4.2 -crf 23 -b:v:4 [output-bitrate-6144k] -maxrate:v:0 [output-bitrate-6144k] -minrate:v:0 [output-bitrate-6144k] -bufsize:v:0 [output-bitrate-6144k]*2[1080-end] [1440-start]-map [v6out] -profile:v high -level 5.1 -crf 22 -b:v:5 [output-bitrate-8192k] -maxrate:v:0 [output-bitrate-8192k] -minrate:v:0 [output-bitrate-8192k] -bufsize:v:0 [output-bitrate-8192k]*2[1440-end] [1440-start]-map [v7out] -profile:v high -level 5.1 -crf 22 -b:v:6 [output-bitrate-10240k] -maxrate:v:0 [output-bitrate-10240k] -minrate:v:0 [output-bitrate-10240k] -bufsize:v:0 [output-bitrate-10240k]*2[1440-end] [2160-start]-map [v8out] -profile:v high -level 5.2 -crf 22 -b:v:7 [output-bitrate-16384k] -maxrate:v:0 [output-bitrate-16384k] -minrate:v:0 [output-bitrate-16384k] -bufsize:v:0 [output-bitrate-16384k]*2[2160-end] [2160-start]-map [v9out] -profile:v high -level 5.2 -crf 22 -b:v:8 [output-bitrate-20480k] -maxrate:v:0 [output-bitrate-20480k] -minrate:v:0 [output-bitrate-20480k] -bufsize:v:0 [output-bitrate-20480k]*2[2160-end] [240-start]-map a:0 -b:a:0 48k[240-end] [360-start]-map a:0 -b:a:1 48k [360-end] [480-start]-map a:0 -b:a:2 64k [480-end] [720-start]-map a:0 -b:a:3 78k [720-end] [1080-start]-map a:0 -b:a:4 78k [1080-end] [1440-start]-map a:0 -b:a:5 84k [1440-end] [1440-start]-map a:0 -b:a:6 108k [1440-end] [2160-start]-map a:0 -b:a:7 128k [2160-end] [2160-start]-map a:0 -b:a:8 161k [2160-end] -f hls [hls_key_file] -hls_time 8 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename [output-short-name]_%v_data%02d.ts -master_pl_name [output-short-name-master].m3u8 -var_stream_map "[stream-map]" [output-short-name]_rendition_%v.m3u8
                                        

Presets    

A preset is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize). This means that, for example, if you target a certain file size or constant bit rate, you will achieve better quality with a slower preset. Similarly, for constant quality encoding, you will simply save bitrate by choosing a slower preset.  The available presets in descending order of speed are: 

  • ultrafast 

  • superfast 

  • veryfast 

  • faster 

  • fast 

  • Medium 

  • slow 

  • slower 

  • veryslow 

The default preset is medium.  


You can add/modify -preset parameter in the encoding profile as shown in the complete command below where the value of the preset is set as medium:


-y -threads 1 [decoder_fourcc] -i [source] -c:v libx264 preset medium -r 29.970 -g 60 -pix_fmt yuv420p -ac 2 -c:a aac [vid_channel_layouts] -filter_complex "[0:v]split=[split-num][240-start][v1][240-end][360-start][v2][360-end][480-start][v3][480-end][720-start][v4][720-end][1080-start][v5][1080-end][1440-start][v6][1440-end][1440-start][v7][1440-end][2160-start][v8][2160-end][2160-start][v9][2160-end];[240-start][v1]scale=trunc((oh*a)/2)*2:240[v1out];[240-end][360-start][v2]scale=trunc((oh*a)/2)*2:360[v2out];[360-end][480-start][v3]scale=trunc((oh*a)/2)*2:480[v3out];[480-end][720-start][v4]scale=trunc((oh*a)/2)*2:720[v4out];[720-end][1080-start][v5]scale=trunc((oh*a)/2)*2:1080[v5out];[1080-end][1440-start][v6]scale=trunc((oh*a)/2)*2:1440[v6out];[1440-end][1440-start][v7]scale=trunc((oh*a)/2)*2:1440[v7out];[1440-end][2160-start][v8]scale=trunc((oh*a)/2)*2:2160[v8out];[2160-end][2160-start][v9]scale=trunc((oh*a)/2)*2:2160[v9out];[2160-end]" [240-start]-map [v1out] -profile:v baseline -level 3.0 -crf 26 -b:v:0 [output-bitrate-200k] -maxrate:v:0 [output-bitrate-200k] -minrate:v:0 [output-bitrate-200k] -bufsize:v:0 [output-bitrate-200k]*2[240-end] [360-start]-map [v2out] -profile:v baseline -level 3.0 -crf 26 -b:v:1 [output-bitrate-512k] -maxrate:v:0 [output-bitrate-512k] -minrate:v:0 [output-bitrate-512k] -bufsize:v:0 [output-bitrate-512k]*2[360-end] [480-start]-map [v3out] -profile:v baseline -level 3.1 -crf 25 -b:v:2 [output-bitrate-768k] -maxrate:v:0 [output-bitrate-768k] -minrate:v:0 [output-bitrate-768k] -bufsize:v:0 [output-bitrate-768k]*2[480-end] [720-start]-map [v4out] -profile:v main -level 4.0 -crf 24 -b:v:3 [output-bitrate-3072k] -maxrate:v:0 [output-bitrate-3072k] -minrate:v:0 [output-bitrate-3072k] -bufsize:v:0 [output-bitrate-3072k]*2[720-end] [1080-start]-map [v5out] -profile:v main -level 4.2 -crf 23 -b:v:4 [output-bitrate-6144k] -maxrate:v:0 [output-bitrate-6144k] -minrate:v:0 [output-bitrate-6144k] -bufsize:v:0 [output-bitrate-6144k]*2[1080-end] [1440-start]-map [v6out] -profile:v high -level 5.1 -crf 22 -b:v:5 [output-bitrate-8192k] -maxrate:v:0 [output-bitrate-8192k] -minrate:v:0 [output-bitrate-8192k] -bufsize:v:0 [output-bitrate-8192k]*2[1440-end] [1440-start]-map [v7out] -profile:v high -level 5.1 -crf 22 -b:v:6 [output-bitrate-10240k] -maxrate:v:0 [output-bitrate-10240k] -minrate:v:0 [output-bitrate-10240k] -bufsize:v:0 [output-bitrate-10240k]*2[1440-end] [2160-start]-map [v8out] -profile:v high -level 5.2 -crf 22 -b:v:7 [output-bitrate-16384k] -maxrate:v:0 [output-bitrate-16384k] -minrate:v:0 [output-bitrate-16384k] -bufsize:v:0 [output-bitrate-16384k]*2[2160-end] [2160-start]-map [v9out] -profile:v high -level 5.2 -crf 22 -b:v:8 [output-bitrate-20480k] -maxrate:v:0 [output-bitrate-20480k] -minrate:v:0 [output-bitrate-20480k] -bufsize:v:0 [output-bitrate-20480k]*2[2160-end] [240-start]-map a:0 -b:a:0 48k[240-end] [360-start]-map a:0 -b:a:1 48k [360-end] [480-start]-map a:0 -b:a:2 64k [480-end] [720-start]-map a:0 -b:a:3 78k [720-end] [1080-start]-map a:0 -b:a:4 78k [1080-end] [1440-start]-map a:0 -b:a:5 84k [1440-end] [1440-start]-map a:0 -b:a:6 108k [1440-end] [2160-start]-map a:0 -b:a:7 128k [2160-end] [2160-start]-map a:0 -b:a:8 161k [2160-end] -f hls [hls_key_file] -hls_time 8 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename [output-short-name]_%v_data%02d.ts -master_pl_name [output-short-name-master].m3u8 -var_stream_map "[stream-map]" [output-short-name]_rendition_%v.m3u8
                                        


Profiles  

You can think of the profile as the level of complexity required in encode / decode. The higher the complexity, the more CPU power is needed to encode/decode. Setting a profile, constrains the encode to using settings that are allowed for that profile level. 

Typically, devices will advertise that they are compatible for a particular profile and level, so you can simply set the option that matches your device for the best chance of compatibility. 

  • Auto (Recommended) 

This will automatically set the profile based on all the options that have been selected. 

It is recommended that you use this option unless you need to set a profile to ensure compatibility for a particular device. 

  • Baseline 

Baseline encodes are the most basic form of encoding. While decoding is much easier, it may also require much higher bit-rates to maintain the same level of quality. 

  • Main 

The middle ground. Most modern / current devices will support this profile. 

  • High Profile 

For best quality and filesize at the expense of CPU time in both decode and encode. 


Note:  Setting a profile does not mean your encoded file will end up being that profile. It simply prevents options being used that would breach that profile constraint.

   

You can add/modify -profile parameter in the encoding profile as shown in the complete command below where the value of the profile is set as high for higher renditions and baseline for lower renditions:


-y -threads 1 [decoder_fourcc] -i [source] -c:v libx264 -r 29.970 -g 60 -pix_fmt yuv420p -ac 2 -c:a aac [vid_channel_layouts] -filter_complex "[0:v]split=[split-num][240-start][v1][240-end][360-start][v2][360-end][480-start][v3][480-end][720-start][v4][720-end][1080-start][v5][1080-end][1440-start][v6][1440-end][1440-start][v7][1440-end][2160-start][v8][2160-end][2160-start][v9][2160-end];[240-start][v1]scale=trunc((oh*a)/2)*2:240[v1out];[240-end][360-start][v2]scale=trunc((oh*a)/2)*2:360[v2out];[360-end][480-start][v3]scale=trunc((oh*a)/2)*2:480[v3out];[480-end][720-start][v4]scale=trunc((oh*a)/2)*2:720[v4out];[720-end][1080-start][v5]scale=trunc((oh*a)/2)*2:1080[v5out];[1080-end][1440-start][v6]scale=trunc((oh*a)/2)*2:1440[v6out];[1440-end][1440-start][v7]scale=trunc((oh*a)/2)*2:1440[v7out];[1440-end][2160-start][v8]scale=trunc((oh*a)/2)*2:2160[v8out];[2160-end][2160-start][v9]scale=trunc((oh*a)/2)*2:2160[v9out];[2160-end]" [240-start]-map [v1out] -profile:v baseline -level 3.0 -crf 26 -b:v:0 [output-bitrate-200k] -maxrate:v:0 [output-bitrate-200k] -minrate:v:0 [output-bitrate-200k] -bufsize:v:0 [output-bitrate-200k]*2[240-end] [360-start]-map [v2out] -profile:v baseline -level 3.0 -crf 26 -b:v:1 [output-bitrate-512k] -maxrate:v:0 [output-bitrate-512k] -minrate:v:0 [output-bitrate-512k] -bufsize:v:0 [output-bitrate-512k]*2[360-end] [480-start]-map [v3out] -profile:v baseline -level 3.1 -crf 25 -b:v:2 [output-bitrate-768k] -maxrate:v:0 [output-bitrate-768k] -minrate:v:0 [output-bitrate-768k] -bufsize:v:0 [output-bitrate-768k]*2[480-end] [720-start]-map [v4out] -profile:v main -level 4.0 -crf 24 -b:v:3 [output-bitrate-3072k] -maxrate:v:0 [output-bitrate-3072k] -minrate:v:0 [output-bitrate-3072k] -bufsize:v:0 [output-bitrate-3072k]*2[720-end] [1080-start]-map [v5out] -profile:v main -level 4.2 -crf 23 -b:v:4 [output-bitrate-6144k] -maxrate:v:0 [output-bitrate-6144k] -minrate:v:0 [output-bitrate-6144k] -bufsize:v:0 [output-bitrate-6144k]*2[1080-end] [1440-start]-map [v6out] -profile:v high -level 5.1 -crf 22 -b:v:5 [output-bitrate-8192k] -maxrate:v:0 [output-bitrate-8192k] -minrate:v:0 [output-bitrate-8192k] -bufsize:v:0 [output-bitrate-8192k]*2[1440-end] [1440-start]-map [v7out] -profile:v high -level 5.1 -crf 22 -b:v:6 [output-bitrate-10240k] -maxrate:v:0 [output-bitrate-10240k] -minrate:v:0 [output-bitrate-10240k] -bufsize:v:0 [output-bitrate-10240k]*2[1440-end] [2160-start]-map [v8out] -profile:v high -level 5.2 -crf 22 -b:v:7 [output-bitrate-16384k] -maxrate:v:0 [output-bitrate-16384k] -minrate:v:0 [output-bitrate-16384k] -bufsize:v:0 [output-bitrate-16384k]*2[2160-end] [2160-start]-map [v9out] -profile:v high -level 5.2 -crf 22 -b:v:8 [output-bitrate-20480k] -maxrate:v:0 [output-bitrate-20480k] -minrate:v:0 [output-bitrate-20480k] -bufsize:v:0 [output-bitrate-20480k]*2[2160-end] [240-start]-map a:0 -b:a:0 48k[240-end] [360-start]-map a:0 -b:a:1 48k [360-end] [480-start]-map a:0 -b:a:2 64k [480-end] [720-start]-map a:0 -b:a:3 78k [720-end] [1080-start]-map a:0 -b:a:4 78k [1080-end] [1440-start]-map a:0 -b:a:5 84k [1440-end] [1440-start]-map a:0 -b:a:6 108k [1440-end] [2160-start]-map a:0 -b:a:7 128k [2160-end] [2160-start]-map a:0 -b:a:8 161k [2160-end] -f hls [hls_key_file] -hls_time 8 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename [output-short-name]_%v_data%02d.ts -master_pl_name [output-short-name-master].m3u8 -var_stream_map "[stream-map]" [output-short-name]_rendition_%v.m3u8


 

CBR/VBR and buffer size (bufsize) 

You can use Constant Bit Rate (CBR) if you want to constrain the maximum bitrate used or keep the stream's bitrate within certain bounds. This is particularly useful for online streaming, where a certain average bitrate is expected, but you still want the encoder to adjust the bitrate per-frame. 

Limiting the output bit rate to a certain range makes sense if you are live streaming or need to be constrained to a certain specification (such as Blu-ray encoding), where the decoder might not be able to handle large bitrate spikes. 

There are several options you can use to steer the encoder's bitrate: 

  • -b:v: specifies the target (average) bit rate for the encoder to use 

  • -minrate specifies a minimum tolerance to be used 

  • -maxrate specifies a maximum tolerance. this is only used in conjunction with bufsize 

  • -bufsize specifies the decoder buffer size, which determines the variability of the output bitrate 


Note: Constraining the bitrate might result in low quality output if the video is hard to encode. In most cases (such as storing a file for archival), letting the encoder choose the proper bitrate is the constant quality or CRF-based encoding.


You can add/modify these paramters by using -crf or -b:v with a maximum bit rate by specifying both -maxrate and -bufsize

-y -threads 1 [decoder_fourcc] -i [source] -c:v libx264 -r 29.970 -g 60 -pix_fmt yuv420p -ac 2 -c:a aac [vid_channel_layouts] -filter_complex "[0:v]split=[split-num][240-start][v1][240-end][360-start][v2][360-end][480-start][v3][480-end][720-start][v4][720-end][1080-start][v5][1080-end][1440-start][v6][1440-end][1440-start][v7][1440-end][2160-start][v8][2160-end][2160-start][v9][2160-end];[240-start][v1]scale=trunc((oh*a)/2)*2:240[v1out];[240-end][360-start][v2]scale=trunc((oh*a)/2)*2:360[v2out];[360-end][480-start][v3]scale=trunc((oh*a)/2)*2:480[v3out];[480-end][720-start][v4]scale=trunc((oh*a)/2)*2:720[v4out];[720-end][1080-start][v5]scale=trunc((oh*a)/2)*2:1080[v5out];[1080-end][1440-start][v6]scale=trunc((oh*a)/2)*2:1440[v6out];[1440-end][1440-start][v7]scale=trunc((oh*a)/2)*2:1440[v7out];[1440-end][2160-start][v8]scale=trunc((oh*a)/2)*2:2160[v8out];[2160-end][2160-start][v9]scale=trunc((oh*a)/2)*2:2160[v9out];[2160-end]" [240-start]-map [v1out] -profile:v baseline -level 3.0 -crf 26 -b:v:0 [output-bitrate-200k] -maxrate:v:0 [output-bitrate-200k] -minrate:v:0 [output-bitrate-200k] -bufsize:v:0 [output-bitrate-200k]*2[240-end] [360-start]-map [v2out] -profile:v baseline -level 3.0 -crf 26 -b:v:1 [output-bitrate-512k] -maxrate:v:0 [output-bitrate-512k] -minrate:v:0 [output-bitrate-512k] -bufsize:v:0 [output-bitrate-512k]*2[360-end] [480-start]-map [v3out] -profile:v baseline -level 3.1 -crf 25 -b:v:2 [output-bitrate-768k] -maxrate:v:0 [output-bitrate-768k] -minrate:v:0 [output-bitrate-768k] -bufsize:v:0 [output-bitrate-768k]*2[480-end] [720-start]-map [v4out] -profile:v main -level 4.0 -crf 24 -b:v:3 [output-bitrate-3072k] -maxrate:v:0 [output-bitrate-3072k] -minrate:v:0 [output-bitrate-3072k] -bufsize:v:0 [output-bitrate-3072k]*2[720-end] [1080-start]-map [v5out] -profile:v main -level 4.2 -crf 23 -b:v:4 [output-bitrate-6144k] -maxrate:v:0 [output-bitrate-6144k] -minrate:v:0 [output-bitrate-6144k] -bufsize:v:0 [output-bitrate-6144k]*2[1080-end] [1440-start]-map [v6out] -profile:v high -level 5.1 -crf 22 -b:v:5 [output-bitrate-8192k] -maxrate:v:0 [output-bitrate-8192k] -minrate:v:0 [output-bitrate-8192k] -bufsize:v:0 [output-bitrate-8192k]*2[1440-end] [1440-start]-map [v7out] -profile:v high -level 5.1 -crf 22 -b:v:6 [output-bitrate-10240k] -maxrate:v:0 [output-bitrate-10240k] -minrate:v:0 [output-bitrate-10240k] -bufsize:v:0 [output-bitrate-10240k]*2[1440-end] [2160-start]-map [v8out] -profile:v high -level 5.2 -crf 22 -b:v:7 [output-bitrate-16384k] -maxrate:v:0 [output-bitrate-16384k] -minrate:v:0 [output-bitrate-16384k] -bufsize:v:0 [output-bitrate-16384k]*2[2160-end] [2160-start]-map [v9out] -profile:v high -level 5.2 -crf 22 -b:v:8 [output-bitrate-20480k] -maxrate:v:0 [output-bitrate-20480k] -minrate:v:0 [output-bitrate-20480k] -bufsize:v:0 [output-bitrate-20480k]*2[2160-end] [240-start]-map a:0 -b:a:0 48k[240-end] [360-start]-map a:0 -b:a:1 48k [360-end] [480-start]-map a:0 -b:a:2 64k [480-end] [720-start]-map a:0 -b:a:3 78k [720-end] [1080-start]-map a:0 -b:a:4 78k [1080-end] [1440-start]-map a:0 -b:a:5 84k [1440-end] [1440-start]-map a:0 -b:a:6 108k [1440-end] [2160-start]-map a:0 -b:a:7 128k [2160-end] [2160-start]-map a:0 -b:a:8 161k [2160-end] -f hls [hls_key_file] -hls_time 8 -hls_playlist_type vod -hls_flags independent_segments -hls_segment_type mpegts -hls_segment_filename [output-short-name]_%v_data%02d.ts -master_pl_name [output-short-name-master].m3u8 -var_stream_map "[stream-map]" [output-short-name]_rendition_%v.m3u8

Two-Pass

This rate control mode is used when you are targeting a specific output file size, and if output quality from frame to frame is of less importance. This is best explained with an example. Your video is 25 minutes long and an output of 600 MiB is desired.


FastStart  

You can add -movflags +faststart as an output option if your videos are going to be viewed in a browser. This will move some information to the beginning of your file and allow the video to begin playing before it is completely downloaded by the viewer.   

Below is the complete command of the -movflags +faststart parameter.    

-y -threads 1 [decoder_fourcc] -i [source] -c:a aac [vid_channel_layouts] -max_muxing_queue_size 1024 -ar 48000 -c:v libx264 -g 60 -pix_fmt yuv420p -r 29.970 [240-start]-vf scale=trunc((oh*a)/2)*2:240,format=yuv420p -crf 26 -vsync 1 -r 29.970 -profile:v baseline -level 3.0 -g 60 -b:v [output-bitrate-200k]  -maxrate [output-bitrate-200k]  -bufsize [output-bitrate-200k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-200k]_[size-240].[outputformat][240-end] [360-start]-vf scale=trunc((oh*a)/2)*2:360,format=yuv420p -crf 26 -vsync 1 -r 29.970 -profile:v baseline -level 3.0 -g 60 -b:v [output-bitrate-512k]  -maxrate [output-bitrate-512k]  -bufsize [output-bitrate-512k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-512k]_[size-360].[outputformat][360-end] [480-start]-vf scale=trunc((oh*a)/2)*2:480,format=yuv420p -crf 25 -vsync 1 -r 29.970 -profile:v baseline -level 3.1 -g 60 -b:v [output-bitrate-768k] -maxrate [output-bitrate-768k]  -bufsize [output-bitrate-768k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-768k]_[size-480].[outputformat][480-end] [720-start]-vf scale=trunc((oh*a)/2)*2:720,format=yuv420p -crf 24 -vsync 1 -r 29.970 -profile:v main -level 4.0 -g 60 -b:v [output-bitrate-3072k]  -maxrate [output-bitrate-3072k]  -bufsize [output-bitrate-3072k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-3072k]_[size-720].[outputformat][720-end] [1080-start]-vf scale=trunc((oh*a)/2)*2:1080,format=yuv420p -crf 23 -vsync 1 -r 29.970 -profile:v main -level 4.2 -g 60 -b:v [output-bitrate-6144k]  -maxrate [output-bitrate-6144k]  -bufsize [output-bitrate-6144k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-6144k]_[size-1080].[outputformat][1080-end] [1440-start]-vf scale=trunc((oh*a)/2)*2:1440,format=yuv420p -crf 22 -vsync 1 -r 29.970 -profile:v high -level 5.1 -g 60 -b:v [output-bitrate-8192k] -maxrate [output-bitrate-8192k] -bufsize [output-bitrate-8192k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-8192k]_[size-1440].[outputformat][1440-end] [1440-start]-vf scale=trunc((oh*a)/2)*2:1440,format=yuv420p -crf 22 -vsync 1 -r 29.970 -profile:v high -level 5.1 -g 60 -b:v [output-bitrate-10240k] -maxrate [output-bitrate-10240k] -bufsize [output-bitrate-10240k] -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-10240k]_[size-1440].[outputformat][1440-end] [2160-start]-vf scale=trunc((oh*a)/2)*2:2160,format=yuv420p -crf 22 -vsync 1 -r 29.970 -profile:v high -level 5.2 -g 60 -b:v [output-bitrate-16384k] -maxrate [output-bitrate-16384k] -bufsize [output-bitrate-16384k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-16384k]_[size-2160].[outputformat][2160-end] [2160-start]-vf scale=trunc((oh*a)/2)*2:2160,format=yuv420p -crf 22 -vsync 1 -r 29.970 -profile:v high -level 5.2 -g 60 -b:v [output-bitrate-20480k] -maxrate [output-bitrate-20480k] -bufsize [output-bitrate-20480k]*2 -movflags +faststart -f mp4 [output-short-name]_[output-bitrate-20480k]_[size-2160].[outputformat][2160-end]
                                        


OpenCL  

It will give a slight encoding speed boost using GPU, without hurting quality.  To enable OpenCL look ahead add -x264opts opencl or -x264-params opencl=true to your command line. 

 

Frame Rate & Audio Rate 

Frame rate of an existing video can be changed, such that the output frame rate is lower or higher than the input frame rate. The output duration of the video will stay the same. 

This is useful when working with, for example, high-framerate input video that needs to be temporally scaled down for devices that do not support high FPS. 

To change the output frame rate to 30 fps, use the following command:

-i <input> -filter:v fps=30 <output>

If the input video was 60 fps, a drop would take place every other frame to get 30 fps output. 

   

Frame size 

If you need to simply resize your video to a specific size (e.g 320×240), you can use the scale filter in its most basic form: 

-i <input> -filter:v fps=30 <output>

Sometimes you need to scale the input image so that it fits into a specified rectangle, e.g. when consolidating material from different sources. 

You can achieve this with the force_original_aspect_ratio option. It has two possible values: 

  • decrease: The output video dimensions will automatically be decreased if needed. 

  • increase: The output video dimensions will automatically be increased if needed. 

This allows you to force the image to fit into a 320×240 box, downscaling it with the correct aspect ratio: 


-i input.jpg -vf scale=w=320:h=240:force_original_aspect_ratio=decrease output_320.png 

   


Audio Channels 

A channel is a representation of sound coming from or going to a single point. A single microphone can produce one channel of audio, and a single speaker can accept one channel of audio, for example. 

A digital audio file can contain multiple channels of data. Music that is mixed for headphone listening is saved as a file with two channels - one sent to the left ear, one sent to the right, while surround sound movie audio is often mixed for 6 channels. 

Mix a single stereo stream down to a mono stream. Both channels of the stereo stream will be downmixed into the stream: 

-i stereo.flac -ac 1 mono.flac  


Video/Audio Codec 

Video gets encoded with the H.264 codec, and audio with the AAC codec.  

Let us assume you would like to convert a video file, issue the following command: 

-i video.ts -vcodec libx264 -codec:a copy video.mp4


Pix_fmt  

yuv420p is a chroma subsampling scheme, and the p stands for planar, not progressive. By default, the value of –pix_fmt is yuv420p which is known as pixel format.   

   

Filters     

Filters sit between the input and the output and make some changes to the media flowing through them. A vast collection of many other filters can be combined to implement a lot of advanced requirements.  

  

Audio Filters 

atempo: You can speed up or slow down audio with this filter. It accepts exactly one parameter, the audio tempo. If not specified, then the filter will assume nominal 1.0 tempo. Tempo must be in the [0.5, 100.0] range. 

 

Video Filters  

minterpolate: You can smooth out slow/fast video with this video filter. This is also known as "motion interpolation" or "optical flow".