Skip to content

ffmpegGuide

holzkohlengrill edited this page Dec 15, 2023 · 2 revisions

ffmpeg

General

  • ffmpeg does by default multiprocessing
  • Parts
    • ffmpeg >> conversion
    • ffplay >> displaying
    • ffprobe >> **interrogation **(characteristics of an AV-file)
    • fffserver >> streaming
    • + libraries available (e.g. for python, ...)

ffprobe

$ ffprobe -i imagine.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'blahbeauty.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf57.25.100
  Duration: 00:00:05.03, start: 0.000000, bitrate: 2167 kb/s
    Stream #0:0(und): Video: hevc (Main) (hev1 / 0x31766568), yuv420p(tv), 1920x1080, 2154 kb/s, 120 fps, 120 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler

  • -i >> next token is input
  • tbn: the time base in AVStream that has come from the container
  • tbc: the time base in AVCodecContext for the codec used for a particular stream
  • tbr: the value users want to see when they look for the video frame rate and is guessed from the video stream

ffplay

ffplay -vf "drawtext=text='%{pts\:hms}':box=1:x=(w-tw):y=h-(lh):fontsize=60" -s:v 3840x2160 -pix_fmt yuv420p -i myCoolVideo.yuv
       <------------------------------------------------------------------>   <--------------------------->
                            draws time into video                                video parameters for playing
  • Drawing
    • Separator is a column (:)
    • x and y are positions of the textbox
    • w: width of video
    • h: heigth of video
    • tw / th: text width/height

ffmpeg

Command overview

ffmpeg -pix_fmt yuv420p -r 120 -s:v 1920x1080 -i Beauty_1920x1080_120fps_420_8bit_YUV.yuv -c:v hevc blahbeauty.mp4
        <---------------------------------->                                               <----->   <-last token is 
                    input options                                                   output options    always output->

Useful options/flags

  • -hide_banner: removes stuff like:

      ffmpeg version 3.0.5-0ubuntu0.16.10.1 Copyright (c) 2000-2016 the FFmpeg developers
        built with gcc 6.2.0 (Ubuntu 6.2.0-5ubuntu12) 20161005
        configuration: --prefix=/usr --extra-version=0ubuntu0.16.10.1 --toolchain=hardened
        --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc
        --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg
        --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls
        --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca
        --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype
        --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame
        --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librubberband
        --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy
        --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame
        --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265
        --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab
        --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-chromaprint
        --enable-libx264
        libavutil      55. 17.103 / 55. 17.103
        libavcodec     57. 24.102 / 57. 24.102
        libavformat    57. 25.100 / 57. 25.100
        libavdevice    57.  0.101 / 57.  0.101
        libavfilter     6. 31.100 /  6. 31.100
        libavresample   3.  0.  0 /  3.  0.  0
        libswscale      4.  0.100 /  4.  0.100
        libswresample   2.  0.101 /  2.  0.101
        libpostproc    54.  0.100 / 54.  0.100
    
  • -y: auto-overwrite existing files

  • -pix_fmt: pixel format for RAW videos >> f.ex. yuv420p

  • -i: input file

  • -r: frame rate

  • -c:v: codec

    • qualifiers:
      • v: video
      • a: audio
      • s: subtitles
  • -profile:v: specify video codec profile

  • -ss 13:38: skip time >> start @ 13 min 38 s

  • -t 02:00: duration >> process input for x min (here f.ex. 2 min)

    • -f: force format

Useful tasks

Concatenate Videos

ffmpeg -f concat -i fileList.txt -c copy newconcat.mov
  • -f: force format
  • Structure of fileList.txt:

fileList.txt

file 'michael_1.mov'
file 'michael_2.mov'
file 'rachel_4.mov'

Extract images from video

ffmpeg -i "C:\Applications\FFMPEG\aa.mp4" "frames/out-%03d.jpg"

Available codecs

ffmpeg -codecs

Also possible ffmpeg -codecs:a (for audio codecs) of ffmpeg -codecs:v respectively.

Containter Formats

ffmpeg -formats

Pixel Formats

ffmpeg -pix_fmts
  • yuv420p10le for 10 4:2:0 videos

Warnings

Unkown side data type

Side data:
  unknown side data type 10 (24 bytes)

Can be ignored (http://superuser.com/questions/1022809/ffmpeg-warning-unknown-side-data-type)

yuv videos

Does not contain metadata >> needs to be specified. Example:

ffmpeg -pix_fmt yuv420p -r 120 -s:v 1920x1080 -i Beauty_1920x1080_120fps_420_8bit_YUV.yuv -c:v hevc blahbeauty.mp4
Clone this wiki locally