FFmpeg and Libav
Sep-2015
Dani Gutiérrez Porset
Associate Professor
Communications Engineering
Eman ta zabal zazu
2
2FFmpeg and Libav
Thanks, Licences and Tools
● Thanks to people and organizations who took and take
part in free software and free knowledge projects.
●
This presentation is licensed as CC BY-SA 3.0 ES
http://creativecommons.org/licenses/by-sa/3.0/es/
● Tools used to make this presentation: GNU/Linux, KDE,
Inkscape, Gimp, LibreOffice, Firefox, Chromium
● All images are taken from Wikimedia Foundation. Logos
and trademarks belong to respective organizations
3
3FFmpeg and Libav
Index
● What are FFmpeg and Libav? Uses
● FFmpeg or Libav
● Example of Commands and Libraries in Libav
● Files, Streams, Containers and Codecs
● Transcoding process
● Some supported formats and codecs
● Laws. “Extra” libraries in Debian and Ubuntu
● Supported protocols and devices
● Some uses
4
4FFmpeg and Libav
What are
FFmpeg and Libav?
● Tools and libraries
to convert, manipulate and stream
multimedia formats and protocols
● Written in C
● Multiplatform: GNU/Linux, Mac OS X, Ms
Windows,...
● License: GNU GPL or GNU LGPL
5
5FFmpeg and Libav
Uses
Net Services
Video/Audio Players
and Media centers
Video/Audio/3D
Editors
k3b
Other Software
VoIP
Browser
Graphic Libraries
Disk authoring
6
6FFmpeg and Libav
FFmpeg or Libav
● Libav (2011) = fork of FFmpeg (2000)
● Incompatible libraries (libavcodec)
● See each program to check wich one is using
https://en.wikipedia.org/wiki/Libav#Software_using_Libav_instead_of_FFmpeg
7
7FFmpeg and Libav
Example: Libav Commands and
Libraries in Ubuntu package
avconv avprobe
libavdevice
libavcodec
libavfilter
libavformat
libavutil
libpostproc
libswscale
avplay avserver
Video postprocessing
Video software scaling
Commands provided for compatibility: ffmpeg, ffplay, ffprobe, ffserver
Commands
(console)
Libraries
Shared utilities
Codecs+ Highly optimized implementations
of DCT, color space conversion,...
Mux/ Demux
SDL
8
8FFmpeg and Libav
Files, Streams,
Containers and Codecs
● Each stream type is encoded according to a codec
● Allowed number, type and codification of streams depends on file format
(container)
● Some files can contain streams that don't begin at start
e.g. subtitles in some VOB files
● Some codecs only allow a small number of fixed frame rates
e.g. MPEG-1/2
● Libav supports:
– Some containers only for mux, only for demux, or for both
– Some codecs only for codec, only for decodec, or for both
9
9FFmpeg and Libav
Files, Streams,
Containers and Codecs
● A file can be: Regular file, Pipe, Network stream, Device
● A file has distinct multiplexed streams, each stream of 5
possible types:
10
10FFmpeg and Libav
Files, Streams,
Containers and Codecs
● Each stream type is encoded according to a codec
● Allowed number, type and codification of streams depends on file format
(container)
● Some files can contain streams that don't begin at start
e.g. subtitles in some VOB files
● Some codecs only allow a small number of fixed frame rates
e.g. MPEG-1/2
● Libav supports:
– Some containers only for mux, only for demux, or for both
– Some codecs only for codec, only for decodec, or for both
11
11FFmpeg and Libav
Transcoding process
12
12FFmpeg and Libav
Some supported
Formats and Codecs
13
13FFmpeg and Libav
Laws
● Some codecs are patented
● Are there software patents? Yes in USA, not in
UE,...
● And if the codecs' terms forbid reverse
engineering? Allowed in some countries for
interoperability
14
14FFmpeg and Libav
Example: “Extra” Libav libraries
in Debian and Ubuntu
● Unrestricted functionality related to patents, e.g. libavcodec-extra-53:
– OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band (Encoder/Decoder)
– OpenCORE Adaptive Multi-Rate (AMR) Wide-Band (Decoder)
– Android VisualOn AAC (Encoder)
– Android VisualOn Adaptive Multi-Rate (AMR) Wide-Band (Encoder)
– OpenCV filtering
– Dirac decoding support via libdirac
– MP3 encoding with liblame
– H.264 encoding via libx264
– MPEG4 Part 2 encoding via libxvidcore
– JPEG 2000 format managing
15
15FFmpeg and Libav
Supported protocols
Protocol Input Output
file, pipe X X
tcp, udp X X
tls X X
http, httpproxy,
https
X X
rtmp, rtp X X
applehttp
concat
crypto
mmsh, mmst
X
md5 X
gopher X X
16
16FFmpeg and Libav
Audio
Linux
Video
Linux
Others Supported devices
Input
ALSA OSSPulseaudio JACK
Video4Linux2
DV 1394
Framebuffer
BKTR
X11 grabbing
Input/Output
VfW capture
LIBCDIO
LIBDC1394
sndio
17
17FFmpeg and Libav
Some uses
● Video and audio grabbing
● Convert formats and codecs (audio, video, from images to
video and viceversa
● Mux, demux, copy, dump, delete streams
● Change bit rate and frame rate
● Filters:
– Without decoding: bitstream filters
– Decoding. Connected filters (sources, sinks,...)
18
18FFmpeg and Libav
Some uses of advanced filters
for audio
● Trim and split
● Mix in one or distinct channels
Example: convert 6 sources to 5.1
● Separate channels
● Change volume
● ...
19
19FFmpeg and Libav
Some uses of advanced filters
for video
● Geometric: crop, flip, scale, pad
● Time: overlay, split, trim
● Deinterlace
● Draw box or text, fade, negate,...
● ...

FFMPEG and LibAV

  • 1.
    FFmpeg and Libav Sep-2015 DaniGutiérrez Porset Associate Professor Communications Engineering Eman ta zabal zazu
  • 2.
    2 2FFmpeg and Libav Thanks,Licences and Tools ● Thanks to people and organizations who took and take part in free software and free knowledge projects. ● This presentation is licensed as CC BY-SA 3.0 ES http://creativecommons.org/licenses/by-sa/3.0/es/ ● Tools used to make this presentation: GNU/Linux, KDE, Inkscape, Gimp, LibreOffice, Firefox, Chromium ● All images are taken from Wikimedia Foundation. Logos and trademarks belong to respective organizations
  • 3.
    3 3FFmpeg and Libav Index ●What are FFmpeg and Libav? Uses ● FFmpeg or Libav ● Example of Commands and Libraries in Libav ● Files, Streams, Containers and Codecs ● Transcoding process ● Some supported formats and codecs ● Laws. “Extra” libraries in Debian and Ubuntu ● Supported protocols and devices ● Some uses
  • 4.
    4 4FFmpeg and Libav Whatare FFmpeg and Libav? ● Tools and libraries to convert, manipulate and stream multimedia formats and protocols ● Written in C ● Multiplatform: GNU/Linux, Mac OS X, Ms Windows,... ● License: GNU GPL or GNU LGPL
  • 5.
    5 5FFmpeg and Libav Uses NetServices Video/Audio Players and Media centers Video/Audio/3D Editors k3b Other Software VoIP Browser Graphic Libraries Disk authoring
  • 6.
    6 6FFmpeg and Libav FFmpegor Libav ● Libav (2011) = fork of FFmpeg (2000) ● Incompatible libraries (libavcodec) ● See each program to check wich one is using https://en.wikipedia.org/wiki/Libav#Software_using_Libav_instead_of_FFmpeg
  • 7.
    7 7FFmpeg and Libav Example:Libav Commands and Libraries in Ubuntu package avconv avprobe libavdevice libavcodec libavfilter libavformat libavutil libpostproc libswscale avplay avserver Video postprocessing Video software scaling Commands provided for compatibility: ffmpeg, ffplay, ffprobe, ffserver Commands (console) Libraries Shared utilities Codecs+ Highly optimized implementations of DCT, color space conversion,... Mux/ Demux SDL
  • 8.
    8 8FFmpeg and Libav Files,Streams, Containers and Codecs ● Each stream type is encoded according to a codec ● Allowed number, type and codification of streams depends on file format (container) ● Some files can contain streams that don't begin at start e.g. subtitles in some VOB files ● Some codecs only allow a small number of fixed frame rates e.g. MPEG-1/2 ● Libav supports: – Some containers only for mux, only for demux, or for both – Some codecs only for codec, only for decodec, or for both
  • 9.
    9 9FFmpeg and Libav Files,Streams, Containers and Codecs ● A file can be: Regular file, Pipe, Network stream, Device ● A file has distinct multiplexed streams, each stream of 5 possible types:
  • 10.
    10 10FFmpeg and Libav Files,Streams, Containers and Codecs ● Each stream type is encoded according to a codec ● Allowed number, type and codification of streams depends on file format (container) ● Some files can contain streams that don't begin at start e.g. subtitles in some VOB files ● Some codecs only allow a small number of fixed frame rates e.g. MPEG-1/2 ● Libav supports: – Some containers only for mux, only for demux, or for both – Some codecs only for codec, only for decodec, or for both
  • 11.
  • 12.
    12 12FFmpeg and Libav Somesupported Formats and Codecs
  • 13.
    13 13FFmpeg and Libav Laws ●Some codecs are patented ● Are there software patents? Yes in USA, not in UE,... ● And if the codecs' terms forbid reverse engineering? Allowed in some countries for interoperability
  • 14.
    14 14FFmpeg and Libav Example:“Extra” Libav libraries in Debian and Ubuntu ● Unrestricted functionality related to patents, e.g. libavcodec-extra-53: – OpenCORE Adaptive Multi-Rate (AMR) Narrow-Band (Encoder/Decoder) – OpenCORE Adaptive Multi-Rate (AMR) Wide-Band (Decoder) – Android VisualOn AAC (Encoder) – Android VisualOn Adaptive Multi-Rate (AMR) Wide-Band (Encoder) – OpenCV filtering – Dirac decoding support via libdirac – MP3 encoding with liblame – H.264 encoding via libx264 – MPEG4 Part 2 encoding via libxvidcore – JPEG 2000 format managing
  • 15.
    15 15FFmpeg and Libav Supportedprotocols Protocol Input Output file, pipe X X tcp, udp X X tls X X http, httpproxy, https X X rtmp, rtp X X applehttp concat crypto mmsh, mmst X md5 X gopher X X
  • 16.
    16 16FFmpeg and Libav Audio Linux Video Linux OthersSupported devices Input ALSA OSSPulseaudio JACK Video4Linux2 DV 1394 Framebuffer BKTR X11 grabbing Input/Output VfW capture LIBCDIO LIBDC1394 sndio
  • 17.
    17 17FFmpeg and Libav Someuses ● Video and audio grabbing ● Convert formats and codecs (audio, video, from images to video and viceversa ● Mux, demux, copy, dump, delete streams ● Change bit rate and frame rate ● Filters: – Without decoding: bitstream filters – Decoding. Connected filters (sources, sinks,...)
  • 18.
    18 18FFmpeg and Libav Someuses of advanced filters for audio ● Trim and split ● Mix in one or distinct channels Example: convert 6 sources to 5.1 ● Separate channels ● Change volume ● ...
  • 19.
    19 19FFmpeg and Libav Someuses of advanced filters for video ● Geometric: crop, flip, scale, pad ● Time: overlay, split, trim ● Deinterlace ● Draw box or text, fade, negate,... ● ...