User Tools

Site Tools


utils_video_encoding

This is an old revision of the document!


Video encoding (ffmpeg) commands and explanations

Compress video stream

Compression without important video quality loss (tested with relatively low quality full HD source):
$ ffmpeg -i input -vcodec libx265 -crf 24 output
⇒ -crf is the compression factor. Lower is better, 24 is about as low as is useful for libx265
⇒ -map 0 to keep all streams (audio, subtitles, but also video)
⇒ Use -vf scale=-1:720 to resize to 720p (keeping aspect ratio with -1, resulting in calculation of width)

Select language streams

Do not re-encode streams, keep all subtitles and select English and French audio languages:
$ ffmpeg -i input -map 0:v -map 0:s -map 0:m:language:eng -map 0:m:language:fre? -c copy output
⇒ -c copy to avoid re-encoding streams
⇒ -map:0:v to keep all video streams
⇒ -map 0:s to keel all subtitle streams
⇒ -map 0:m:language:eng to keep streams with english metadata defined (all types of streams but impacting only audio (a) since we're keeping all subtitles in this case)
⇒ the ? at the end of -map instruction avoids failure if the matching input is missing

utils_video_encoding.1592170405.txt.gz · Last modified: 2020/06/14 21:33 by xavier