Merge video + audio and convert to 8-bit H.264 with deinterlace
ffmpeg -i Svatba_Petr_1.m2v -i Svatba_Petr_1.wav -c:v libx264 -crf 18 -vf "bwdif,format=yuv420p" -c:a aac D:\output3.mp4
-
Adjust the
-crfvalue to provide the desired level of quality. Add the-presetoption if you want to adjust encoding speed. See FFmpeg Wiki: H.264 for more info on-crfand-preset. -
Uses the format filter to choose the
yuv420ppixel format to create 8-bit output. bwdif- deinterlace.
10-bit/12-bit HEVC to 8-bit H.264
ffmpeg -i input -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy output.mkv
-
-map 0will include all streams (default stream selection only selects 1 stream per type). See FFmpeg Wiki: Map. -
Adjust the
-crfvalue to provide the desired level of quality. Add the-presetoption if you want to adjust encoding speed. See FFmpeg Wiki: H.264 for more info on-crfand-preset. -
Uses the format filter to choose the
yuv420ppixel format to create 8-bit output.
10-bit/12-bit HEVC to 10-bit H.264
ffmpeg -i input -map 0 -c:v libx264 -crf 18 -c:a copy output.mkv
-
-map 0will include all streams (default stream selection only selects 1 stream per type). See FFmpeg Wiki: Map. -
Adjust the
-crfvalue to provide the desired level of quality. Add the-presetoption if you want to adjust encoding speed. See FFmpeg Wiki: H.264 for more info on-crfand-preset. -
No need for the format filter in this case.
10-bit/12-bit HEVC to 8-bit HEVC
ffmpeg -i input -map 0 -c:v libx265 -crf 20 -vf format=yuv420p -c:a copy output.mkv
-
-map 0will include all streams (default stream selection only selects 1 stream per type). See FFmpeg Wiki: Map. -
Adjust the
-crfvalue to provide the desired level of quality. Add the-presetoption if you want to adjust encoding speed. See FFmpeg Wiki: HEVC / H.265 for more info on-crfand-preset. -
Uses the format filter to choose the
yuv420ppixel format to create 8-bit output.
12-bit HEVC to 10-bit HEVC
ffmpeg -i input -map 0 -c:v libx265 -crf 20 -vf format=yuv420p10le -c:a copy output.mkv
-
-map 0will include all streams (default stream selection only selects 1 stream per type). See FFmpeg Wiki: Map. -
Adjust the
-crfvalue to provide the desired level of quality. Add the-presetoption if you want to adjust encoding speed. See FFmpeg Wiki: HEVC / H.265 for more info on-crfand-preset. -
Uses the format filter to choose the
yuv420p10lepixel format to create 10-bit output. Other 10-bit pixel formats supported by libx265 areyuv422p10le&yuv444p10le, but your player may not like these. Seeffmpeg -h encoder=libx265for additional supported pixel formats.
GoPro 4K MPEG4 to FullHD 50p MPEG4 cca 1600-2000 kbps
ffmpeg -i GX010183.MP4 -vf scale=1920:1080 -crf 18 -c:a copy GX010183_fullHD.MP4
How to cut a video, without re-encoding
Use this to cut video from [start] for [duration]:
ffmpeg -ss [start] -i in.mp4 -t [duration] -map 0 -c copy out.mp4
Use this to cut video from [start] to [end]:
ffmpeg -copyts -ss [start] -i in.mp4 -to [end] -map 0 -c copy out.mp4
- -ss specifies the start time, e.g. 00:01:23.000 or 83 (in seconds)
- -t specifies the duration of the clip. The format of the time is the same
- Instead of -t, you can also use -to, which specifies the end time
- -map 0 maps all streams: audio, video and subtitles
- -copyts preserves the original timestamps from the input file
- -c copy copies the first video, audio, and subtitle bitstream from the input to the output file without re-encoding them. This won't harm the quality and make the command run within seconds
Repair end time code:
ffmpeg -i temp.mp4 -c copy -copyts out.mp4
