Video cheat sheet

Extract H.264 bitstream from MP4:

ffmpeg -i source.mp4 -map 0:v -vcodec copy -bsf:v h264_mp4toannexb source-video.h264

Extract H.265 (HEVC) bitstream from MP4:

ffmpeg -i source.mp4 -map 0:v -vcodec copy -bsf:v hevc_mp4toannexb source-video.h265

Regenerate presentation time stamps for raw bitstream (-r 60 is the frame rate)

ffmpeg -fflags +genpts -r 60 -i source-video.h26x -vcodec copy output.mp4

Change container from MP4 to MKV without re-encoding:

ffmpeg -i input.mp4 -c copy output.mkv

Install MKV tools in MacOS (mkvmerge, etc):

brew install mkvtoolnix

Dump file info with ffprobe:

ffprobe -i input.ts -show_frames -select_streams v:0 -print_format flat

Video terminology:

  • MPEG-4 part 14 / MP4 - container format
    • Reference list
    • atom / atoms - all “structures” in an MP4 stream are referred to as atoms
    • box / boxes - an alternative to atom but means the same thing