A handy cheat sheet for various FFmpeg commands I use frequently.
ffmpeg -i input -c:v libx265 -c:a copy output
- For Apple compatibility, add
-tag:v hvc1
- For Apple hardware acceleration, replace
-c:v libx265
with-c:v hevc_videotoolbox
(faster but produces lower quality video and larger file sizes) - Lower the constant rate factor (default
28
) and use a slower preset (defaultmedium
) for better quality and compression e.g.-crf 25 -preset slow
- If there are audio issues, replace
-c:a copy output
with-c:a aac -ac 2
for stereo audio or-c:a eac3
for multi-channel audio. Consider specifying the audio bitrate too, e.g.-b:a 224k
ffmpeg -i input -c:v libaom-av1 -c:a copy output
ffmpeg -i input.mkv -codec copy output.mp4
- Add
-c:s mov_text
to copy text-based subtitles (cannot convert subs likedvd_subtitle
to text) - Add
-tag:v hvc1
to translate Apple HEVC compatibility (see Translation)
ffmpeg -i input.mp4 -i subs.srt -c copy -c:s mov_text -metadata:s:s:0 language=eng output.mp4
-metadata:s:s:0 language=eng
can be omitted
ffmpeg -i input.mp4 -i english.srt -i japanese.srt -c copy -map 0:v:0 -map 0:a:0 -map 1 -map 2 -c:s mov_text -metadata:s:s:0 language=eng -metadata:s:s:1 language=jpn output.mp4
-metadata:s:s:0 language=eng -metadata:s:s:1 language=jpn
can be omitted
ffmpeg -i input.mkv -c copy -map 0:v:0 -map 0:a:0 -map 0:s:9 -map 0:s:19 -c:s mov_text output.mp4
- Metadata is also copied from original
0:s:8
and0:s:19
represent subtitle streams9
and20
respectively- Can be used in concert with HEVC translation by adding
-tag:v hvc1
- Consider
-map 0:v
and-map 0:a
instead of-map 0:v:0
and-map 0:a:0
respectively
ffmpeg -i input -codec copy -tag:v hvc1 output.mp4
- Audio stream may require altering to be compatible:
- Stereo:
-c:a aac -ac 2
- Multi-channel:
-c:a eac3
(may require-filter_complex "channelmap=channel_layout=5.1" -c:a aac
)
- Stereo:
- Add
-c:s mov_text
to copy text-based subtitles (cannot convert subs likedvd_subtitle
to text)