Make and validate a first FFmpeg video encode
This workflow creates a short test in Matroska. It maps the first video stream, optionally maps audio,
encodes video with x264, and encodes audio with Opus. Your FFmpeg build must include libx264 and
libopus.
Inspect the input
Section titled “Inspect the input”ffprobe -v error -show_format -show_streams -of json input.mkvffmpeg -hide_banner -h encoder=libx264ffmpeg -hide_banner -h encoder=libopusConfirm the source stream indexes, frame rate, pixel format, resolution, color metadata, audio layout, and subtitles before encoding.
Encode a 30-second sample
Section titled “Encode a 30-second sample”ffmpeg -ss 00:05:00 -i input.mkv -t 30 \ -map 0:v:0 -map '0:a?' \ -c:v libx264 -preset slow -crf 20 -pix_fmt yuv420p \ -c:a libopus -b:a 128k \ sample.mkv-map makes stream selection explicit. The ? makes the audio mapping optional. -crf controls the
x264 quality/size tradeoff, while -preset controls its speed/compression tradeoff. The yuv420p
pixel format is a compatibility choice and may be wrong for high-bit-depth or HDR sources.
Validate
Section titled “Validate”ffmpeg -v error -i sample.mkv -f null -ffprobe -v error -show_format -show_streams -of json sample.mkvThe decode check should print no errors. Confirm the expected stream count, codecs, duration, resolution, pixel format, and color fields. Finally watch the whole sample on a target player and seek through it.