4/15/2020 FFmpeg Encoding and Editing Course
FFMPEG ENCODING AND
EDITING COURSE
Werner Robitza
June 04, 2018
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 1/56
4/15/2020 FFmpeg Encoding and Editing Course
ABOUT ME
Video quality and Quality of Experience researcher
PhD student and research assistant at Technische
Universität Ilmenau
Contact:
[email protected]
http://slhck.info
@slhck
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 2/56
4/15/2020 FFmpeg Encoding and Editing Course
GOALS
This course should cover:
Basic concepts
Installing ffmpeg and tools
Encoding videos
Appling filters
Analyzing videos
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 3/56
4/15/2020 FFmpeg Encoding and Editing Course
REQUIREMENTS
These slides
ffmpeg, ffprobe and ffplay installed (it will be
explained)
Some sample videos, example: Big Buck Bunny
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 4/56
4/15/2020 FFmpeg Encoding and Editing Course
RESOURCES
If you need sample videos for testing, see overview
from VQEG
(Video Quality Experts Group):
https://www.its.bldrdoc.gov/vqeg/video-datasets-and-
organizations.aspx
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 5/56
4/15/2020 FFmpeg Encoding and Editing Course
INTRODUCTION TO FFMPEG
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 6/56
4/15/2020 FFmpeg Encoding and Editing Course
ABOUT THE PROJECT
Free, open-source software for multimedia editing,
conversion, …
Started in 2000
Continuous development until now
Similar or related (and useful) frameworks:
ImageMagick
MLT Framework
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 7/56
4/15/2020 FFmpeg Encoding and Editing Course
TOOLS
FFmpeg contains:
Command-line tools: ffmpeg, ffprobe, ffplay
Libraries: libavformat, libavcodec,
libavfilter, …
Libraries are used in many projects (VLC, MLT
Framework, …) and can be used from C/C++ code.
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 8/56
4/15/2020 FFmpeg Encoding and Editing Course
(libav*))
ABOUT THE LIBRARIES (libav*
libavformat: Reads and writes container formats
(AVI, MKV, MP4, …)
libavcodec: Reads and writes codecs (H.264,
H.265, VP9, …)
libavfilter: Various filters for video and audio
... and many more
Examples on how to programmatically use libraries:
http://leixiaohua1020.github.io/#ffmpeg-
development-examples
Further (partly non-FFmpeg) libraries that you may find
useful:
OpenCV: more signal processing oriented
Python: MoviePy, pyav, scikit-video
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 9/56
4/15/2020 FFmpeg Encoding and Editing Course
ARCHITECTURE
Simplfied overall architecture:
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 10/56
4/15/2020 FFmpeg Encoding and Editing Course
INSTALLATION / COMPILATION
Installation Pro Con
Method
Building from Offers all Takes time, harder
source options, to update
tools,
codecs
Downloading Easy and Does not offer all
static build fast encoders, manual
update necessary
Installing from Easy and Does not always
package manager fast offer latest version
(e.g., apt-get) or all encoders
Get source code and static builds from:
http://ffmpeg.org/download.html
Building on Windows: https://github.com/jb-
alvarado/media-autobuild_suite
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 11/56
4/15/2020 FFmpeg Encoding and Editing Course
GETTING HELP
Places to get help:
📖 Documentation: https://ffmpeg.org/ffmpeg-
📖 Wiki: http://trac.ffmpeg.org/wiki
all.html
📖 IRC: #ffmpeg
✉ Mailing list:
https://lists.ffmpeg.org/mailman/listinfo/ffmpeg-
user/
🌐 Stack Overflow: https://stackoverflow.com/ and
use #ffmpeg
🌐 Super User: http://superuser.com/ and use
#ffmpeg
… or ask me
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 12/56
4/15/2020 FFmpeg Encoding and Editing Course
GENERAL VIDEO ENCODING
CONCEPTS
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 13/56
4/15/2020 FFmpeg Encoding and Editing Course
CONTAINER FORMATS
Containers contain media data. Typical examples:
MP4: MPEG-4 Part 14 container for H.264, H.264,
AAC audio, …
MKV: Versatile container for any media format
WebM: Subset of MKV, usage in Web streaming
AVI: Legacy container
See supported containers with:
$ ffmpeg -formats
File formats:
D. = Demuxing supported
.E = Muxing supported
--
D 3dostr 3DO STR
E 3g2 3GP2 (3GPP2 file format)
E 3gp 3GP (3GPP file format)
D 4xm 4X Technologies
E a64 a64 - video for Commodore 64
D aa Audible AA format files
...
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 14/56
4/15/2020 FFmpeg Encoding and Editing Course
CODECS
CODEC = Coder / Decoder
Specification on how to code and decode video,
audio, …
Usually not a specification on how to encode /
compress data
Sometimes “codec” == actual encoding/decoding
software
See supported codecs with:
$ ffmpeg -codecs
Codecs:
D..... = Decoding supported
.E.... = Encoding supported
..V... = Video codec
..A... = Audio codec
..S... = Subtitle codec
...I.. = Intra frame-only codec
....L. = Lossy compression
.....S = Lossless compression
-------
D.VI.. 012v Uncompressed 4:2:2
D.V.L. 4xm 4X Movie
D.VI.S 8bps QuickTime 8BPS vid
.EVIL. a64_multi Multicolor charset
.EVIL. a64_multi5 Multicolor charset
D.V..S aasc Autodesk RLE
D.VIL. aic Apple Intermediate
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 15/56
4/15/2020 FFmpeg Encoding and Editing Course
MOST IMPORTANT (LOSSY) CODECS
Currently mostly used, standardized by ITU/ISO:
🎥 H.262 / MPEG-2 Part H: Broadcasting, TV, used
🎥 H.264 / MPEG-4 Part 10: The de-facto standard
for backwards compatibility
🎥 H.265 / HEVC / MPEG-H: Successor of H.264,
for video encoding today
up to 50% better quality
🔊 MP3 / MPEG-2 Audio Layer III: Used to be the
de-facto audio coding standard
🔊 AAC / ISO/IEC 14496-3:2009: Advanced Audio
Coding standard
Competitors that are royalty-free:
🎥 VP8: Free, open-source codec from Google (not
🎥 VP9: Successor to VP8, almost as good as H.265
so much in use anymore)
🎥 AV1: A successor to VP9, claims to be better than
H.265
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 16/56
4/15/2020 FFmpeg Encoding and Editing Course
MOST IMPORTANT LOSSLESS
CODECS
Lossless codecs are useful for archival, editing, ...
Lossless = no compression artifacts at lower file size
🎥 Raw YUV, HuffYUV, FFV1, ffvhuff …
🔊 Raw PCM, FLAC, ALAC, …
Also, "visually lossless" codecs exist:
🎥 Apple ProRes, Avid DNxHD, JPEG2000, high-
quality H.264/H.265, ...
High bitrate and usually only I-frames
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 17/56
4/15/2020 FFmpeg Encoding and Editing Course
ENCODERS
Encoders are the actual software that outputs a codec-
compliant bitstream
Encoders can vary in quality and performance, some
are better than others (and some are free, some are
not)
Examples:
🎥 libx264: most popular free and open-source H.264
🎥 NVENC: NVIDIA GPU-based H.264 encoder
encoder
🎥 libx265: free and open-source HEVC encoder
🎥 libvpx: VP8 and VP9 encoder from Google
🎥 libaom: AV1 encoder
🔊 libfdk-aac: AAC encoder
🔊 aac: native FFmpeg AAC encoder
…
→ lots of competition
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 18/56
4/15/2020 FFmpeg Encoding and Editing Course
ENCODERS SUPPORTED IN FFMPEG
$ ffmpeg -encoders
Encoders:
V..... = Video
A..... = Audio
S..... = Subtitle
.F.... = Frame-level multithreading
..S... = Slice-level multithreading
...X.. = Codec is experimental
....B. = Supports draw_horiz_band
.....D = Supports direct rendering method 1
------
V..... a64multi Multicolor charset f
V..... a64multi5 Multicolor charset f
V..... alias_pix Alias/Wavefront PIX
...
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 19/56
4/15/2020 FFmpeg Encoding and Editing Course
PIXEL FORMATS
Representation of raw pixels in video streams
Specifies order of luma/color components and
chroma subsampling
Image Source: Wikipedia
Supported pixel formats: ffmpeg -pix_fmts
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 20/56
4/15/2020 FFmpeg Encoding and Editing Course
ENCODING WITH THE ffmpeg
COMMAND LINE TOOL
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 21/56
4/15/2020 FFmpeg Encoding and Editing Course
GENERAL SYNTAX
ffmpeg <global-options> <input-options> -i <input
Global options for log output, file overwriting, ...
Input options for reading files
Output options for:
conversion (codec, quality, ...)
filtering
stream mapping
…
Full help: ffmpeg -h full or man ffmpeg – but it's
huge!
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 22/56
4/15/2020 FFmpeg Encoding and Editing Course
TRANSCODING AND TRANSMUXING
Transcoding from one codec to another (e.g. H.264
using libx264):
ffmpeg -i <input> -c:v libx264 output.mp4
Transmuxing from one container/format to another –
without re-encoding:
ffmpeg -i input.mp4 -c copy output.mkv
ffmpeg will take one video, audio, and subtitle stream
from the input and map it to the output.
Explanation:
-c sets the encoder (see ffmpeg -encoders)
-c copy only copies bitstream
-c:v sets only video encoders
-c:a sets only audio encoders
-an and -vn would disable audio or video streams
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 23/56
4/15/2020 FFmpeg Encoding and Editing Course
TRANSCODING BACKGROUND
From http://ffmpeg.org/ffmpeg-all.html:
ffmpeg […] read[s] input files and get
packets containing encoded data from
them. When there are multiple input
files, ffmpeg tries to keep them
synchronized […].
Encoded packets are then passed to the
decoder. […] The decoder produces
uncompressed frames […] which can
be processed further by filtering […].
After filtering, the frames are passed to
the encoder, which encodes them and
outputs encoded packets. Finally those
are passed to the muxer, which writes
the encoded packets to the output file.
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 24/56
4/15/2020 FFmpeg Encoding and Editing Course
SEEKING AND CUTTING
Cut a video from timestamp <start> for <duration>,
or until <end>:
ffmpeg -ss <start> -i <input> -t <duration> -c co
ffmpeg -ss <start> -i <input> -to <end> -c copy <
Examples:
ffmpeg -ss 00:01:50 -i <input> -t 10.5 -c copy <o
ffmpeg -ss 2.5 -i <input> -to 10 -c copy <output>
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 25/56
4/15/2020 FFmpeg Encoding and Editing Course
NOTES ABOUT SEEKING
When re-encoding video, seeking is always accurate
to the timestamp
When copying bitstreams (-c copy), ffmpeg may
copy frames that are not shown but necessary to
include
Cutting with -c copy may yield video that starts
with black frames (on unsupported players)
Also see:
http://trac.ffmpeg.org/wiki/Seeking
https://superuser.com/questions/138331/using-
ffmpeg-to-cut-up-video
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 26/56
4/15/2020 FFmpeg Encoding and Editing Course
SETTING QUALITY
The output quality depends on encoder defaults and
the source material
Do not just encode without setting any quality level!
Generally: You need to choose a target bitrate or
quality level
Target bitrate depends on the video genre, size and
framerate
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 27/56
4/15/2020 FFmpeg Encoding and Editing Course
OPTIONS FOR SETTING QUALITY
Possible options (just examples):
-b:v or -b:a to set bitrate
e.g., -b:v 1000K = 1000 kbit/s, -b:v 8M = 8
Mbit/s
-q:v or -q:a to set fixed-quality parameter
e.g., -q:a 2 for native AAC encoder
Examples of encoder-specific options:
-crf to set Constant Rate Factor for
libx264/libx265
-vbr to set constant quality for FDK-AAC encoder
Many many more; see e.g. ffmpeg -h
encoder=libx264 for examples
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 28/56
4/15/2020 FFmpeg Encoding and Editing Course
WHAT IS CRF?
CRF = Constant Rate Factor
Maintain constant quality across the entire encode
Good for storing video at fixed quality if file size is
not important
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 29/56
4/15/2020 FFmpeg Encoding and Editing Course
EXAMPLE: TRANSCODING TO H.264,
PT. 1
Constant quality (CRF) encoding:
ffmpeg -i <input> -c:v libx264 -crf 23 -c:a aac
For H.264, CRF between 18 and 28 looks "good", lower
is better. (Different CRF for HEVC and VP9.)
EXAMPLE: TRANSCODING TO H.264,
PT. 2
Two-pass encoding:
ffmpeg -y -i <input> -c:v libx264 -b:v 8M -pass 1
ffmpeg -i <input> -c:v libx264 -b:v 8M -pass 2 -c
(Windows: Use NUL instead of /dev/null)
See https://trac.ffmpeg.org/wiki/Encode/H.264
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 30/56
4/15/2020 FFmpeg Encoding and Editing Course
RATE CONTROL
Different kinds of rate control:
Constant Bitrate (CBR)
Variable Bitrate (VBR)
Average bitrate (ABR)
Constant quantization parameter (CQP)
Constant quality, based on psychovisual
properties, e.g. CRF in x264/x265/libvpx-vp9
Constrained bitrate (VBV)
Which rate control to use for which case? More info:
https://slhck.info/video/2017/03/01/rate-control.html
Important: Rate depends on content characteristics!
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 31/56
4/15/2020 FFmpeg Encoding and Editing Course
RATE CONTROL EXAMPLES
Frame sizes over time (smoothed) for different rate
control modes
Observe wrong estimation of bitrate at the beginning
for ABR
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 32/56
4/15/2020 FFmpeg Encoding and Editing Course
SPEED VS. QUALITY VS. FILE SIZE
(Lossy) encoding is always a trade-off between:
For example:
You can have fast, high-quality encoding, but the file
will be large
You can have high-quality, smaller file size, but the
encoding will take longer
You can have small files with fast encoding, but the
quality will be bad
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 33/56
4/15/2020 FFmpeg Encoding and Editing Course
SPEED/QUALITY PRESETS IN X264
Choose the encoding speed for libx264 with the preset
option:
ffmpeg -i <input> -c:v libx264 -crf 23 -preset ul
ffmpeg -i <input> -c:v libx264 -crf 23 -preset me
ffmpeg -i <input> -c:v libx264 -crf 23 -preset ve
All presets: ultrafast, superfast, veryfast,
faster, fast, medium, slow, slower, veryslow
Example results (all have the same quality!):
Preset Encoding Time File Size
ultrafast 4.85s 15M
medium 24.13s 5.2M
veryslow 112.23s 4.9M
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 34/56
4/15/2020 FFmpeg Encoding and Editing Course
CHANGING FRAMERATE
Simple way to change the framerate by dropping or
duplicating frames:
ffmpeg -i <input> -r 24 <output>
More complex ways involve filtering, see fps,
mpdecimate, minterpolate filters:
ffmpeg -i <input> -filter:v fps=24 <output>
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 35/56
4/15/2020 FFmpeg Encoding and Editing Course
STREAM MAPPING
Each file and its streams have a unique ID, starting with
0.
Examples:
0:0 is the first stream of the first input file
0:1 is the second stream of the first input file
2:a:0 is the first audio stream of the third input file
…
You can map input streams to output, e.g. to add audio
to a video:
ffmpeg -i input.mp4 -i input.m4a -c copy -map 0:v
See: http://trac.ffmpeg.org/wiki/Map
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 36/56
4/15/2020 FFmpeg Encoding and Editing Course
SIMPLE FILTERING
ffmpeg has lots of video, audio, subtitle filters:
ffmpeg -i <input> -filter:v "<filter1>,<filter2>
A <filter> has a name and several options, and some
pre-defined variables:
-filter:v <name>=<option1>=<value1>:<option2>=<v
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 37/56
4/15/2020 FFmpeg Encoding and Editing Course
SCALING
Scale to 320×240:
ffmpeg -i <input> -vf "scale=w=320:h=240" <output
Scale to a height of 240 and keep aspect ratio divisible
by 2:
ffmpeg -i <input> -vf scale=w=-2:h=240 <output>
Scale to 1280×720 or smaller if needed:
ffmpeg -i <input> -vf "scale=1280:720:force_origi
More tips:
http://trac.ffmpeg.org/wiki/Scaling%20(resizing)%20
https://superuser.com/questions/547296/
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 38/56
4/15/2020 FFmpeg Encoding and Editing Course
PADDING
Add black borders to a file, e.g. 1920×800 input to
1920×1080:
ffmpeg -i <input> -vf "pad=1920:1080:(ow-iw)/2:(o
Note that:
You can use mathematical expressions
ow and oh are output width and height
iw and ih are input width and height
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 39/56
4/15/2020 FFmpeg Encoding and Editing Course
FADING
Simple fade-in and fade-out at a specific time for a
specific duration.
ffmpeg -i <input> -filter:v \
"fade=t=in:st=0:d=5,fade=t=out:st=30:d=5" \
<output>
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 40/56
4/15/2020 FFmpeg Encoding and Editing Course
DRAWING TEXT
Complex system for printing text on video:
ffmpeg -i <input> -vf \
drawtext="text='Test Text':x=100:y=50:\
fontsize=24:fontcolor=yellow:box=1:boxcolor=red"
<output>
Various options related to font family, size, position,
color, …
Text expansion (burn in frame number or timecode)
See: http://ffmpeg.org/ffmpeg-all.html#drawtext-1
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 41/56
4/15/2020 FFmpeg Encoding and Editing Course
COMPLEX FILTERING
Complex filters have more than one in- and/or output:
ffmpeg -i <input1> -i <input2> -filter_complex \
"[0:v:0][1:v:0]overlay[outv]" \
-map "[outv]" <output>
Steps:
Specify inputs to filterchain (e.g. [0:v:0][1:v:0])
Specify filters in the chain (e.g. overlay)
Specify output labels of chain (e.g. [outv])
Map output labels to final output file
You can have multiple filterchains with ;
See: http://ffmpeg.org/ffmpeg-all.html#Filtergraph-
syntax-1
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 42/56
4/15/2020 FFmpeg Encoding and Editing Course
CONCATENATING STREAMS
Decode three video/audio streams and append to one
another:
ffmpeg -i <input1> -i <input2> -i <input3> -filte
"[0:0][0:1][1:0][1:1][2:0][2:1]concat=n=3:v=1
-map "[outv]" -map "[outa]" <output>
See: http://trac.ffmpeg.org/wiki/Concatenate (also for
other methods)
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 43/56
4/15/2020 FFmpeg Encoding and Editing Course
TIMELINE EDITING
Enable filters only at a specific point in time.
Example:
Show a watermark in the top left corner
Between seconds 1 and 2 only
ffmpeg -i <video> -i <watermark> -filter_complex
"[0:v][1:v]overlay=10:10:enable='between(t,1
-map "[outv]" <output>
See: http://ffmpeg.org/ffmpeg-all.html#Timeline-
editing
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 44/56
4/15/2020 FFmpeg Encoding and Editing Course
CALCULATING SIMPLE QUALITY
METRICS
PSNR (Peak Signal To Noise Ratio):
$ ffmpeg -i <degraded> -i <reference> -filter_com
[Parsed_psnr_0 @ 0x7fdb187045c0] PSNR y:33.437789
SSIM (Structural Similarity):
$ ffmpeg -i <degraded> -i <reference> -filter_com
[Parsed_ssim_0 @ 0x7fbf0500b660] SSIM Y:0.925477
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 45/56
4/15/2020 FFmpeg Encoding and Editing Course
MANY OTHER FILTERS
Examples:
Scene change detection using the select filter
Removing watermarks (delogo)
Blurring, edge detection and convolution filters
Video stabilization
Vectorscopes, histograms and other information
Chroma and alpha keying
Subtitle editing
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 46/56
4/15/2020 FFmpeg Encoding and Editing Course
GETTING MEDIA INFORMATION
WITH ffprobe
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 47/56
4/15/2020 FFmpeg Encoding and Editing Course
GENERAL CONCEPTS
ffprobe <input>
[-select_streams <selection>]
[-show_streams|-show_format|-show_frames|-sho
[-show_entries <entries>]
[-of <output-format>]
Explanation:
select_streams for specificing only video or
audio, for example
show_ for selecting which information to show
show_entries for selecting fewer entries to show
of to set output format
See:
https://ffmpeg.org/ffprobe.html
http://trac.ffmpeg.org/wiki/FFprobeTips
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 48/56
4/15/2020 FFmpeg Encoding and Editing Course
PRACTICAL ffprobe EXAMPLES PT. 1
Show all available streams:
ffprobe <input> -show_streams
Show info on video stream:
ffprobe <input> -select_streams v -show_format
Show presentation timestamp and frame type of every
frame, in CSV format (p=0 disables CSV section
headers)
ffprobe <input> -select_streams v -show_frames \
-show_entries frame=pkt_pts_time,pict_type -of cs
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 49/56
4/15/2020 FFmpeg Encoding and Editing Course
PRACTICAL ffprobe EXAMPLES PT. 2
Change output to JSON format for parsing:
ffprobe <input> -select_streams v -show_packets
Get the number of streams in a file (nk=1 disables
keys):
ffprobe <input> -show_format -show_entries format
Get the duration in seconds or HH:MM:SS.ms:
ffprobe <input> -show_format -show_entries format
ffprobe -sexagesimal <input> -show_format -show_e
Get bitrate of audio stream in Bit/s:
ffprobe <input> -select_streams a -show_entries s
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 50/56
4/15/2020 FFmpeg Encoding and Editing Course
INSPECTING VIDEO CODECS
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 51/56
4/15/2020 FFmpeg Encoding and Editing Course
DEBUGGING MOTION VECTORS
Simple way to visualize motion in FFmpeg with H.264
codecs (does not work for other codecs):
ffplay -flags2 +export_mvs input.mp4 -vf codecvie
ffmpeg -flags2 +export_mvs -i input.mp4 -vf codec
pf – forward predicted motion vectors of P pictures
bf – forward predicted motion vectors of B pictures
bb – backward predicted motion vectors of B pictures
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 52/56
4/15/2020 FFmpeg Encoding and Editing Course
DEBUGGING MOTION VECTORS
More info:
http://trac.ffmpeg.org/wiki/Debug/MacroblocksAndMo
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 53/56
4/15/2020 FFmpeg Encoding and Editing Course
VIDEO STREAM ANALYZERS
Different software for analyzing bitstreams graphically:
Elecard Stream Analyzer (commercial)
CodecVisa (commercial)
Intel Video Pro Analyzer (commercial)
AOMAnalyzer (free, AV1/VP9 video)
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 54/56
4/15/2020 FFmpeg Encoding and Editing Course
SUMMARY
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 55/56
4/15/2020 FFmpeg Encoding and Editing Course
SUMMARY
You should have learned how to:
Understand FFmpeg libraries, codecs, containers,
encoders, …
Encode video and audio
Apply basic filters
Read stream information and metadata
Find help if you get stuck
file:///home/amaranth/Desktop/ffmpeg-encoding-course-master/docs/index.html#/8 56/56