FFmpeg commands


Listing some of the commands that I am using these days while working with FFmpeg. Some readers may find them useful.


analyse motion vector data of any supported input video stream
ffplay -flags2 +export_mvs input.mp4 -vf codecview=mv=pf+bf+bb
ffmpeg -flags2 +export_mvs -i input.mp4 -vf codecview=mv=pf+bf+bb output.mp4



Convert any file to YUV420 file. Pixel format is YUV420P
ffmpeg -i akiyo.mp4 -c:v rawvideo -pix_fmt yuv420p akiyo.yuv



Convert any video file to HEVC using libx265
ffmpeg -i  input.mp4 -c:a copy -c:v libx265 out-hevc.mp4




Control frame rate to 5fps and play in full screen mode
ffplay -framerate 5 -fs str.bin


Play video files using FFPlay
ffplay akiyo.mp4
ffplay str.bin


Show all frame information, print frame wise information on terminal, can be modified to print on a file instead
ffprobe -show_frames  str.bin


Count number of frames in any video stream
ffprobe -v error -count_frames -select_streams v:0  -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 str.bin

Options description

  • -v error This hides “info” output (version info, etc) which makes parsing easier.
  • -count_frames Count the number of frames per stream and report it in the corresponding stream section.
  • -select_streams v:0 Select only the video stream.
  • -show_entries stream=nb_read_frames Show only the number of read frames.
  • -of default=nokey=1:noprint_wrappers=1 Set output format (aka the “writer”) to default, do not print the key of each field (nokey=1), and do not print the section header and footer (noprint_wrappers=1).




Extract Y, U and V components of a video sequence in separate video files
ffmpeg -i akiyo.mp4 -filter_complex 'extractplanes=y+u+v[y][u][v]' -map '[y]' y.avi -map '[u]' u.avi -map '[v]' v.avi


Fade first n frames in a sequence, n = 100 here
ffmpeg -i akiyo.mp4 -filter_complex 'fade=in:0:100' output.hevc

Personal notes -
  • akiyo.mp4 was approximately 470KB, it’s raw YUV is 42MB. The str.bin after HEVC main compression is 23.9KB for same visual quality
  • YUV name & size MP4 file size QP PSNR HEVC .bin size
    akiyo.yuv 470KB 32 40.48 23.9KB
    akiyo.yuv 470KB 51 28.94 5.4KB
    akiyo.yuv 470KB 20 47.21 151.4KB


About author

Devesh Samaiya

Chief Tinkerer at Lonely Night Projects

Leave a reply

Your email address will not be published. Required fields are marked *

34 − 25 =