Formats AV
Seccions d'aquesta pàgina 19
- 01General
- 02Contenidors / Containers (MUX)
- 03Conversió / Conversion
- 04libav / ffmpeg compilation on Linux
- 05ffmpeg compilation on MSWindows
- 06x264 compilation
- 07x265 compilation
- 08GPAC
- 09VideoLAN
- 10OpenSVC
- 11SVC reference software (JSVM)
- 12Butterflow
- 13libdash
- 14Bento4
- 15LASeR reference software
- 16Subtítols / Subtitles
- 17Còdecs vídeo / Video codecs
- 18Còdecs àudio / Audio Codecs
- Streaming
- 19Còdecs d'imatges / Image codecs
01General#
- Open Media Commons (royalty-free open solutions for digital content)
- VLC features list
- Video on the Web
- FourCC
(wikipedia)
- Registered FOURCC Codes and WAVE Formats (Microsoft)
- Video type parameters (Whatwg wiki)
02Contenidors / Containers (MUX)#
| Container |
file ext | file (UNIX) | mime type |
owner | base | brand
('ftyp') |
video
codecs |
audio
codecs |
stream | usage |
|
|---|---|---|---|---|---|---|---|---|---|---|---|
| file |
transmission |
||||||||||
| 3GP | video/3gpp |
3GPP | ISO Base media file format (isobmff) (MPEG-4 part 12)(MP4reg) | 3g?? |
|
|
x | ||||
| MOV | .mov | ISO Media, Apple QuickTime movie | video/quicktime | Apple | qt |
x | x | x | |||
| MJ2 (Motion JPEG2000) | |||||||||||
| MP4 | .mp4 | ISO Media, MPEG v4 system | MPEG |
|
|
x | |||||
| DVB-FF |
.dvb |
video/vnd.dvb.file | DVB |
|
|||||||
| ASF | Microsoft | x | x | x | |||||||
| AVI | .avi | Microsoft | x | x | - | ||||||
| DivX | DivXNetworks | x | x | - | |||||||
| Flash Video | .flv | Macromedia Flash Video | video/x-flv | Adobe |
|
|
RTMP | ||||
| .f4v |
video/mp4 | ISO base media file |
|
|
|||||||
| Matroska
(wp) |
.mkv .mka .mks |
CoreCodec | MCF |
|
|
x | |||||
| MCF | BSD | x | x | x | |||||||
| MPEG PS | .mpg .mpeg .vob |
MPEG sequence, v2, program multiplex | MPEG |
|
|
? | |||||
| MPEG TS | .ts .trp |
MPEG transport stream data (TeX font metric data) |
MPEG |
|
x | ||||||
| BDAV MPEG
TS |
.m2ts |
MPEG |
|
||||||||
| MXF | .mxf | SMPTE | |||||||||
| OGG (RFC 3533) |
Xiph | |
|
x | |||||||
| OGM (RFC 3534) |
|
|
|||||||||
| RMVB | Real Networks | RealVideo | x | x | |||||||
| SVI (AVI) | .svi | Samsung | AVI | XVID 208x176 15fps HAS_INDEX IS_INTERLACED TRUST_CKTYPE |
mpga 2ch 44100Hz 128Kbps |
||||||
| VOB (MPEG PS) |
MPEG |
|
|
||||||||
| WEBM |
.webm |
video/webm audio/webm |
Google |
Matroska |
VP8 |
Vorbis |
|||||
| Container |
file ext | file (UNIX) | mime type |
owner | base | video
codecs |
audio
codecs |
stream | |||
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Comparison of container formats (Wikipedia)
- Container formats (MultimediaWiki)
- Detailed Features for different Media Container Formats (eInfochips)
- White paper: media container file formats (MP4/Quicktime structure)
- Video file formats
- Audio file formats
- Audio file format FAQ
-
purpose
package
info
anàlisi / analysis
extraction (demux)
remux
conversió / conversion
encryption
general
ffmpegffmpeg -iffprobe
ffplay -i esports_3.m2v -vf 'showinfo'
ffmpeg
libav avconv -iavprobe
mplayer midentify
mencoder
kaa.metadata mminfo
transcode
transcode
OpenCaster
pesinfo
esvideompeg2info
tspcrmeasure
[mpeg2video]vbv
esaudioinfo
ts2pes
pes2es
esvideompeg2pes
esaudio2pes
pesvideo2ts
pesaudio2ts
tscbrmuxer
MPEG-4 MPEG4IP mp4info mp4trackdumpmpeg_ps_extract
mpeg4ip
mp4fragmenter
bento4 mp4infomp4dump
x
GPAC MP4Box -infoMP4Box -disoMP4Box -h extract
MP4Box -raw 1 toto.mp4
MP4Box -add video.264 -add audio.aac toto.mp4
MP4Box -add toto1.mp4#video -add audio.aac toto.mp4
MP4Box
JSVM
BitStreamExtractorStatic
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Info
- gspot
- Mediainfo
urpmi libwxgtku2.8-devel
ffmpeg -i toto.tsanalyzeduration <microseconds>- default: 5000000 (5 seconds)
probesize <bytes>- default: 5000000 (~5MB)
- tbn, tbc, tbr (frame-rate)
- Meaning of ffmpeg output (tbc, tbn, tbr) [closed]
- OpenCV Reporting TBR instead of FPS when using capture.get(CV_CAP_PROP_FPS)
- ff_rfps_calculate
- 4.4 libavformat/utils.c
- 5.0 libavformat/demux.c (avformat.h)
-
ffprobe -show_streams
timebase from
units
stored in
set with tbn
time_base = 1/tbn
container
AVStream.time_base -video_track_timescale 25000 (will give "time_base": "1/25000") (*) (e.g. when generating a video to be used by concat demux) tbc
codec_time_base = 1/tbc
codec
images/s (doubled?)
AVCodecContext.time_base (usually not needed) -time_base 1/25 (will give "codec_time_base": "1/50") tbr
r_frame_rate = tbr
guessed
fields/s?
AVStream.r_frame_rate (ff_rfps_calculate)
fps avg_frame_rate = fps
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Exemples / Examples
Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 90k tbn, 50 tbc- video at 25 fps, with pts values evenly distributed. All OK.
Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 30 tbr, 90k tbn, 50 tbc- differences between fps and tbr may come from a video at 25 fps, with timestamps not evenly distributed, probably from a 30fps video that dropped 5 frames every second, whose pts values have not been recalculated. VLC may detect it as 30fps.
- ...
ffprobe toto.ts / avprobe toto.tsmidentify toto.mov(mplayer -identify) (Transcoding and tagging video)-
midentify "$file" | sed -e 's/^/export /' > /tmp/midentify.sh
. /tmp/midentify.sh
-
- hachoir-metadata
urpmi python-hachoir-metadata
- kaa.metadata
(mminfo)
urpmi python-kaa-metadatatitol=`mminfo $1$2 | awk -F": " '$1 ~ /title$/ {print $2}'`
- MPEG-4
- H.264
- bento4
(formerly MPEG4IP)
- anàlisi / analysis
mp4info toto.mp4
- MPEG4IP
(
urpmi libmp4v2-utils) (see bento4)mp4info toto.mp4/usr/bin/mp4art
/usr/bin/mp4chaps
/usr/bin/mp4extract
/usr/bin/mp4file
/usr/bin/mp4info
/usr/bin/mp4subtitle
/usr/bin/mp4tags
/usr/bin/mp4track
/usr/bin/mp4trackdump(mp4videoinfo toto.mp4)(h264_parse toto.h264)(mpeg2video_parse toto.m2v)
- GPAC
- anàlisi / analysis
- File
dumping
and information
MP4Box -info toto.mp4
- Darwin
(
urpmi darwinstreamingserver-utils)- QTFileInfo toto.mp4
- JSVM
(SVC)
jsvm/bin/BitStreamExtractorStatic toto.264
- AVInaptic
- Anàlisi
/ Analysis
- bento4
- info
mp4dump
- H.264
- MP4
- GPAC (MP4Box)
- isoviewer
- AtomicParsley
(sf)
src/Makefile.inCXXFLAGS+= -Wall -Wno-unused -fpermissive
autoautoconf && autoheader./configuremakesudo make install
- AtomBox Studio (commercial)
- Dumpster (Apple)
- GPAC
- Gstreamer
- avprobe (libav)
- Usage
- format
avprobe -v 0 -show_format toto.mp4- only duration inside [format]:
avprobe -v 0 -show_format_entry duration toto.mp4
- streams
avprobe -v 0 -show_streams toto.mp4
- packets
avprobe -v 0 -show_packets toto.mp4
- format
- Usage
- ffplay
- ffprobe (
ffmpeg)- Usage
-show_entries(separated by ":")-
-show_entries
optional filter (frame=...,...,...:packet=...,...)
format
- bit_rate
- duration
- filename
- format_name
- nb_streams
- nb_programs
- probe_score
- size
- start_time
stream
- index
- codec_name
- codec_long_name
- profile
- codec_type
- codec_time_base
- codec_tag_string
- codec_tag
- video
- width=1280
height=720
coded_width=1280
coded_height=720
has_b_frames=0
sample_aspect_ratio=N/A
display_aspect_ratio=N/A
pix_fmt=yuv420p
level=41
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=60/1
avg_frame_rate=6312950/218257
time_base=1/16000
start_pts=0
start_time=0.000000
duration_ts=69842240
duration=4365.140000
bit_rate=2490311
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=126259
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:language=und
TAG:handler_name=VideoHandler
- width=1280
- audio
- sample_fmt=fltp
sample_rate=44100
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=0
start_time=0.000000
duration_ts=192504806
duration=4365.188345
bit_rate=125588
max_bit_rate=125588
bits_per_raw_sample=N/A
nb_frames=187993
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=1
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
TAG:language=und
TAG:handler_name=SoundHandler
- sample_fmt=fltp
packet
- codec_type
- stream_index
- pts
- pts_time
- dts
- dts_time
- duration
- duration_time
- convergence_duration
- convergence_duration_time
- size
- pos
- flags
frame
- media_type
- stream_index
- key_frame
- pkt_pts
- pkt_pts_time
- pkt_dts
- pkt_dts_time
- best_effort_timestamp
- best_effort_timestamp_time
- pkt_duration
- pkt_duration_time
- pkt_pos
- pkt_size
- width
- height
- pix_fmt
- sample_aspect_ratio
- pict_type
- coded_picture_number
- display_picture_number
- interlaced_frame
- top_field_first
- repeat_pict
- color_range
- color_space
- color_primaries
- color_transfer
- chroma_location
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Exemples / Examples
- time, type, size
ffprobe -v 0 -show_entries frame=pkt_dts_time,pict_type,pkt_size -print_format compact=nk=1:p=0:s='\ ' -select_streams v:0 sintel.mkv
- mixed (frame and stream)
ffprobe -v 0 -show_entries format=bit_rate,filename:stream=codec_type,index toto.mov
- frame information:
ffprobe-v 0-show_entries frame=coded_picture_number,pict_type,pkt_size -select_streams 0:8 794.ts
- pts and image type:
ffprobe -show_entries frame=pkt_pts_time,pict_type -print_format compact=nk=1:p=0:s='\ ' -select_streams v:0 -i toto.mp4 >data_pts_type.dat- get only information about I-type
images:
- grep
I
data_pts_type.dat >data_pts_i.dat
- grep
I
- gnuplot
distance between two consecutive
I-frames:
- i_distance.plot
- delta_v(x)
= ( vD = x - old_v, old_v = x,
vD)
old_v = 0
set title "Delta time between consecutive I frames"
set boxwidth 1
set style fill solid 1.0
set style data boxes
plot 'data_pts_i.dat' using 1:(delta_v($1)) title 'Delta'
- delta_v(x)
= ( vD = x - old_v, old_v = x,
vD)
- gnuplot -p i_distance.plot
- i_distance.plot
- time, type, size
-
- deprecated (use
-show_entriesinstead)-show_formatffprobe-v 0-show_format -print_format compact=item_sep=*:nokey=1 794.tsffprobe-v 0-show_format -print_format json=compact=1 794.ts
-show_streamsffprobe-v 0-show_streams -print_format xml -pretty 794.ts > /tmp/794_streams.xmlffprobe -v 0 -show_streams -print_format flat=s=_ 794.ts
-show_framesffprobe-v 0-show_frames -print_format xml-select_streams v:0794.ts > /tmp/794_frames.xml
-print_format- print compact format
-print_formatcompact=item_sep=*:nokey=1ffprobe -v 0 -show_entries frame=coded_picture_number,pict_type -print_format compact -i "concat:v1_init_gpac.mp4|v1_0_gpac.m4s|v1_1_gpac.m4s"ffprobe -v 0 -show_entries packet=pts,dts -print_format compact -i "concat:v1_init_gpac.mp4|v1_0_gpac.m4s|v1_1_gpac.m4s"- without key names
ffprobe -show_entries frame=coded_picture_number,pict_type:packet=pts_time-print_format compact=nk=1-select_streams v:0 toto.mp4
- print fields from frame and from packet:
ffprobe -show_entries frame=coded_picture_number,pict_type:packet=pts_time-print_format compact-select_streams v:0 toto.mp4
- with no section (
p=0), no field keys (nk=1), space as a separator (s='\ '):-print_format compact=nk=1:p=0:s='\ '
- print json
-print_format json=compact=1
- print xml
-print_format xml
- print csv format
ffprobe -show_entries frame=coded_picture_number,pict_type:packet=pts_time-print_format csv-select_streams v:0 toto.mp4- with a different character separator (#)
ffprobe -show_entries frame=coded_picture_number,pict_type:packet=pts_time-print_format csv=s=#-select_streams v:0 toto.mp4
- without printing section
-print_format csv=p=0:s=#
- print compact format
- parse from json format
info_json=$(ffprobe -v 0 -print_format json -show_entries stream ${input_path})- video_stream=$(echo
"${info_json}" | jq '.streams[] |
select(.codec_type=="video")')
- width=$(echo "${video_stream}" | jq '.width')
- height=$(echo "${video_stream}" | jq '.height')
- pix_fmt=$(echo "${video_stream}" | jq -r '.pix_fmt')
- r_frame_rate=$(echo "${video_stream}" | jq -r '.r_frame_rate')
- audio_stream=$(echo
"${info_json}" | jq '.streams[] |
select(.codec_type=="audio")')
- sample_rate=$(echo "${audio_stream}" | jq -r '.sample_rate')
- channels=$(echo "${audio_stream}" | jq '.channels')
- video_stream=$(echo
"${info_json}" | jq '.streams[] |
select(.codec_type=="video")')
ect_streams v:0) frames- video profile
and level
ffprobe -show_streams -i toto.mp4profile=Baseline
...
level=31
...
- duration
duration=$(ffprobe -i $video_path -show_format -v quiet | sed -n 's/duration=//p')
# keep only numbers and decimal point (discard N/A):
duration=$(echo $duration | tr -d -c 0-9.)
- bit-rate extraction
bit_rate=$(ffprobe -v 0 -show_entries format=bit_rate toto.mp4 | sed -n 's/bit_rate=//p')
- bit-rate calculation
eval $(ffprobe -v 0 -show_entries format=duration,size -print_format flat=s=_ 794.ts) && echo $format_size*8/$format_duration | bc -l
- tags (xxxx)
Stream ... Video: h264 (High) (xxxx / xxxx_in_hex), ...- problem when cutting from srt copy
- Tips
- Passing options to ffprobe
- FFprobe scripting question
- HANDY
TIP: Using FFprobe for stream analysis (plots
with gnuplot)
(requires a recent
version of ffmpeg:
/usr/local/bin/ffprobe)- ffplot
- plot.txt
# GNUPLOT "plot.txt"
set title "Title"
set xlabel "frame #"
set ylabel "Bytes per frame"
#set yrange [0:120000]
#set ytics (120000, 110000, 100000, 90000, 80000, 70000, 60000, 50000, 40000, 30000, 20000, 10000)
#set xrange [-10:850]
set lmargin 12
set rmargin 2
set grid
set pointsize 2
set label 1 "I frames"
set label 1 at graph .85, .96 tc lt 1
set label 2 "P frames"
set label 2 at graph .85, .92 tc lt 2
set label 3 "B frames"
set label 3 at graph .85, .88 tc lt 3
plot 'column.dat' using 3:1:2 notitle with i lc rgb variable
/usr/local/bin/ffprobe -show_entries frame=coded_picture_number,pict_type,pkt_size -select_streams v:0 794.ts | grep 'size\|coded_picture_number\|pict_type' > raw.dat && paste -s -d '\t\t\n' raw.dat > fixed.dat && sed -e 's/coded_picture_number=//g' -e 's/pkt_size=//g' -e 's/pict_type=//g' -e 's/I/167116800/g' -e 's/P/65280/g' -e 's/B/255/g' fixed.dat > column.dat && gnuplot -p < plot.txt
- Usage
- bento4
- Entrellaçat / Interlaced
- Extracció / Extraction (demux)
- ffmpeg
- MPEG4IP
- mpeg_ps_extract
- ...
- libdvb
- ts2es
- ts2ps
- ...
- MKVToolnix (Matroska)
- CD audio ripping
- Portada / Album art cover
- How to Add Album Art Cover to Audio Files Using the Command Line
- Instal·lació
- flac
- Mageia
sudo dnf install flac- abcde
- Mageia
sudo dnf install abcde- glyr
- MusicBrainz Picard Picard (docs) (gui)
- embedded image
- instal·lació
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepoflatpak install flathub org.musicbrainz.Picard
execucióflatpak run org.musicbrainz.Picard
- Passos (When the CD is available)
- extracció de les pistes amb abcde i glyr /
ripping
- sense glyr
abcde -o flac- amb glyr (genera cover.jpeg en un fitxer a part; no cal si després feu servir Picard)
abcde -o flac -G- metadades i caràtula
flatpak run org.musicbrainz.Picard- heu de tenir els fitxers extrets del CD (per exemple amb abcde)
- plafons (visibles des de Veure)
file browser cluster pane album pane Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Tools > Lookup CD
- seleccioneu l'edició que teniu
- us posarà les pistes al plafó dret (album pane)
- Afegeix carpeta... / o bé arrossegueu la carpeta des del navegador (plafó esquerre) cap a la secció Unclustered (plafó central)
- arrossegueu la carpeta des del plafó central cap a l'àlbum al plafó dret
- comproveu que cada cançó està precedida d'un rectangle verd
- seleccioneu tots els fitxers (al plafó dret) i feu Desar.
- amb això tindreu la caràtula incrustada a cadascun dels fitxers
- comproveu-ho amb ffplay del fitxer; hauria d'aparèixer la caràtula
- Eines / Tools
- k3b
- abcde
- FLAC
abcde -o flac
- FLAC
- Portada / Album art cover
- extraction of ES (elementary streams):
- Extracció de pistes d'un DVD / Extract tracks
from dvd (*)
(*)
mkdir /media/dvd; mount /dev/dvd /media/dvd
tccat -i /dev/dvd -d 2 -T 6,-1,1 > fist.vobmplayer dvd://TITOL -dvd-device DISPOSIU_o_IMATGE.ISO -dumpstream -dumpfile dvd.vobmplayer dvd://1 -dvd-device /dev/dvd -dumpstream -dumpfile dvd.vobmplayer dvd://4 -dvd-device toto.iso -dumpstream -dumpfile dvd.vob
vlc dvd:RUTA_DVD@TIT --audio-track X --sub-track Y --sout "#standard{access=file,mux=ps,dst=FICH_SAL}"vlc dvd:/dev/dvd@4 --audio-track 1 --sub-track 1 --sout "#standard{access=file,mux=ps,dst=dvd.vob}"vlc dvd:casinoRoyale.iso@4 --audio-track 1 --sub-track 1 --sout "#standard{access=file,mux=ps,dst=dvd.vob}"
- Llistes / Playlists
-
HFR (Sony RX100 V)
video
container
720
1080
4K
codec depth subsampling
25p/30p
24p
25p
30p
50i/60i 50p/60p
100p/120p
24p
25p
30p
AVCHD
- 17 Mb/s (FH)
- 24 Mb/s (FX)
- 17 Mb/s (FH)
- 24 Mb/s (FX)
28 Mb/s (PS)
MP4
6Mb/s
16Mb/s
28Mb/s
XAVC
H.264 L5.2
8, 10, 12 bits
4:2:0, 4:2:2, 4:4:4
MXF
XAVC S HD
MP4
50 Mb/s
50 Mb/s
- 60 Mb/s
- 100 Mb/s
XAVC S 4K
- 60 Mb/s
- 100 Mb/s
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- AVCHD
(BluRay Disc, camcorders)
- BD-RE White Paper (pdf) (BluRay)
- AVCHD (wp)
- CPI: AVCHD clip information
- FLV
ffmpeg ... -f flv ...- Streaming (RTMP)
- Codecs
- Audio
- MP3: 44100 Hz, 48000 Hz
- AAC: 44100 Hz, 48000 Hz
- Video
- ...
- H.264
- Audio
- FLV/F4V
Technology Center (Adobe)
- Video file format specification (pdf): FLV, F4V
- Flash Video (Wikipedia)
- Video and Audio Streaming with Flash and Open Source Tools
- yamdi (Yet Another Metadata Injector for FLV)
- FLVTool2 (*)
- JW FLV Media Player
- Aspect ratio: flv does not allow anamorphic display
- YouTube
- Creating flash videos using ffmpeg
- One-stop Installation Guide for Create a Linux Server-side FLV conversion environment
- SVI
- Howto: Samsung YP-T10 MTP and the SVI video codec
- Awesome YP-P2 and Samsung's lies
- Converting AVI?s for the Samsung YP-P2 (Nautilus actions: right-click)
- Samsung svi video format? (ISFT)
- MXF
- YUV
- Conversió / Conversion
- Seqüències de mostra / Sample sequences
- Packed YUV formats (FourCC)
- YUV
Lab Reports (efg)
- UYVY (sample image in the zip file)
- YUV (wp)
- YCbCr
(wp)
-
original
gamma corrected
luma, chrominance
analogue
(continuous)
digital
(discrete)
R
R'
Y' = 0.229*R' + 0.587*G' + 0.114*B'
Y'
Y' = 219*Y' + 16 G
G'
B-Y'
Cb = (B-Y')/1.772
Cb = 224*(B-Y') + 128 B
B'
R-Y'
Cr = (R-Y')/1.402
Cr = 224*(R-Y') + 128 Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- SDI / ITU-R BT:656
- packaging: CbYCrY (UYVY)
- Luma (wp)
- Reproductors / Players
- Video Tools
- video:
- PYUV
(download)
mplayer -demuxer rawvideo -rawvideo w=720:h=576 -aspect 4:3 -fps 25 toto.yuvffplay -s 720x576 toto.yuv- yuvdump (MPEG4IP)
- How do I animate a digital YUV image sequence? (FAQ) (Image Magick
- PYUV
(download)
- single image:
- PYUV
(download)
- display a uyvy image:
- Resolution: SD576
- Color space: YCbCr
- Subsampling: 4:2:2
- Ordering: UYVY
- Interleaved
- if the image has a header (e.g. .422
files):
- Extra settings -> Header bytes: 32
- display a uyvy image:
- ffmpeg
ffplay -f rawvideo -pix_fmt uyvy422 -s 720x576 -aspect 4:3 -i toto.uyvy
- Image
Magick (formats)
display -colorspace YCbCr -size 720x576 -sampling-factor 4:2:2 [-interlace plane] UYVY:single_image.yuv- Using ImageMagick to convert a
4:2:2 YCrCb raw image to something viewable
convert -size 720x576 UYVY:toto.raw toto.png
- gnuplot
- full image:
- show Y':
set cbrange [16:235]
set palette gray
plot "toto.uyvy" binary array=(720,576) flipy format="%uchar%uchar" using 2 with image
- show Cb:
set cbrange [16:240]
plot "toto.uyvy" binary array=(360,576) flipy format="%uchar%uchar%uchar%uchar" using 1 with image
- show Cr:
set cbrange [16:240]
plot "toto.uyvy" binary array=(360,576) flipy format="%uchar%uchar%uchar%uchar" using 2 with image
- show Y':
- first line:
- three components:
gnuplot -p < grafica.plot- grafica.plot:
set terminal wxt size 640,240
set multiplot
unset key
set title "Y'"
set origin 0.0,0.0
set size 0.5,1
plot "toto.uyvy" binary array=720 flipy format="%*uchar%uchar" with steps
set title "Cb"
set origin 0.5,0.0
set size 0.25,1
plot "toto.uyvy" binary array=360 flipy format="%uchar%uchar%uchar%uchar" using 1 with steps
set title "Cr"
set origin 0.75,0.0
set size 0.25,1
plot "toto.uyvy" binary array=360 flipy format="%uchar%uchar%uchar%uchar" using 3 with steps
unset multiplot
- show Y':
plot "toto.uyvy" binary array=720 flipy format="%*uchar%uchar" with impulses
plot "toto.uyvy" binary array=720 flipy format="%uchar%uchar" using 2 with impulsesplot "toto.uyvy" binary array=720 flipy format="%uchar%uchar" using 2 with steps
- show Cb:
plot "toto.uyvy" binary array=360 flipy format="%uchar%*uchar%*uchar%*uchar" with steps
plot "toto.uyvy" binary array=360 flipy format="%uchar%uchar%uchar%uchar" using 1 with steps
- show Cr:
plot "toto.uyvy" binary array=360 flipy format="%*uchar%*uchar%uchar%*uchar" with steps
plot "toto.uyvy" binary array=360 flipy format="%uchar%uchar%uchar%uchar" using 3 with steps
- three components:
- full image:
- PYUV
(download)
- WebM Project
03Conversió / Conversion#
- Programari/software
- HOWTO Convert video files
- MTS
files (AVCHD: H.264 + AAC on
MPEG2-TS, from camera)
- Concatenació /
Concatenation
- cat (second step is necessary to avoid
discontinuities: "Continuity check failed for pid ...
expected ... got ...")
- cat 00650.MTS 00651.MTS 00652.MTS > temporal.mts
- avconv -i temporal.mts -c:v copy -c:a copy -f mpegts tots.mts
- avconv -i temporal.mts -c:v copy -c:a copy tots.mp4
- find
all files between two dates (2013-08-9 to 2013-08-11)
- cat $(find . -newermt 2013-08-9 ! -newermt 2013-08-12 -printf "%T@ %p\n" | sort -n | awk '{print $2}' | paste -s -d ' ') > 2013-08-09_11.mts
- avconv -i 2013-08-09_11.mts -c:a copy -c:v copy 2013-08-09_11.mp4
- melt
- libav: Concatenació / Concatenation
- ffmpeg: Concatenació / Concatenation
- aplicacions d'edició / gui edition applications
- Howtos
- Thread: tsMuxer and joining
m2ts files
- MPLS playlist
- Thread: How to merge multiple
.mts files (canon HF) into one single .mts file
- tsmuxer
- Thread: tsMuxer and joining
m2ts files
- cat (second step is necessary to avoid
discontinuities: "Continuity check failed for pid ...
expected ... got ...")
- DLNA
- Concatenació /
Concatenation
- Subtítols / Subtitles
- Subtitle manipulation tools for Linux
- [vdr]
How
to extract HD dvb subtitles (and possibly convert to srt)?
- vdrsubrip
uses:
- dependencies
- ProjectX to extract subtitles (urpmi projectx)
- BDSup2Sub
(doom9)
(digital-digest)
to convert to images
- svn --username anonymous co http://javaforge.com/svn/bdsup2sub/BDSup2Sub/ BDSup2Sub
- ImageMagick to improve images
- gocr for OCR
- usage:
- edit vdrsubrip:
- PROJX='/usr/share/java/ProjectX.jar'
- BDSUP2SUB='~/src/BDSup2Sub/BDSup2Sub.jar'
- edit vdrsubrip:
- dependencies
- vdrsubrip
uses:
- [linux-dvb]
how
to extract subtitles in text format?
- son2srt
- Extraction with transcode
- Extraction with ffmpeg
- Eines / Tools:
- rippers:
- KSubtitleRipper (gui)
- subtitleripper
(uses: transcode, gocr)
- compilation
- urpmi libnetpbm-devel libpng-devel
- compilation
- rippers:
- wget ...
- vobsub.c:
- rename getline to getlinia (or anything else)
- Makefile:
- INCLUDES := -I /usr/include/netpbm
- #LIBS += -lppm
LIBS += -lnetpbm
- make
- subtitle2pgm
- Gnome Subtitles
- KSubtile
- SubtitleEditor
- Gaupol
- GSubEdit
- Jubler
- sub2srt
- Subtitles
- compensate the display time in 3 seconds:
- subs -i -b 3 subtitle_file.sub
- 24fps -> 25 fps:
- subs -i -a 24/25 subtitle_file.sub
- time from file1 and text from file2:
- subs -z subtitle_file1.sub subtitle_file2.sub
- compensate the display time in 3 seconds:
- MPEG4IP
- Using MJPEG-tools
- TSDuck
- TSDuck is also a large library to manipulate MPEG transport streams. C++, Java and Python developers can use bindings in their languages.
- Using mencoder (mplayer)
- Using transcode (tccat,
tcextract):
- urpmi
- Subtitle
manipulation tools for Linux
- DVD -> /home/user/rip/vob
- tccat -i /home/user/rip/vob | tcextract -x ps1 -t vob -a 0x22 > subs-en
- other languages:
- to determine the sid for the preferred subtitles:
- mplayer -dvd-device /space/st-tng/disc1/ -dvd 1 -vo null -ao null -frames 0 -v 2>&1 | grep sid
- if you want language with sid 7, then add it to
0x20:
- tccat -i /home/user/rip/vob | tcextract -x ps1 -t vob -a 0x27 > subs-it
- to determine the sid for the preferred subtitles:
- convert them to images:
- subtitle2pgm -o english -c 255,0,255,255 < subs-en
- OCR:
- pgm2txt english
- create srt file:
- srttool -s -w < english.srtx > english.srt
- Estabilització / Stabilization
- libav
(fork from ffmpeg)
- Història / History
- Instal·lació / Installation
- Compilació
/ Compilation
- pipe
-
syntax
meaning
example
pipe:0
stdin
... | avconv -i pipe:0 ...
pipe:1
stdout
avconv ... pipe:1 | tee -a fitxer1 fitxer2
pipe:2
stderr
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- avconv -f video4linux2 -i /dev/video0 -s 320x240 -vcodec libx264 -f mpegts pipe:1 | avplay -i pipe:0
- avconv -i tvc_794_20140821_1709.ts -c copy -f mpegts - | avplay -i -
- mkfifo
- mkfifo toto.ts
- avconv -i ... -f mpegts - > toto.ts
- [avconv -i ... -f mpegts -y toto.ts]
- avplay toto.ts
- simultaneous
2 outputs to 2 fifos (does not work)
- mkfifo v1.ts v2.ts
- ffmpeg -i sintel-1280-surround.mp4 -c:v libx264 -b:v 500k -s 640x360 -aspect 16:9 -an -f mpegts -y v1.ts -c:v libx264 -b:v 1500k -s 1280x720 -aspect 16:9 -f mpegts -y v2.ts
- other examples
-
- General
- Filtres / Filters
- ffmpeg filters
- Info about input (only available when specifying an
output)
- avconv -i input -filter:v showinfo output
- Tall / Cut (5s)
- avconv -threads auto -i toto.MTS -t 0:00:05.0 -c:v copy -c:a copy -f mpegts toto_5s.MTS
- Concatenació /
Concatenation
- see also
- How can I join video files? (mkfifo)
- MTS files:
- avplay -i "concat:00185.MTS|00186.MTS|00187.MTS"
- MPEG-DASH
segments:
- avplay -i "concat:segment_init.mp4|segment_1.m4s|segment_2.m4s"
- Entrellaçat / Interlaced
- ffmpeg
- Interlaced video looks very bad when encoded with avconv, what is wrong?
- -flags +ilme+ildct
- -flags +alt?
- -top 0/1
- deinterlace
- -filter:v yadif
- Rotació i rescalatge /
Rotation and rescale
- avconv -threads auto -i toto.mts -filter:v transpose=clock toto_clock.mp4
- resize and then rotation:
- resize, rotation and pad:
- avconv -threads auto -i 00189_5s.MTS -filter:v "scale=w=576:h=-1,transpose=clock,pad=width=720:height=576:x=(ow-iw)/2:y=0:color=black" -f mpegts 00189_5s_clock.MTS
- avconv -threads auto -i 00189_5s.MTS -filter:v "scale=w=576:h=-1,transpose=clock,pad=width=720:height=576:x=(ow-iw)/2:y=0:color=black" -strict experimental 00189_5s_clock.mp4
- Relació
d'aspecte / Aspect ratio (ffmpeg)
- Sobreimpressió / Overlay
- Transport
Stream (TS) (see also ffmpeg
TS)
- mpegts
- TS streaming
- change PAT/PMT
rate (default: every 100ms):
- libavformat/mpegtsenc.c
- PAT_RETRANS_TIME 100
- libavformat/mpegtsenc.c
- MP4 (see also ffmpeg MP4)
- Streaming (see also ffmpeg
streaming)
-
-re option is needed when input is a file
server client (192.168.1.100)
output option: -f ...
(check that the port is not closed by the firewall) RTP / SDP rtp
unicast
- (?) avconv -re -i toto.mp4 -c:a copy -c:v copy -f rtp rtp://192.168.1.100:1234
multicast
- (?) avconv -re -i toto.mp4 -c:a copy -c:v copy -f rtp rtp://234.1.2.3:1234
TS over UDP
mpegts
unicast - avconv -re -i toto.mp4 -bsf h264_mp4toannexb -c:a copy -c:v copy -f mpegts "udp://192.168.1.100:1234?ttl=10&buffer_size=65536&pkt_size=1316"
- avconv -re -i toto.mp4 -f mpegts "udp://192.168.1.100:1234?ttl=10&buffer_size=65536&pkt_size=1316"
multicast - avconv -re -i toto.mp4 -c:v copy -c:a copy -bsf h264_mp4toannexb -f mpegts "udp://234.1.2.3:1234?ttl=10&buffer_size=65536&pkt_size=1316"
- avconv -re -i toto.mp4 -f mpegts "udp://234.1.2.3:1234?ttl=10&buffer_size=65536&pkt_size=1316"
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- server
- RTP / SDP
- from file
- avconv -re -i ...
- from camera
- avconv -f video4linux2 -i /dev/video0 -s 320x240 -vcodec libx264 -f rtp rtp://192.168.1.100:1234
- send generated sdp (shown on screen when
launching previous command) to client as
toto.sdp
- v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 192.168.1.100
t=0 0
a=tool:libavformat 55.0.1
m=video 1234 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 packetization-mode=1
- v=0
- from file
- TS over UDP
(use pkt_size=1316
to allocate 7 TS packets into one IP packet:
188*7=1316 < 1500):
- (see also OpenCaster tsudpsend)
- unicast (-re option needed if input is a file)
- avconv -i ... -f mpegts -muxrate 1200000 udp://unicast_destination_address:1234?buffer_size=65536&pkt_size=1316
- no transcoding (H.264/AAC) (depending on
original mp4 file, the option -bsf may be
necessary)
- avconv -re -i toto.mp4 -bsf h264_mp4toannexb -c:a copy -c:v copy -f mpegts udp://192.168.1.100:1234?ttl=10&buffer_size=65536&pkt_size=1316
- transcode from mp4 (h.264/aac) to mpeg2ts
(mpeg2video/mp2):
- avconv -re -i toto.mp4 -f mpegts udp://192.168.1.100:1234?ttl=10&buffer_size=65536&pkt_size=1316
- multicast
- avconv -i ... -f mpegts -muxrate 1200000 udp://multicast_destination_address:1234?ttl=10&buffer_size=65536&pkt_size=1316
- implicit transcoding to mpeg2video/mp2:
- avconv -re -i toto.mp4 -f mpegts udp://234.1.2.3:1234?ttl=10&buffer_size=65536&pkt_size=1316
- no transcoding:
- avconv -re -i toto.mp4 -c:v copy -c:a copy -bsf h264_mp4toannexb -f mpegts udp://234.1.2.3:1234?ttl=10&buffer_size=65536&pkt_size=1316
- RTP / SDP
- client (192.168.1.100)
- RTP / SDP
- unicast
- just play:
- avplay toto.sdp
- write the stream to a TS file with TS
constant bit-rate (e.g. 80kbps):
- avconv -i toto.sdp -c:v copy -y -f mpegts -muxrate 80000 toto.ts
- just play:
- multicast
- ...
- unicast
- TS over UDP (see also ffmpeg
UDP):
- -infbuf option is needed to avoid errors (see also fifo_size for ffmpeg)
- unicast
- avplay -infbuf udp://@:1234
- avconv ... -i udp://...fifo_size=...
- multicast
- avplay -infbuf -i udp://@234.1.2.3:1234
- RTP / SDP
-
- H.264
/ libx264
(see also ffmpeg with x264)
- libx264
- GOP size: 100
- -g 100
- GOP size: 100
- baixa latència / low latency
- x264 presets:
- avconv -preset ultrafast
- avconv presets
- /usr/local/share/avconv/libx264-*.avpreset
- avconv -pre:v 1080p50_60
- /usr/local/share/avconv/libx264-toto_preset.avpreset
(com es fa amb un fitxer local? quines opcions hi ha
disponibles?)
- slices=2
x264-params=cabac=0
... - avconv ... -pre:v toto_preset ...
- slices=2
- /usr/local/share/avconv/libx264-*.avpreset
- baseline profile del vídeo redimensionat a 360x* ("-1"
fa que es mantingui la relació), a 800 kbps:
- avconv -i toto.ts -filter:v scale=360:-1 -b:v 800k -profile:v baseline toto.mp4
- Problemes / Problems
- "[libx264] lookaheadless mb-tree requires intra refresh or infinite keyint"
- libx264
- Using ffmpeg
- Info
- ffmpeg-libav-tutorial (Leandro Moreira)
- FFmpeg_Book
(pdf)
(Astro
Electronic)
- Bird trails
- Docs
- Documentation
- All documentation
- Filter
documentation
- Audio
sources
- abuffer, aevalsrc, afdelaysrc, afireqsrc,
afirsrc, anullsrc, flite, anoisesrc, hilbert,
sinc, sine
ffplay -f lavfi -i "sine=frequency=5000:sample_rate=44100, aformat=channel_layouts=stereo"- ...
- abuffer, aevalsrc, afdelaysrc, afireqsrc,
afirsrc, anullsrc, flite, anoisesrc, hilbert,
sinc, sine
- Video
sources
- mandelbrot, allrgb, allyuv, color, colorspectrum, haldclutsrc, nullsrc, pal75bars, pal100bars, rgbtestsrc, smptebars, smptehdbars, testsrc, testsrc2, yuvtestsrc
ffplay -f lavfi -i mandelbrotffmpeg -f lavfi -i testsrc=size=864x480- ffmpeg -lavfi 'testsrc2;sine' toto.mov
ffmpeg -f lavfi -i "testsrc=duration=10:size=640x360, format=pix_fmts=yuv420p" -f lavfi -i anoisesrc=duration=10:colour=pink:amplitude=0.5 -ac 2 toto.mp4- audio/video sync
- openclsrc
- ...
- Audio
sources
- wiki
- Acceleració per
maquinari / Hardware acceleration
- AWS
- CPU capabilities
- ...
- HWAccelIntro
- Usage
- Detecció
/ Detection
- check whether ffmpeg has been compiled with nvenc
support:
ffmpeg -codecs | grep nvenc
- check whether ffmpeg has been compiled
with nvenc support and system allows
usage of nvenc:
ffmpeg -f lavfi -i nullsrc -c:v h264_nvenc -t 00:00:00 -f null /dev/null- all ok (exit with 0)
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
- ffmpeg has not been compiled
with cuda (exit with 1)
- Unknown encoder 'h264_nvenc'
- system is not able to deal
with cuda (exit with 1)
- [h264_nvenc @ 0x762c00] dl_fn->cuda_dl->cuInit(0) failed -> CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
- all ok (exit with 0)
- echo $?
- example script:
#!/bin/bash
function is_ffmpeg_nvenc_available {
# check whether ffmpeg has h264_nvenc coder and system is able to use it
ffmpeg -f lavfi -i nullsrc -c:v h264_nvenc -t 00:00:00 -f null /dev/null 1>/dev/null 2>&1
result=$?
if ! (( result ))
then
# ffmpeg works ok
echo 1
else
# ffmpeg exits with 1 (error)
echo 0
fi
}
nvenc_available=$(is_ffmpeg_nvenc_available)
echo "nvenc_available: ${nvenc_available}"
- check whether ffmpeg has been compiled with nvenc
support:
- Decoding and encoding
ffplay ffmpeg decoding - -vcodec h264_cuvid
- -c:v h264_cuvid
- -hwaccel cuda
- -c:v h264_cuvid
encoding - - -c:v h264_nvenc
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Decoding
ffmpeg -h decoder=h264_cuvidffplay -vcodec h264_cuvid toto.mp4ffmpeg -hwaccel cuda -i toto.mp4 ...
- Encoding
ffmpeg -h encoder=h264_nvenc
ffmpeg -y -f lavfi -i "testsrc=duration=20:size=1920x1080, format=pix_fmts=yuv420p" -f lavfi -i anoisesrc=duration=10:colour=pink:amplitude=0.5 -ac 2 -c:v h264_nvenc toto_nvenc.mp4- ffmpeg -f lavfi -i nullsrc -c:v h264_nvenc -gpu list -f null -
- Transcoding
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input -c:v h264_nvenc -preset slow output
- Filtering
- Detecció
/ Detection
- Output from ./configure when compiling
system info
vdpauinfo
Mageia dependencies
nv-codec-headers ?
libv64dpau-devel ? libva-devel lib64omxil-bellagio-devel
CentOS/Alma/Rocky dependencies
nv-codec-headers
Debian/Raspbian dependencies
libomxil-bellagio-dev provided pkg-config
auto-detect (no need to specify --enable-...)
ffnvcodec
[--enable-vdpau] x
[--enable-vaapi] --enable-omx --enable-omx-rpi External libraries providing
hardware (decoding) acceleration:
- ffmpeg -hwaccels
- Hardware acceleration methods:
- ffmpeg -hwaccel cuda ...
- ffplay ...
cuda cuda cuda
codec suffix
(ffmpeg -codecs, ./configure --list-hwaccels)
nvenc nvdec cuvid vdpau v4l2_m2m vaapi omx
Enabled encoders
ffmpeg -codecs
- ffmpeg -i input -c:v h264_nvenc -o output
H.263
h263_v4l2m2m
H.264 h264_nvenc, nvenc_h264
h264_vaapi h264_omx
HEVC hevc_nvenc, nvenc_hevc
hevc_v4l2m2m hevc_vaapi
MJPEG
mjpeg_vaapi
MPEG-1
MPEG-2
mpeg2_vaapi
MPEG-4
mpeg4_v4l2m2m
mpeg4_omx
VP8
vp8_v4l2m2m
Possible hwaccels (decoders)
./configure --list-hwaccels
ffmpeg -codecs
- ...
AV1
av1_nvdec
av1_vaapi
H.263
h263_v4l2m2m h263_vaapi
H.264
h264_nvdec h264_cuvid h264_vdpau h264_v4l2m2m h264_vaapi
HEVC
hevc_nvdec hevc_cuvid hevc_vdpau hevc_v4l2m2m hevc_vaapi
MJPEG
mjpeg_nvdec mjpeg_cuvid
mjpeg_vaapi
MPEG-1
mpeg1_nvdec mpeg1_cuvid mpeg1_vdpau mpeg1_v4l2m2m
MPEG-2
mpeg2_nvdec mpeg2_cuvid mpeg2_vdpau mpeg2_v4l2m2m mpeg2_vaapi
MPEG-4
mpeg4_nvdec mpeg4_cuvid mpeg4_vdpau mpeg4_v4l2m2m mpeg4_vaapi
VC1
vc1_nvdec vc1_cuvid vc1_vdpau vc1_v4l2m2m vc1_vaapi
VP8
vp8_nvdec vp8_cuvid
vp8_v4l2m2m vp8_vaapi
VP9
vp9_nvdec vp9_cuvid vp9_vdpau vp9_v4l2m2m vp9_vaapi
WMV3
wmv3_nvdec
wmv3_vdpau
wmv3_vaapi
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- ffmpeg -hwaccels
-
configure option
(./configure --list-hwaccels)
codecs
libav
ffmpeg
mjpeg mpeg1 mpeg2
mpeg4
h263
h264
hevc vc1
vp8 vp9 wmv3
--disable-dxva2
x
CUDA
x x x x
x x x x x x OpenMAX --enable-omx
--enable-omx-rpi
v4l2_m2m
d d ed ed ed
d
VA API
--enable-vaapi
[--enable-vaapi]
--enable-hwaccel=h264_vaapix
x
x
x
x
x x
x x x
VDA
--enable-vda
--enable-hwaccel=h264_vda
x
VDPAU
--enable-hwaccel=h264_vdpau
x x
x
x
x x
x
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Creating
multiple
outputs
... -f tee -flags +global_header -map 0:v -map 0:a "[...]...|[...]..."- Problemes /
Problems
- NOTE: if -flags +global_header is not specified and one of the outputs is RTMP, it will appear without video profile in /stats (nginx-rtmp-module) and HTML5 player with video.js will not be able to start it
[tee @ 0x80cf20] Non-monotonous DTS in output stream 0:0; previous: 566, current: 561; changing to 567. This may result in incorrect timestamps in the output file.
- Examples:
- 1 transcoding and 2 output muxers: HLS + RTMP
- ffmpeg -i ... \
-c:a ... -c:v ... \
-f tee -flags +global_header -map 0:v -map 0:a \
"[hls_time=2:hls_list_size=0:hls_wrap=0:start_number=1]toto.m3u8|[f=flv]rtmp://localhost:1935/..."
- ffmpeg -i ... \
- 2 transcodings: one with HLS+RTMP, the other one
with HLS+SAP
- ffmpeg -i ... \
-vsync vfr -c:v h264 -preset medium -b:v 1000000 -vf scale=w=720:h=576 -g 25 -profile:v main -level 30 -keyint_min 25 -sc_threshold 0 \
-c:a aac -strict -2 -b:a 128000 -ac 2 \
-f tee -flags +global_header -map 0:v -map 0:a \
"[hls_time=2:hls_list_size=0:hls_wrap=0:start_number=1]sd.m3u8|[f=flv]rtmp://localhost:1935/sd/..." \
-vsync vfr -c:v h264 -preset medium -b:v 2000000 -vf scale=w=1280:h=720 -g 25 -profile:v high -level 31 -keyint_min 25 -sc_threshold 0 \
-c:a aac -strict -2 -b:a 128000 -ac 2 \
-f tee -flags +global_header -map 0:v -map 0:a \
"[hls_time=2:hls_list_size=0:hls_wrap=0:start_number=1]hd.m3u8|[f=sap]sap://234.1.2.3" \
- ffmpeg -i ... \
- 1 transcoding and 2 output muxers: HLS + RTMP
- How to speed up / slow down a video time lapse, etc.
- Option '-sameq' does NOT mean 'same quality'
- How to take multiple screenshots to an image (tile, mosaic)
- Create a mosaic out of several input videos
- Filtering guide
- Acceleració per
maquinari / Hardware acceleration
- options
- more options
- ffmpegX options
- ffplay -loglevel
verbose ...
- ffplay -v {quiet,panic,fatal,error,warning,info,verbose,debug} [-vf showinfo] ...
- Protocol 'rtp' not on whitelist 'file,crypto'!
- ffplay -safe 0 -protocol_whitelist rtp,udp,file,http,https,tcp,tls -i toto.sdp
- keyboard
(cursor over window showing video)
- q ESC quit
f toggle full screen
p,SPC pause
a cycle audio channel in the current program
v cycle video channel
t cycle subtitle channel in the current program
c cycle program
w cycle video filters or show modes
s activate frame-step mode
left/right seek backward/forward 10 seconds
down/up seek backward/forward 1 minute
pg down/pg up seek backward/forward 10 minutes
mouse right click seek to percentage in file corresponding to fraction of width
- q ESC quit
- webcam
- Capture / Webcam
- Dispositius / Devices
v4l2-ctl --list-devicesv4l2-ctl -d /dev/video1 -Lv4l2-ctl -c <option>=<value>
- Visualització / View
- ffmpeg [-v ...] [options_for_input_file_0 [-i input_file_0]] [options_for_input_file_1 [-i input_file_1]] [-map 0:x] [-map 1:y] [options_for_output_file_0 [output_file_0]] [options_for_output_file_1 [output_file_1]] [options -newaudio] [options -newvideo]
- keyboard actions
(type "?" to see help)
- ? show this help
+ increase verbosity
- decrease verbosity
c Send command to first matching filter supporting it
C Send/Que command to all matching filters
D cycle through available debug modes
h dump packets/hex press to cycle through the 3 states
q quit
s Show QP histogram
- ? show this help
- Generic
options (show available ...):
- ffmpeg -formats
- ffmpeg -codecs
- ffmpeg -filters
- ffmpeg -pix_fmts (show available pixel formats: -pixel_format)
- ffmpeg -sample_fmts
- general parameters
- -d daemonize
(must be the very first option)
- -stream_loop
<number> (0: no loop; -1: infinite loop; n: number
of loops)
- -i input file
- Video
sources (synthetic videos)
- [ffplay,ffmpeg] -f lavfi -i testsrc=size=1280x720 ...
- Video
sources (synthetic videos)
- -f container/ES_type
- -loglevel, -v {quiet,panic,fatal,error,warning,info,verbose,debug,trace}
- -hide_banner
- -d daemonize
(must be the very first option)
- flags / fflags
- complete list of ffmpeg flags / commands
- -flags
- global_header
- loop
- low_delay
- ...
- -fflags
(format flags)
- fastseek
- genpts
- igndts
- nobuffer
- ...
- video parameters
- -c:v
video_codec
- -b:v video_bit-rate
- -b video bit-rate
- -bt:v video_bit-rate tolerance
- -r frame-rate
- -s size (see also scale filter)
- -aspect aspect_ratio
- -c:v
video_codec
- audio parameters
- -c:a
audio_codec
- -b:a audio_bit-rate
- -ac number_of_audio_channels
- -ar audio_sampling_rate
- -c:a
audio_codec
- -map
input_file:index (when using map option, all
output streams to be mapped must be specified; if output
file can contain both audio and video, e.g. mp4, two -map
must be specified)
- Stream selection
- examples (*):
- ... -map 0:0 -map 0:2 ... toto.mp4
- stream #0:0 (video) to toto.mp4 video track
- stream #0:2 (2nd audio) to toto.mp4 main audio track
- .. -map 0:0 -map 0:2 -map 0:1 ... toto.mp4
-newaudio
- stream #0:0 (video) to toto.mp4 video track
- stream #0:2 (2nd audio) to toto.mp4 main audio track
- stream #0:1 (1st audio) to toto.mp4 secondary audio track
- ... -map 0:3 -map 2:4 out_a.mp2 out_b.mp3
- stream #0.3 to out_a.mp2
- stream #2.4 to out_b.mp3
- ffmpeg -i first_input.mp4 -i second_input.mp4 -i
third_input.mp2 -map 0:0 -map 0:2 -map 1:1 -map 1:1
-map 2:1 toto.mp4 -newaudio out_a.mp2 out_b.mp3
input
output
first_input.mp4 contains:
- 0:0: video track
- 0:1: audio track
- 0:2: audio track
-i first_input.mp4 second_input.mp4 contains:
- 1:0: video track
- 1:1: audio track
-i second_input.mp4 third_input.mp2 contains:
- 2:0: audio track
- 2:1: audio track
-i third_input.mp2 Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-map 0:0 toto.mp4 toto.mp4 will contain the following tracks:
- 0:0: video from first_input
- 0:1: audio from second audio track from first_input
- 0:2: audio from first audio track from second_input
-map 0:2 -map 1:1 -newaudio -map 1:1 out_a.mp2 out_a.mp2 will contain the following tracks:
- 1:0: audio from first audio track from second_input
-map 2:1 out_b.mp3 out_b.mp3 will contain the following tracks:
- 2:0: audio from second audio track from third input
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- TS program selection
- ... -map 0:0 -map 0:2 ... toto.mp4
- pipe
- multiple inputs
- Switch (mixer)
- múltiples sortides / multiple outputs
- sample formats
- list of available formats
- ffmpeg -sample_fmts
- libswresample (libav: libavresample)
- conversion from s16p to s16:
- How to convert sample
rate from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16?
- libswresample
- [Libav-user] Audio conversion from planar to non-planar formats
- (?) fffmpeg ... -sample_fmt s16 ...
- How to convert sample
rate from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16?
- list of available formats
- Start from time (-ss) hh:mm:ss[:ff],
during duration (-t):
- ffmpeg ... -ss hh:mm:ss[:ff] -t hh:mm:ss[.dd] ...
- specify -ss before -i to avoid anything but key frames: much faster (*)
- "-ss seconds" for an entire number of seconds
- filtres / filtering
- FFmpeg Filters Documentation
- Filtering
guide (wiki)
- Visualizing
filters
- graph2dot ...
- Visualizing
filters
- chained filters
- simple
- Filtergraph,Chain,Filter relationship
- -vf "scale=320:-1, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: timecode='00\:00\:00\:00': r=24: x=(w-tw)/2: y=h-(2*lh): fontsize=50: fontcolor=white"
- complex
- -filter_complex
-filter_complex "[input_label]filter_a.1_name=param1=value1:param2=value2,filter1.2_name=param1=value1:param2=value2[output_label]; [input_label]...[output_label]"- igual: separa el nom del filtre dels paràmetres; separa clau de valor
- dos punts: separa els paràmetres entre ells
- coma: separa dos filtres consecutius
- punt i coma: separa dos filtres paral·lels
- filtres:
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- -filter_complex
- simple
- list of available filters:
- ffmpeg -filters
- audio
- video
- ffmpeg -filter:v ...
- ffmpeg -vf ...
- show information (see also ashowinfo for audio) (n pts pts_time pos fmt sar s i iskey type checksum plane_checksum mean stdev)
- remove the logo
- ffplay -i tv3.m2v -vf 'delogo=x=620:y=40:w=50:h=50:band=10:show=0'
- add a logo (see OpenCaster):
- ffmpeg -vf ...overlay...
- ffmpeg -i ${video_src} -i ${logo_src} \
-filter_complex "[0:v]scale=320:-1[output]; [1:v][output]scale2ref=iw/8:-1[logo][output]; [output][logo]overlay=main_w/10:main_h/10[output]" -map "[output]" -map 0:a -c:v h264 -c:a aac -f tee "[f=mp4]output1_tl.mp4|[f=mpegts]output1_tl.ts" \
-filter_complex "[0:v]scale=640:-1[output]" -map "[output]" -map 0:a -c:v h264 -c:a aac -f tee "[f=mp4]output2.mp4"
- display subtitles
- dep
- Mageia
- urpmi libass-devel
- Mageia
- ./configure ... --enable-libass
- ffmpeg -vf 'subtitles'
- dep
- scale (resize)
- PIP
- ffplay -i 324.m2v -vf 'movie=tv3.m2v, scale=180:-1 [petit]; [in][petit] overlay=16:16 [out]'
- ffplay -i 794.ts -vst 11 -ast 12 -vf "movie=794.ts:s=0, scale=180:-1 [v1]; [in][v1] overlay=16:16 [out]"
- ffmpeg -i 794.ts -filter_complex "[0:v:0]scale=width=240:height=180[petit]; [0:v:1][petit] overlay" -f mpegts - | ffplay -
- ffmpeg -i 794.ts -b:v 2M -filter_complex "[0:v:0]scale=width=240:height=180[petit]; [0:p:803:v][petit] overlay" -f mpegts - | ffplay -
- mosaic
- ffmpeg -i 794.ts -b:v 4M -filter_complex "nullsrc=size=1280x720 [base]; [0:v:0] scale=width=640:height=360 [upperleft]; [0:v:1] scale=width=640:height=360 [upperright]; [0:v:2] scale=width=640:height=360 [lowerleft] ; [0:v:3] scale=width=640:height=360 [lowerright]; [base][upperleft] overlay [tmp1]; [tmp1][upperright] overlay=shortest=1:x=640 [tmp2]; [tmp2][lowerleft] overlay=shortest=1:y=360 [tmp3]; [tmp3][lowerright] overlay=shortest=1:x=640:y=360" -f mpegts - | ffplay -
- drawtext
- ffmpeg has to be compiled with
--enable-libfreetype,--enable-libharfbuzz, and, optionally,--enable-fontconfig(to allow not specifying font) ... -filter_complex "[0:v]drawtext=text=toto: x=(w-tw)/2: y=h/4: box=1: boxcolor=black: fontsize=h/4: fontcolor=white [v0]" -map '[v0]' ...- Burnt
in
timecode
- Dependencies and fontfile:
- Mageia
sudo dnf install google-droid-sans-fonts- fontfile=/usr/share/fonts/google-droid/DroidSansMono.ttf
- fontfile=/usr/share/fonts/google-droid-sans-fonts/DroidSans.ttf
- urpmi fonts-ttf-droid
- CentOS
- sudo yum install
google-droid-sans-mono-fonts
google-droid-sans-fonts
- fontfile=/usr/share/fonts/google-droid/DroidSansMono.ttf
- sudo yum install
google-droid-sans-mono-fonts
google-droid-sans-fonts
- Ubuntu
- sudo apt-get install
fonts-droid-fallback
- fontfile=/usr/share/fonts-droid/truetype/droid/DroidSansFallback.ttf
- fontfile=/usr/share/fonts-droid-fallback/truetype/DroidSansFallback.ttf
- sudo apt-get install
fonts-droid-fallback
- Mageia
- ffplay -f lavfi -i testsrc=size=1280x720 -vf "drawtext=fontfile=${fontfile}: timecode='09\:57\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1"
- ffplay -f lavfi -i testsrc=size=1280x720 -vf "drawtext=fontfile=/usr/share/fonts/TTF/droid/DroidSans.ttf: timecode='09\:57\:00\:00': r=25: x=(w-tw)/2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1"
- ffmpeg -i sintel-1024-stereo.mp4 -vf "drawtext=fontfile=${fontfile}: timecode='00\:00\:00\:00': r=24: x=(w-tw)/2: y=h-(2*lh): fontsize=50: fontcolor=white: box=1: boxcolor=0x00000000@1" -c:a copy -c:v libx264 sintel-1024-stereo_timecode.mp4
- referenced variables
-
wwidth h
text_w, tw
line_h, lh
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- present time (local):
- ... -vf "drawtext=fontfile=${fontfile}: text='%{localtime\:%T}': r=24: x=(w-tw)/2: y=h-(2*lh): fontsize=50: fontcolor=white: box=1: boxcolor=0x00000000@1" ...
- timecode and present time (UTC):
- ffplay -f lavfi -i testsrc=size=1280x720:r=25 -vf "format=pix_fmts=yuv420p, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: text='%{gmtime\:%T %Z}': r=25: x=(w-tw)/3*2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=50, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: timecode='00\:00\:00\:00': r=25: x=(w-tw)/3: y=h-(2*lh): fontsize=50: fontcolor=white: box=1: boxcolor=0x00000000@1"
- ffmpeg -f lavfi -i testsrc=size=1280x720:r=25 -vf "format=pix_fmts=yuv420p, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: text='%{gmtime\:%T %Z}': r=25: x=(w-tw)/3*2: y=h-(2*lh): fontcolor=white: box=1: boxcolor=0x00000000@1: fontsize=50, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: timecode='00\:00\:00\:00': r=25: x=(w-tw)/3: y=h-(2*lh): fontsize=50: fontcolor=white: box=1: boxcolor=0x00000000@1" -c:v libx264 -g 12 -keyint_min 12 -sc_threshold 0 -f flv rtmp://...
- present UTC time, with milliseconds, with
audio, to mp4 file:
-
fontfile="..."
ffmpeg -re \
-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10:colour=pink:amplitude=0.5, aformat=channel_layouts=stereo" \
-vf "drawtext=fontfile=${fontfile}: text='%{gmtime\:%Y-%m-%dT%H\\\\\:%M\\\\\:%S.%NZ}': x=(w-tw)/2: y=h-(2*lh): fontsize=30: fontcolor=white: box=1: boxcolor=0x00000000@1" \
-ac 2 toto.mp4
-
- present UTC time, with milliseconds, with
audio, to HLS
file with #EXT-X-PROGRAM-DATE-TIME in UTC:
- for HLS #EXT-X-PROGRAM-DATE-TIME,
ffmpeg will take timezone value from
/etc/localtime (a symbolic link to e.g.
/usr/share/zoneinfo/Europe/Andorra). If
you want UTC in
#EXT-X-PROGRAM-DATE-TIME, you must
export TZ=UTC
export TZ=UTC && \\
ffmpeg -re \
-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10:colour=pink:amplitude=0.5, aformat=channel_layouts=stereo" \
-vf "drawtext=fontfile=${fontfile}: text='%{gmtime\:%Y-%m-%dT%H\\\\\:%M\\\\\:%S.%NZ}': x=(w-tw)/2: y=h-(2*lh): fontsize=30: fontcolor=white: box=1: boxcolor=0x00000000@1" \
-ac 2 \
-b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
-map 0:v -map 1:a -map 0:v -map 1:a \
-f hls \
-var_stream_map "v:0,a:0,name:my_hd v:1,a:1,name:my_sd" \
-master_pl_name master.m3u8 \
-hls_list_size 0 \
-hls_flags program_date_time \
out_%v.m3u8
- for HLS #EXT-X-PROGRAM-DATE-TIME,
ffmpeg will take timezone value from
/etc/localtime (a symbolic link to e.g.
/usr/share/zoneinfo/Europe/Andorra). If
you want UTC in
#EXT-X-PROGRAM-DATE-TIME, you must
- resize to 1280x720, downmix to stereo, add
timecode:
- ffmpeg -i big_buck_bunny_1080p_h264.mov -vf "scale=1280:-1, drawtext=fontfile=/usr/share/fonts/google-droid/DroidSans.ttf: timecode='00\:00\:00\:00': r=24: x=(w-tw)/2: y=h-(2*lh): fontsize=50: fontcolor=white: box=1: boxcolor=0x00000000@1" -ac 2 -c:a aac -strict -2 -b:a 64k -c:v libx264 -b:v 700k bbb_timecode_1280x720_700k_stereo.mp4
- compte enrere / countdown
input=input.mp4
duration=$(ffprobe -loglevel error -show_entries format=duration -of default=nw=1:nk=1 "$input")
ffplay -f lavfi -i "color=color=DarkGray:size=1280x720:duration=${duration}" -vf "drawtext=fontfile=${fontfile}: text='%{eif\:$duration-t\:d}': x=(w-tw)/2: y=(h-lh)/2: fontcolor=white: fontsize=h/2"
- Dependencies and fontfile:
- Dynamic text
- ffmpeg has to be compiled with
- show DVB subtitles:
- from ts file
- ffplay -i tvc_794_20140821_1709.ts -vst 2 -ast 7 -sst 23
- from live dvb (no funciona, perquè potser tzap
no conserva els subtítols)
- tzap -pr "TV3(TVC)"
- ffplay -f mpegts -i /dev/dvb/adapter0/dvr0 -vf 'subtitles=...
- from ts file
- burn DVB subtitles:
- ffmpeg -i tvc_794_20140821_1709.ts
- Program 801
Metadata:
service_name : ?TV3
service_provider: ?TVC
Stream #0:2[0x6f]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:7[0x70](cat): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 158 kb/s
Stream #0:6[0x72](v.o): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 94 kb/s
Stream #0:8[0x73](ac3): Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 192 kb/s
Stream #0:22[0x74](a.d): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 94 kb/s
Stream #0:23[0x321](cat): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:24[0x32b](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
...
- Program 801
- ffmpeg -i tvc_794_20140821_1709.ts -filter_complex '[#0x6f][#0x321] overlay' -sn -map '#0x70' -f mpegts - | ffplay -
- ffmpeg -i 794.ts -filter_complex '[0:v][0:s:0]overlay[v]' -map [v] -map 0:a ...
- ffmpeg -i tvc_794_20140821_1709.ts
- ffmpeg -f lavfi -i amovie=toto.ts,silencedetect=noise=0.0001 -f null -
- blackframe
- ffmpeg -f lavfi -i movie=tvc_hd_20121116-2345.ts,blackframe -f null -
- segmentació / segmentation
- concatenació /
concatenation
- libav: Concatenació / Concatenation
- MTS: Concatenació / Concatenation
- Concatenate
(How
to
concatenate (join, merge) media files) (wiki)
- methods:
concat demuxer
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.wav
- all files must have the same muxer and coders
- not working well with dts discontinuities
concat protocol
ffmpeg -i "concat:input1.ts|input2.ts|input3.ts" -c copy output.ts
- working well with dts discontinuities
concat filter
ffmpeg -i input1.mp4 -i input2.webm -i input3.mov \ -filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]" \ -map "[outv]" -map "[outa]" output.mkv
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- ffmpeg: adding blankspace to end of video
- concat
demux
- e.g. to preprend a preroll
- create a preroll with the same parameters
as main video:
/usr/local/bin/ffmpeg -y -f lavfi -i "pal75bars=duration=2.0:size=1280x720:r=25/1, format=pix_fmts=yuv420p" -f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=44100" -c:v h264 -profile:v Main -ac 2 -c:a aac -video_track_timescale 25000 /tmp/toto.mp4
- create a file with a playlist: input.txt
- file
...
file ...
- file
...
- play it
ffplay -f concat -safe 0 -i input.txt
- create a preroll with the same parameters
as main video:
- e.g. to preprend a preroll
- Concat
filter
- Does not accept -c copy
ffmpeg -f lavfi -i "pal75bars=duration=3:size=640x360, format=pix_fmts=yuv420p" -f lavfi -i "anoisesrc=duration=3:colour=white:amplitude=0.2" -i toto.mp4 -filter_complex '[0:v:0][1:a:0][2:0][2:1] concat=n=2:v=1:a=1 [outv] [outa]' -map "[outv]" -map "[outa]" tutu.mp4
- Manually
- directly concatenable formats
- cat imput1.ts input2.ts > output.ts
- not directly concatenable formats, but
transmuxable to a concatenable format (e.g.
H.264/AAC in MP4, to TS)
- mkfifo temp1 temp2
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp1 2> /dev/null & \
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts temp2 2> /dev/null & \
ffmpeg -f mpegts -i "concat:temp1|temp2" -c copy -bsf:a aac_adtstoasc output.mp4 - concat_mp4.sh
- #!/bin/bash
MIN_ARGS=2
if (( $# < $MIN_ARGS ))
then
cat <<EOF
Usage: `basename $0` <input1> <input2> <input3> ... <output>
Concatenate several MP4 files into a single one.
EOF
exit 1
fi
#TMP=/tmp
TMP=$(mktemp -d)
# get all the command line parameters, except for the last one, which is output
output=${@:$#:1}
len=$(($#-1))
inputs=${@:1:$len}
function get_metadata {
video_path=$1
echo "[$(basename $0).get_metadata] $video_path"
info=$(ffprobe -i $video_path -show_format -v quiet)
metadata_str=$(echo "$info" | awk 'BEGIN {ORS=" ";FS="="} /^TAG:/ {gsub(/TAG:/,""); print "-metadata " $1 "=\"" $2 "\""}')
echo "[$(basename $0).get_metadata] metadata_str: $metadata_str"
return
}
function finish {
# remove created fifos
rm -f $TMP/mcs_*
}
# call finish function when exiting
trap finish EXIT
echo "[$(basename $0)]"
# remove all previous tmp fifos (if exist)
rm -f $TMP/mcs_*
i=0
for f in $inputs
do
echo "[$(basename $0)] input $i: $f"
if [[ -s $f ]]
then
# create fifo
fifo_name=$TMP/mcs_$i
mkfifo $fifo_name
# copy to fifo
ffmpeg -i $f -y -c copy -bsf:v h264_mp4toannexb -f mpegts $fifo_name 2> /dev/null &
if (( i==0 ))
then
concat_str="concat:${fifo_name}"
# get metadata (e.g. creation date) only from the first file
get_metadata $f
else
concat_str="${concat_str}|${fifo_name}"
fi
else
echo "[$(basename $0)] WARNING: $f is not a valid input"
fi
(( i++ ))
done
echo "[$(basename $0)] output: $output"
if [[ "$concat_str" ]]
then
echo "[$(basename $0)] concat_str: $concat_str"
eval ffmpeg -y -f mpegts -i \"${concat_str}\" -c copy -bsf:a aac_adtstoasc $metadata_str $output
else
echo "[$(basename $0)] ERROR: no valid input files found"
exit 1
fi
exit 0
- #!/bin/bash
- mkfifo temp1 temp2
- directly concatenable formats
- Using
an
external script
- mmcat.sh
- methods:
- timestamps
- DTS: decoding time stamp
- PTS: presentation time stamp
- Info
- Sincronització / Synchronisation
- Tutorial 05: Synching Video (An ffmpeg and SDL Tutorial)
- [FFmpeg-user] Fixing bad DTS/PTS without reencode
- Recalculate PTS/DTS
setpts- multiple
input
overlay in 2x2 grid (wiki)
setpts=PTS-STARTPTS
- multiple
input
overlay in 2x2 grid (wiki)
- -copyts
- -copytb mode
- -fflags genpts
- delay subtitles
- regenerate timestamps
- FFmpeg: recreate timestamps without reencoding
- video
-vsyncdrop- "As passthrough but destroys all timestamps, making the muxer generate fresh timestamps based on frame-rate."
- to reset "
start: xxxx.xxxxxx" to "start: 0.000000" (maybe you need to deal with video-only file?)ffmpeg -i toto_start_xxx.video.mp4 -c copy toto_start_0.video.mp4
- audio
- -async ...
- Problemes / Problems
- info output is written to stderr (stdout is used for media
data)
- ffmpeg -i toto.mp2 toto.aac 2>toto.log
- HOWTOs
- Pipe
- FFmpeg Howto (FFMedia Broadcast)
- Tutoriales FFmpeg para principiantes
- Using ffmpeg to manipulate audio and video files
- HOWTO: Fix Aspect ratio of Divx,etc for DVD with ffmpeg
- FFmpeg
and 'Fist of Fury'
- cropfilter: cropdetect
- subtitles
- DVD track extraction: tccat
- ...
- Encode
(el bocabyte vascodilatador)
- DVD track extraction: mplayer, vlc
- Shanes
video
encoding notes
- ..
- Frame-rate
- tbn, tbc, tbr
-r(v<6) /-fpsmax(v≥6)-vsync(v<6) /-fps_mode(v≥6)-
value
string
description
-1
auto
"Chooses between 1 and 2 depending on muxer capabilities. This is the default method." 0
passthrough "Each frame is passed with its timestamp from the demuxer to the muxer."
1
cfr
"Frames will be duplicated and dropped to achieve exactly the requested constant frame rate."
2
vfr
"Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp."
drop
"As passthrough but destroys all timestamps, making the muxer generate fresh timestamps based on frame-rate."
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- ffmpeg: -vsync 0 versus -r (frame rate)
-
- Create a video by fragmenting the provided one
into fragments of different framerates:
- vfr.sh
- #!/bin/bash
video_path=$1
video_basename=$(basename $video_path)
video_name=${video_basename%.*}
# video
video_coder=h264
video_bitrate=500k
# audio
audio_coder=aac
audio_bitrate=128k
# get duration
duration=$(ffprobe -i $video_path -show_format -v quiet | sed -n 's/duration=//p')
# keep only numbers and decimal point (discard N/A):
duration=$(echo $duration | tr -d -c 0-9.)
echo "duration of ${video_path}: ${duration}"
fps_array=(30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 30 5 20 10 30 50 4 20 )
number_fragments=${#fps_array[@]}
echo "number_fragments: ${number_fragments}"
fragment_duration=$(echo ${duration}/${number_fragments} | bc )
echo "fragment_duration: ${fragment_duration}"
start=0
for fps in ${fps_array[@]}
do
echo "${fps} fps"
echo " start: $start"
output_filename=$(printf "%s_%05d_%sfps.mp4" ${video_name} ${start} ${fps})
echo " output_filename: ${output_filename}"
ffmpeg -y -ss ${start} -t ${fragment_duration} -i ${video_path} -vsync cfr -vf fps=${fps} -c:v ${video_coder} -b:v ${video_bitrate} -c:a ${audio_coder} -b:a ${audio_bitrate} ${output_filename}
start=$(( start + fragment_duration ))
done
# final concatenation
final_output_filename="${video_name}_vfr.mp4"
script=concat_mp4.sh
if which ${script}
then
echo "script ${script} found"
concat_mp4.sh -o ${final_output_filename} ${video_name}*fps.mp4
else
echo "script ${script} not found"
fi
exit 0
- #!/bin/bash
- vfr.sh
- Bit-rate
-
creation
info
OpenCaster
ffmpeg
x264
ffmpeg/ffplay
esvideompeg2info
-b:v 2M
bitrate from measured size (formula has rounds): 1997900.000000bps
-bt:v 200k
-minrate 2M
VBV: restrictions for hw decoder (e.g. DVB stb)
-maxrate 2M
--vbv-maxrate 2000
max. 2000 kb/s
Sequence header: bitrate: 2.00Mbs
-bufsize 1835008
--vbv-bufsize 1835
Sequence header: vbv buffer size: 112
-rc_init_occupancy 0 --vbv-init 0
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- DVB bit-rates
- VBV in OpenCaster
- CBR in TS
- Bit-rate in H.264
- TS bit-rate
- OpenCaster
- tspcrmeasure muxed_13271000_stamped.ts 13000000
- OpenCaster
- Video Buffer Verifier (VBV)
- Compressió, multiplexació estadística i serveis avançats sobre TV digital terrestre (Rubén Santiso Puigarnau)
- Variable bit rates with
?-vb? and ?minrate?/?maxrate? settings in FFmpeg
- CBR:
ffmpeg -f lavfi -i "testsrc=duration=3600:size=1920x1080, format=pix_fmts=yuv420p" -f lavfi -i anoisesrc=duration=3600:colour=pink:amplitude=0.5 -ac 2 -c:v libx264 -x264-params "nal-hrd=cbr:force-cfr=1" -b:v 3.5M -minrate 3.5M -maxrate 3.5M -bufsize 7M test_1h_3500k.mp4
- CBR: -b:v 3500K -minrate 3500K
- streaming: -maxrate 3500K -bufsize 1000K
- CBR:
- Limiting the output bitrate (ffmpeg wiki)
- EncodingForStreamingSites (ffmpeg wiki)
- To reduce
bit-rate (two passes: [Ffmpeg-user]
H.264
ignored bitrate) (-y: overwrite output files):
- ffmpeg -y -pass 1 ... -b 160k -qmax 50 ...
- ffmpeg -y -pass 2 ... -b 160k -qmax 50 ...
-
- H.264 video (using x264)
(see also libav
with libx264)
- FFmpeg and H.264 Encoding Guide
- FFmpeg x264 encoding guide
- Acceleració per maquinari / Hardware acceleration
- Linuxencoding
- X264 Encoding Suggestions
- X264 settings
- x264
FFmpeg
Options Guide (options for x264 and ffmpeg)
- default gop size: 250
- -g 250
- -keyint_min ... (will be truncated to gop_size/2 +1)
- -sc_threshold ... (scene cut detection)
- default gop size: 250
- GOP
- Key frame help
- Re:
changing
bitrate on the fly
- -sc_threshold ...
- fixed gop size (e.g. 12 frames)
- ... -g 12 -keyint_min 12 -sc_threshold 0 ...
- additional key frames:
- X264 Settings (MeWiki)
- High level settings
- -profile:v
- baseline, main, high, high10, high422, high444
- -level:v
-
-level:v ...level level idc
31
3.1 1f
51
5.1 33
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- -preset
(*)
(replaces
-vpre
for x264 from version ...)
- ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow, placebo
- -tune
- film, animation, grain, stillimage, psnr, ssim, fastdecode, zerolatency
- -profile:v
- Low level settings
- ... -x264opts "vbv-maxrate=2000:vbv-bufsize=200:slice-max-size=1500" ...
- x264
FFmpeg
Options Guide (options for x264 and ffmpeg)
- Baixa latència / Low latency
- Quality: CRF
Constant Rate Factor
-
crf
subjective quality
0
lossless
23
good
35
acceptable
51
terrible
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- H.264
bit-rate
control
- A qualitative overview of x264's ratecontrol methods, By Loren Merritt
- VBV
- A qualitative overview of x264's ratecontrol methods
- X264 Settings
- Ratecontrol
- nal-hrd (Hypothetical Reference Decoder)
- x264 FFmpeg Options Guide
- -vpre
(use "-preset"
(quality related) and "-profile:v"
(profile constraints) instead)
- /usr/share/ffmpeg/libx264-{ipod320,ipod640}.ffpreset (git code) (those related to x264 have been replaced)
- libx264 (ffmpeg documentation)
- x264 ? FFmpeg Preset Choices (FFmpeg x264 encoding guide) (FFmpeg x264 encoding guide)
- -vpre quality_related -vpre profile_constraints:
-
quality related
profile constraints
- ultrafast
- superfast
- veryfast
- faster
- fast
- medium
- slow
- slower
- veryslow
- placebo
- baseline
- main
- ipod320
- ipod640
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Problems
- "maybe incorrect parameters such as bit_rate,
rate, width or height"
- Solution: use -vpre option
- when using -vpre ipodxxx, you must prepend a -vpre {slow...} option
- "maybe incorrect parameters such as bit_rate,
rate, width or height"
- Transport
stream
(TS) (see also libav
TS)
- Creating DVB-T compatible MPEG2 streams using FFMPEG
- Generar un TS (Transport Stream) valido para DVB-T y DVB-T2 (TDT) (-mpegts...)
- Encoding H.264 CBR videos with FFmpeg
- -streamid ...
- Mux bitrate (specified in bits per second) (Bitrate calculator)
- mpegts
encoding options:
- -mpegts_original_network_id
- -mpegts_transport_stream_id
- -mpegts_service_id
- -mpegts_pmt_start_pid
- -mpegts_start_pid
- -metadata service_provider="nom proveidor"
- -metadata service_name="nom servei"
- Program (service)
selection:
- Stream specifiers (bug)
- Convert MPEG2TS to H264 ES
- ffprobe
- ffprobe -v 0 -show_frames -select_streams v:1 794.ts
- play video (-vst) #0:11 and audio (-ast) #0:12
- ffplay -i 794.ts -vst 11 -ast 12
- play video and best audio from specific program
(Program 10220):
ffplay -vst p:10220 -ast p:10220 ...
- play video and specific relative (?) audio from
specific program (Program 10220):
ffplay -vst p:10220 -ast p:10220:1 ...
- from the first (0:) input file, select "Program
51" (:p:51:) video (:0), without transcoding (-c:v
copy) into H.264 elementary stream (input video
already was H.264):
- ffmpeg -i input.ts -map 0:p:51:0 -c:v copy output.h264
- select "program 802" video and two audios from
input file and generate a TS:
- ffmpeg -i 794.ts -map 0:p:802:0 -map 0:p:802:1 -map 0:p:802:2 -c:v copy -c:a copy /tmp/c33.ts
- or directly select the stream id given by ffmpeg
-i:
- ffmpeg -i 794.ts
- Program 803
Metadata:
service_name : ?3/24
service_provider: ?TVC
Stream #0:26[0x83]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:27[0x84](cat): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 158 kb/s
Stream #0:25[0x86](v.o): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16p, 94 kb/s
[...]
- Program 803
- ffmpeg -i 794.ts -map 0:26 -c:v copy /tmp/324.m2v
- ffmpeg -i 794.ts
- select by pid:
- get the PIDs:
- ffmpeg -i
- nput #0, mpegts, from
'tvc_794_20140821_1709.ts':
Duration: 13:26:44.25, start: 758.128889, bitrate: 26 kb/s
Program 801
Metadata:
service_name : ?TV3
service_provider: ?TVC
Stream #0:2[0x6f]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 720x576 [SAR 64:45 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:7[0x70](cat): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 158 kb/s
...
- nput #0, mpegts, from
'tvc_794_20140821_1709.ts':
- ffmpeg -i
- ff
- ffmpeg -f mpegts -i udp://host:port -c:a:i:2300 aac -b:a 384k -c:v copy -f flv rtmp://host/live/stream
- get the PIDs:
- Transcoding from TS with MPEG-2 audio and video to TS
with H.264 and MPEG-2 audio:
- ffmpeg -i tvc_hd_20121116-2348.ts -c:a mp2 -ab 64k -ar 48000 -ac 1 -async 1 -c:v libx264 -threads 4 -preset veryfast -profile:v main -b:v 200k -s 256x144 -f mpegts toto2.ts
- Creation of a TS from an ES
(obtained with ffmpeg -i 794.ts -map 0:p:802:0 -c:v copy
/tmp/c33.m2v):
- ffmpeg -fflags +genpts -i /tmp/c33.m2v -c:v copy /tmp/c33_m2v.ts
- MP4
(see also libav MP4)
- mov / mp4 / ismv
- Fragmentació /
Fragmentation
- How to convert an mpeg2 to a streamable or fragmented mp4?
- How to output
fragmented mp4 with ffmpeg?
- ffmpeg ... -movflags frag_keyframe+empty_moov ...
- H.264 + AAC
- ffmpeg -i ... -c:v libx264 -b:v 800k -g 25 -keyint_min 25 -sc_threshold 0 -c:a aac -b:a 128k toto.mp4
- MP4 files to be MPEG-DASHed with MP4Box,
and played
with
dash.js (which requires -frag-rap option in
MP4Box)
- two representations with an added key frame every
2 (n_forced*2)
seconds (see also libx264
GOP)
- ffmpeg -i sintel_trailer-720p.mp4 -c:v libx264 -b:v 500k -s 640x360 -aspect 16:9 -force_key_frames 'expr:gte(t,n_forced*2)' -c:a aac -strict -2 -b:a 128k sintel_trailer_640x360_500k.mp4
- ffmpeg -i sintel_trailer-720p.mp4 -c:v libx264 -b:v 1500k -s 1280x720 -aspect 16:9 -force_key_frames 'expr:gte(t,n_forced*2)' -c:a aac -strict -2 -b:a 128k sintel_trailer_1280x720_1500k.mp4
- simultaneous
two video representations and one audio
representation, read at its rate (-re):
- ffmpeg -re -i sintel_trailer-720p.mp4 \
-c:v libx264 -b:v 500k -s 640x360 -aspect 16:9 -keyint_min 24 -g 24 -r 24 -an sintel_trailer_640x360_500k.mp4 \
-c:v libx264 -b:v 1500k -s 1280x720 -aspect 16:9 -keyint_min 24 -g 24 -r 24 -an sintel_trailer_1280x720_1500k.mp4 \
-c:a aac -strict -2 -b:a 128k -vn sintel_trailer_audio_128k.mp4- Stream mapping:
Stream #0:0 -> #0:0 (h264 -> libx264)
Stream #0:0 -> #1:0 (h264 -> libx264)
Stream #0:1 -> #2:0 (aac -> aac)
- Stream mapping:
- ffmpeg -re -i sintel_trailer-720p.mp4 \
- two representations with an added key frame every
2 (n_forced*2)
seconds (see also libx264
GOP)
- moov atom at the beginning of the file
-movflags +faststart
- get position of moov atom
- ffmpeg -v trace -i toto.mp4 2>&1 | grep -e type:\'mdat\' -e type:\'moov\'
moov atom not found- Solució / Solution
- untrunc
- ponchio / untrunc
- Compilació / Compilation
- get the code from git
git clone https://github.com/ponchio/untrunc.gitcd untrunc
- compile with a compiled ffmpeg
(/usr/local)
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -I <path_to_src>/ffmpeg-3.4.2 -I/usr/local/include -lavformat -lavcodec -lavutil
- compile with a system ffmpeg
- ..
- get the code from git
- Ús / Usage
- ...
- untrunc fork
- anthwlock / untrunc
- Compilació / Compilation
- get the code from git
git clone https://github.com/anthwlock/untrunc.git untrunc_anthwlockcd untrunc_anthwlock
- compile
make FF_VER=4.2.3
- ...
- get the code from git
- untrunc
- Solució / Solution
- FLV
- ffmpeg -re -f lavfi -i "testsrc=size=864x480, format=pix_fmts=yuv420p" -f lavfi -i "sine=frequency=5000:sample_rate=44100, aformat=channel_layouts=stereo" -c:v h264 -b:v 600k -profile:v main -preset ultrafast -c:a aac -strict -2 -b:a 64k -f flv toto.flv
- RTMP
- Test
Streaming
With FFMPEG
- ffmpeg -re -f lavfi -i
"testsrc=size=1280x720:rate=24" -f lavfi -i
sine=f=220:b=1 -af "volume=0.1" -codec:a aac
-strict -2 -codec:v libx264 -preset ultrafast
-profile:v main -tune zerolatency -pix_fmt
yuv420p -g 48 -f flv rtmp://...
- Problems
- [flv @ 0x23df540] Packets are not in
the proper order with respect to DTS
av_interleaved_write_frame(): Invalid argument
[flv @ 0x23df540] Failed to update header with correct duration.
[flv @ 0x23df540] Failed to update header with correct filesize.- Solution: update ffmpeg
- problem is present with:
- libavformat 56. 4.101
- it is not present with:
- libavformat 56. 25.101
- problem is present with:
- Solution: update ffmpeg
- [flv @ 0x23df540] Packets are not in
the proper order with respect to DTS
- Problems
- ffmpeg -re -f lavfi -i
"testsrc=size=1280x720:rate=24" -f lavfi -i
sine=f=220:b=1 -af "volume=0.1" -codec:a aac
-strict -2 -codec:v libx264 -preset ultrafast
-profile:v main -tune zerolatency -pix_fmt
yuv420p -g 48 -f flv rtmp://...
- Test
Streaming
With FFMPEG
- Specific formats
- Android
video
- Video
encoding
recommendations (Android Developers)
lower quality
higher quality
video
codec
H.264 baseline profile
H.264 baseline profile
resolution
176x144
480x360
frame rate
12 fps
30 fps
bitrate
56 Kbps
500 Kbps
audio
codec
AAC-LC
AAC-LC
channels
1
2
bitrate
24 Kbps
128 Kbps
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Converting Videos For The Android T-Mobile G1 Phone With Linux
- Encoding Video for Android (Broken links)
- PAL 16:9
to 480x320 ("-map 0:2" to use 2nd audio track) (DVD track extraction):
- ffmpeg -threads 4 [-ss seconds] -i toto.vob -map 0:0 -map 0:2 -s 480x270 -padtop 24 -padbottom 26 -vcodec libx264 -vpre superfast -vpre baseline -b 480k -acodec libvo_aacenc -ab 128k -async 2 -sameq -aspect 3:2 toto_android.mp4
- HD 1080i
to 480x320 ("-ac 2" to downmix to 2 audio channels):
- ffmpeg -threads 4 -i toto.MTS -s 480x270 -padtop 24 -padbottom 26 -vcodec libx264 -vpre superfast -vpre baseline -b 480k -acodec libvo_aacenc -ab 128k -ac 2 -r 25 -sameq -aspect 3:2 toto_android.mp4
- ffmpeg -aspect 3:2 -i inputfilename.ext -aspect 3:2 -s 480x320 -vcodec h264 -b 480k -r 23.976 -acodec aac -ab 96k -sameq -pass 1 outputfilename.mp4
- ffmpeg -aspect 4:3 -i inputfilename.ext -aspect 3:2 -s 400x300 -vcodec h264 -b 480k -r 23.976 -acodec aac -ab 96k -padtop 10 -padbottom 10 -padleft 40 -padright 40 -sameq -pass 1 outputfilename.mp4
- ffmpeg -aspect 16:9 -i inputfilename.ext -aspect 3:2 -s 480x270 -vcodec h264 -b 480k -r 23.976 -acodec aac -ab 96k -padtop 24 -padbottom 26 -sameq -pass 1 outputfilename.mp4
- Video
encoding
recommendations (Android Developers)
- HbbTV
video
- SD
- ffmpeg -i toto.mp4 -s 720x576 -aspect 16:9 -r 25 -vcodec libx264 -vpre fast -sameq toto-576.mp4
- HD
- ...
- SD
- TomPlayer
video
- ffmpeg -i toto.xxx -vcodec mpeg4 -b 700k -s 480x272 toto.avi
- iPhone video
- iPhone (Videolan)
- iPhone HTTP streaming
- video
transcoding recipes with ffmpeg
- ffmpeg -i input_file -f mp4 -vcodec mpeg4 -maxrate 1000k -b 700k -qmin 3 -qmax 5 -bufsize 4096k -g 300 -acodec libfaac -ab 192k -s 480x320 -aspect 4:3 output_file.mp4
- x264
encoding
guide
- --level 30 --profile baseline --vbv-bufsize 10000 --vbv-maxrate 10000
- iPod video
- iPod (Videolan)
- iPod
video
guide
- 1.5Mbit/s 640×480 H.264 videos
- ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -vpre slow -vpre ipod640 -b BIT_RATE -aspect WIDTH:HEIGHT -threads 0 -f ipod OUTPUT.mp4
- 768kbit/s 320×240 H.264 videos
- ffmpeg -i INPUT -acodec libfaac -ab 128k -s WIDTHxHEIGHT -vcodec libx264 -vpre slow -vpre ipod320 -b BIT_RATE -metdata "title=SOME_TITLE" -threads 0 -f ipod OUTPUT.mp4
- 1.5Mbit/s 640×480 H.264 videos
- commandline ffmpeg & x264 settings for Ipod 5.5
- (*): ffmpeg -i input.mp4 -f mpegts -acodec libmp3lame -ar 48000 -ab 64k -s 320x240 -vcodec libx264 -b 96k -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -subq 5 -trellis 1 -refs 1 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 200k -maxrate 96k -bufsize 96k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 320:240 -g 30 -async 2 output.ts
- ffmpeg -i <in file> -f mpegts -acodec
libmp3lame -ar 48000 -ab 64k -vcodec libx264 -s
320x240 -b 96k -bt 200k -maxrate 96k -bufsize 96k
-rc_eq 'blurCplx^(1-qComp)' -level 30 -aspect
320:240 -async
2 -vpre mobile <output file>
- libx264-mobile.ffpreset:
- flags=+loop
cmp=+chroma
partitions=+parti4×4+partp8×8+partb8×8
subq=5
trellis=1
refs=1
coder=0
me_range=16
keyint_min=25
sc_threshold=40
i_qfactor=0.71
qcomp=0.6
qmin=10
qmax=51
qdiff=4
g=30
- flags=+loop
- libx264-mobile.ffpreset:
- x264
encoding
guide
- --level 1.3 --no-cabac --vbv-bufsize 768 --vbv-maxrate 768
- PS3 video
- Conversion for Portivity
(60s starting at time 50)
- ffmpeg -ss 50 -t 60 -i sp.mxf -vcodec libx264 -s 320x240 -b 160k -r 12.5 -acodec libfaac -ab 32k sp.mp4
- [ffmpeg -ss 50 -t 60 -i sp.mxf -vcodec h264 -s 320x240 -b 160k -r 12.5 -acodec aac -ab 32k sp.mp4]
- MP4Box -hint sp.mp4 (to be streamed by Darwin server)
- To Samsung SVI (no
funciona...):
- ffmpeg -i toto.mp4 -f avi -s 208x176 -r 15 -vcodec xvid toto.svi
- Android
video
- Just copy the audio ES
- ffmpeg -acodec copy ...
- General (ts -> h264/MP4) (plf needed):
- ffmpeg -i toto.ts -vcodec {h264,libx264} -s 320x240 -r 15 -b 1000 -f mp4 toto.mp4
- Elementary streams
- From .m2v
(elementary stream) to .h264 (elementary stream):
- ffmpeg -i toto.m2v [-f h264] toto.h264
- From .mp2
(elementary stream) to AAC (elementary stream) (plf needed):
- ffmpeg -i toto.mp2 toto.aac
- From .m2v
(elementary stream) to .h264 (elementary stream):
- YUV
- From .yuv video
file (-s must be the first parameter):
- ffmpeg -s 704x576 -i toto_704x576.yuv -f mp4 -vcodec {h264,libx264} toto.mp4
- ffmpeg -s 720x576 -i 576i25_shields_ter.yuv -target pal-dvd -aspect 16:9 576i25_shields_ter.vob
- ffmpeg -s 1280x720 -r 50 -i 720p50_shields_ter.yuv -target pal-dvd -aspect 16:9 720p50_shields_ter.vob
- To .yuv video
file:
- ffmpeg -i toto.mp4 toto.yuv
- From .yuv video
file (-s must be the first parameter):
- Video codecs
- MPEG-4
SP (simple profile):
- ffmpeg ... -profile 0...
- To force MPEG-4 ASP (advanced
simple profile):
- ffmpeg ... -profile 15...
- To specify H.264 level:
- ffmpeg ... -[v]level 30 ... (level 3.0)
- To specify video profile (prefer -profile:v instead of -vprofile):
-
-profile:v MPEG-4 H.264 (libx264) 0, 16 Simple Baseline 1, 17 Simple Scalable Baseline 2 Core Baseline 3 Unknown Profile(49)
4 Unknown Profile(65
5 Scalable Texture
6 Simple Face Anim
7 Basic Anim Text
8 Hybrid
9 Adv RT Simple
10 Core Scalable
11 Adv Coding Efficieny
12 Adv Core Profile
13 Adv Scalable Texture
14 Simple Studio
15 Adv Simple
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- AVCHD
to AVI (AVS
forum)
- FFmpeg Tutorial: Convert MTS/M2TS(AVCHD) to AVI
- % xport -h sample.m2ts 1 1 1
% mv bits0001.mpa sample.ac3
% mkfifo pipe.yuv
% ldecod -i bits0001.mpv -o pipe.yuv &
% ffmpeg -r 29.97 -s 1440x1080 -i pipe.yuv -i /tmp/sample.ac3 -acodec copy -vcodec mpeg4 -aspect 16:9 -b 15000k sample.avi
% rm pipe.yuv
- GIF animat / Animated GIF
- MPEG-4
SP (simple profile):
- I-frames only
- fmpeg ... -intra ...
- B-frames
ffmpeg ... -bf number ...- No B-frames
ffmpeg ... -bf 0 ...
- image
-> video
- Timelapse / Stop
motion
- Subsample image file names
- cp ranges
- From several
jpeg or png files:
- Create a video slideshow from images
- Reproducció / Play
- ffplay -framerate 50 -start_number 150 -i DSC%05d.JPG
- Creació de vídeo / Video creation
- to 1280x720@8fps:
- ffmpeg -y -start_number 767 -r 8 -i DSC%05d.JPG -vf 'pad=max(iw\,ih*16/9):ow*9/16:(ow-iw)/2:(oh-ih)/2, scale=1280:-1' -c:v libx264 -f mp4 toto_8fps.mp4
- ffmpeg -start_number 150 -i DSC%05d.JPG -c:v libx264 -f mp4 toto.mp4
- ffmpeg -r 5 -start_number 150 -i DSC%05d.JPG -vf scale=1280:-1 -c:v libx264 -f mp4 toto.mp4
- ffmpeg -r 15 -start_number 150 -i toto%02d.png -f mp4 -vcodec {h264,libx264} toto.mp4
- to 1280x720@8fps:
- From all png files in a dir (globbing):
- ffmpeg ... -pattern_type glob -i 'foo-*.jpeg' ...
- Smooth
- ffmpeg convert a series of images to video - with crossfade or any other transition between every two frames
- blend filter
- ffmpeg -i {input} -vf "tblend=average,framestep=2,setpts=0.50*PTS" -r {srcfps} -{encoding parameters} {output}
- Butterflow
- From video
- ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" -an output.mp4
- Make a Video File from a Single
Frame:
- ffmpeg -loop_input -vframes <number_of_frames> -i <input_file> <output_file>
- Carta
d'ajust / Test card
- ffmpeg -loop 1 -i toto.png -f lavfi -i "sine=frequency=440:sample_rate=48000,aformat=channel_layouts=stereo" -vf "setdar=dar=16/9" -t 10 -pix_fmt yuv420p -c:v h264 -c:a aac toto_169.mp4
- ffmpeg -loop 1 -i PM5544_with_non-PAL_signals.png -f lavfi -i "sine=frequency=440:sample_rate=48000,aformat=channel_layouts=stereo" -filter:v "scale=w=720:h=576,setdar=dar=4/3" -t 10 -pix_fmt yuv420p -c:v h264 -c:a aac pm5544.mp4
- ffmpeg -loop 1 -i Philips_Pattern_pm5644.png -f lavfi -i "sine=frequency=440:sample_rate=48000,aformat=channel_layouts=stereo" -filter:v "scale=w=720:h=576,setdar=dar=16/9" -t 10 -pix_fmt yuv420p -c:v h264 -c:a aac pm5644.mp4
- ffmpeg -loop_input -vframes 250 -i bars_grey.bmp -vcodec mpeg2video bars_grey.mpeg
- From raw (c-generated)
rgb images:
- tvTestPattern > f.raw
- ffmpeg -f rawvideo -pix_fmt rgb24 -s 720x576 -aspect 4:3 -i f.raw -f s16le -ac 2 -i /dev/zero -shortest -target dvd -b 4000 -ab 128 -ildct -ilme -y interlace_test2.mpeg
- From raw UYVY 4:2:2
images:
- ffmpeg -loop_input -f rawvideo -pix_fmt uyvy422 -s
720x576 -aspect 4:3 -i mostra.uyvy -f s16le -ac 2 -i
<(dd if=/dev/zero bs=19200 count=1) -target
pal-dvd toto.mpeg
- ffplay toto.mpeg (durada infinita!) (de fet, es pot fer directament: ffplay -s 720x576 -f rawvideo -pix_fmt uyvy422 -i toto.uyvy)
- ffmpeg -loop_input -f rawvideo -pix_fmt uyvy422 -s
720x576 -aspect 4:3 -i mostra.uyvy -f s16le -ac 2 -i
<(dd if=/dev/zero bs=19200 count=1) -target
pal-dvd toto.mpeg
- mpeg animation
(eg for DVD menus) from a single image (*):
- ffmpeg -loop_input -t 1.0 -i stillframename -ar 48000 -f s16le -i <(dd if=/dev/zero bs=19200 count=1) -target pal-dvd outputmoviename
- Timelapse / Stop
motion
- video -> images
(thumbnails)
- WebP
- libwebp
- Compilació / Compilation
- Ús / Usage
- Convert MP4 file to animated WEBP file in ffmpeg CLI
ffmpeg -i input.mp4 -vcodec libwebp -filter:v fps=fps=2 -loop 1 -an -vsync 0 -s 128:72 output.webp
- Extract only (-vframes 1 or -t 00:00:00:01) the
5th frame of second 20 (-ss
00:00:20:05), from file into a jpeg image
(thumbnail) (*)
(-ss before -i is much faster):
- ffmpeg -ss 00:00:20:05 -i toto.mp4 -vframes 1 -f mjpeg toto.jpeg
- ffmpeg -ss 00:00:20:05 -i toto.mp4 -vframes 1 -f singlejpeg -s 150x100 toto.jpeg (maybe singlejpeg is not supported)
- ffmpegthumbnailer
- Extract all frames from file into several
jpeg
files (implicit image2
format):
- ffmpeg -i toto.mp4 toto%d.jpeg
- Extract one frame every 1 second (-r 1) to several jpeg images:
- Multiple
thumbnails:
- ffmpeg -ss $i*$interval -i intro.mov -vframes 1 -s 320x240 thumb_$i.jpg
- thumb.sh (allows output name of type
img_<position_in_seconds>s.jpeg)
- #!/bin/bash
input=$1
interval=$2
# output dimensions (aspect ratio will be preserved)
out_width=320
out_height=240
# video duration
duration=$(ffprobe -i $input -show_format -v quiet | sed -n 's/duration=//p')
duration_int=${duration%\.*}
echo "duration: $duration"
position=0
while (( position < duration_int ))
do
position_name=$(printf "%06d" $position)
echo $position_name
ffmpeg -v 0 -ss $position -i $input -vframes 1 -vf scale=w=${out_width}:h=${out_height}:force_original_aspect_ratio=decrease img_${position_name}s.jpeg
(( position=position+interval ))
done
- #!/bin/bash
- ffmpeg-php
- Generating Video Thumbnail Storyboards
- Making thumbnails for movies with ffmpeg
- WebP
- Crop
- part central del vídeo, amb relació 4:3
- ffplay sintel-1024-stereo.mp4 -vf 'crop=ih*4/3:ih'
- part central del vídeo, amb relació 4:3
- Relació
d'aspecte / Aspect ratio
-
input image output image satisfy only one destination dimension
satisfy both destination dimensions
width height inscribe excribe adapted pad
- -vf "scale=${width}:-1"
- # force height to be multiple of 2
-vf "scale=${width}:-2"
- -vf "scale=-1:${height}"
- # force width to be multiple of 2
-vf "scale=-2:${width}"
- -vf "scale=${width}:${height}:force_original_aspect_ratio=decrease"
- # force dimensions to be multiple of 2
(using pad)
-vf "scale=${width}:${height}:force_original_aspect_ratio=decrease, pad='iw+mod(iw\,2)':'ih+mod(ih\,2)'" - # force dimensions to be multiple of 2 (a
recent version of ffmpeg is needed)
-vf "scale=${width}:${height}:force_original_aspect_ratio=decrease:force_divisible_by=2"
-vf "scale=${width}:${height}:force_original_aspect_ratio=increase" -vf "scale=${width}:${height}" - this is the most generic solution to automatically add pillarbox or letterbox
- first, we calculate the video region
- min is used to allow pillarbox or letterbox
- dar must be taken into account
- output dar must be calculated offline, because ffmpeg does not do it (only for input dar)
- ...
- then we put the video on centre and pad it
with black
- pad=${out_width}:${out_height}:-1:-1
- out_width=720
out_height=576
out_dar="4:3"
out_dar_bar=${out_dar//:/\/}
out_dar_float=$(echo "${out_dar_bar}" | bc -l)
ffmpeg -y -v verbose -i ${input} -vf "scale=min(${out_width}\,trunc(${out_width}*dar/${out_dar_float}+0.5)):min(${out_height}\,trunc(${out_height}*${out_dar_float}/dar+0.5)), pad=${out_width}:${out_height}:-1:-1" ${output}
PAL
720x576, 4:3768x576 4:3 -vf "scale=768:-1"
-> 768x614, 4:3
(ok, but too high)
-vf "scale=-1:576"
-> 720x576, 4:3 (ok)
-vf "scale=768:576:force_original_aspect_ratio=decrease"
-> 720x576, 4:3 (ok)
-vf "scale=768:576:force_original_aspect_ratio=increase"
-> 768x614, 4:3 (ok, but too high)
-vf "scale=768:576"
-> 768x576, 4:3 (ok)
1024x576
16:9
PAL anamorphic
720x576, 16:9
- -vf "scale=540:576,
pad=720:576:-1:-1"
-> 720x576, 16:9
1280x720 16:9 -vf "scale=1280:-1"
-> 1280x1024, 4:3
(ok, but too high)
-vf "scale=-1:720"
-> 900x720, 4:3 (ok)
-vf "scale=1280:720:force_original_aspect_ratio=decrease"
-> 900x720, 4:3 (ok)-vf "scale=1280:720:force_original_aspect_ratio=increase"
-> 1280*1024, 4:3 (ok, but too high)
PAL anamorphic
720x576, 16:91024x576 16:9
-vf "scale=1024:576:force_original_aspect_ratio=decrease"
-> 720x576, 16:9 (ok, still anamorphic)
-vf "scale=1024:576"
-> 1024x576, 16:9 (ok)
PAL
720x576, 4:3
1280x720 16:9 -vf "scale=1280:-1"
-> 1280x1024, 4:3
(ok, but too high)-vf "scale=-1:720"
-> 900x720, 16:9 (ok, still anamorphic)-vf "scale=1280:720:force_original_aspect_ratio=decrease"
-> 900x720, 16:9 (ok, still anamorphic)
1280x720, 16:9 PAL
720x576, 4:3
1280x720, 16:9 PAL anamorphic
720x576, 16:9
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Variables
-
input description output in_w
iwwidth out_w
owin_h
ihheight out_h
oha = (iw/ih) relation
sar sample aspect ratio
dar = (iw/ih)*sar display aspect ratio
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- vegeu pad amb libav / see simplified pad with libav
- scale
filter preserving aspect ratio:
- "The scale filter forces the output display aspect ratio to be the same of the input, by changing the output sample aspect ratio."
- force width:
- ffmpeg ... -vf scale=320:-1...
- force width, but height has to be multiple of n=2
(n can be any value):
- ffmpeg ... -vf scale=320:-2...
- inscribe into a maximum rectangle (*):
- Resizing videos with ffmpeg/avconv to fit into static sized player
- ffmpeg ... -vf "scale=w=854:h=480:force_original_aspect_ratio=decrease"
...
- to force multiple of n (a recent version
of ffmpeg is needed):
- ... -vf "scale=320:h=180:force_original_aspect_ratio=decrease:force_divisible_by=2" ...
- to force multiple of 2 using pad:
- ... -vf "scale=320:h=180:force_original_aspect_ratio=decrease, pad='iw+mod(iw\,2)':'ih+mod(ih\,2)'" ...
- to force output aspect (
setdar=dar) to the same as input aspect (=dar):- ... setdar=dar=dar:max=16 ...
- complete example:
- ffmpeg -y -f lavfi -i
"testsrc=duration=10:size=720x576,
format=pix_fmts=yuv420p" -f lavfi -i
anoisesrc=duration=10:colour=pink:amplitude=0.5
-ac 2 -aspect 4:3 vídeo_43.mp4
ffmpeg -i vídeo_43.mp4 -vf "scale=320:h=180:force_original_aspect_ratio=decrease, pad='iw+mod(iw\,2)':'ih+mod(ih\,2)', setdar=dar=dar:max=16" -c:a copy video_43_petit.mp4
- ffmpeg -y -f lavfi -i
"testsrc=duration=10:size=720x576,
format=pix_fmts=yuv420p" -f lavfi -i
anoisesrc=duration=10:colour=pink:amplitude=0.5
-ac 2 -aspect 4:3 vídeo_43.mp4
- to force multiple of n (a recent version
of ffmpeg is needed):
- ffmpeg -y -f lavfi -i
"testsrc=duration=10:size=720x576,
format=pix_fmts=yuv420p" -f lavfi -i
anoisesrc=duration=10:colour=pink:amplitude=0.5
-ac 2 -aspect 16:9 vídeo_169.mp4
ffmpeg -i vídeo_169.mp4 -vf "scale=320:h=180:force_original_aspect_ratio=decrease, pad='iw+mod(iw\,2)':'ih+mod(ih\,2)', setdar=dar=dar:max=16" -c:a copy video_169_petit.mp4 - ffmpeg ... -vf scale='ceil(min(1\,min(854/iw\,480/ih))*iw):-2' ...
- ffmpeg ... -vf scale='-2:ceil(min(1\,min(854/iw\,480/ih))*ih)' ...
- excribe around a minimum rectangle:
- ffmpeg ... -vf scale=w=854:h=480:force_original_aspect_ratio=increase ...
- # pad
the input to get a final w/h ratio of 16:9
pad="ih*16/9:ih:(ow-iw)/2:(oh-ih)/2" - resize (1920x1080 16:9 -> 720x576 16:9
anamorphic) and transcode (H.264, AAC):
- avconv -threads auto -i toto.MTS -filter:v "scale=w=720:h=576,setdar=dar=16/9" -strict experimental toto.mp4
- resize from 1280x544 (2,35)
- to SD 4:3 (with letterbox)
- ffplay -i sintel-1280-surround.mp4 -vf 'pad=width=iw:height=iw*3/4:x=0:y=(oh-ih)/2, scale=w=720:h=576, setdar=dar=4/3'
- ffmpeg -i sintel-1280-surround.mp4 -vf 'pad=width=iw:height=iw*3/4:x=0:y=(oh-ih)/2, scale=w=720:h=576, setdar=dar=4/3' -c:v mpeg2video -an sintel_pad_4\:3_v2.mp4
- to HD 16:9 (with letterbox)
- ffplay -i sintel-1280-surround.mp4 -vf 'pad=width=iw:height=iw*9/16:x=0:y=(oh-ih)/2'
- to SD 16:9 anamorphic (with letterbox)
- ffplay -i sintel-1280-surround.mp4 -vf 'pad=width=iw:height=iw*9/16:x=0:y=(oh-ih)/2, scale=w=720:h=576, setdar=dar=16/9'
- ffmpeg -i sintel-1280-surround.mp4 -vf 'pad=width=iw:height=iw*9/16:x=0:y=(oh-ih)/2, scale=w=720:h=576, setdar=dar=16/9' -c:v libx264 -an sintel_pad_16:9.mp4
- to SD 4:3 (with letterbox)
- ...
- pad
video filter
- output sar is the same as input sar; dar may change according to this
- qualsevol relació d'aspecte d'entrada, cap a
sortida en 16:9
- ffplay sintel-1024-stereo.mp4 -vf 'pad=max(iw\,ih*16/9):ow*9/16:(ow-iw)/2:(oh-ih)/2'
- ...
- center
- ... pad=1280:720:-1:-1
- From anamorphic
(active: 720x576) to letterbox (ETSI
300
294) (active: 720x432 (720/16*9 *
4/3/(720/576)=432); horizontal bars: (576-432)/2=72
heigth each) (padcolor will usually be black 000000)
(sameq to have the same bitrate as the input):
- ffmpeg ... -s 720x432 -padtop 72 -padbottom 72 -padcolor 00ff00 -sameq -aspect 4:3 ...
- ...
4:3
14:9
16:9
720x576 768x576 720x576 896x576 720x576 1024x576 1280x720 1920x1080 3840x2160 dar size sar name create with ffmpeg 16:15 1:1 56:45 1:1 64:45 1:1 1:1 1:1 1:1 4:3 720x576 16:15 PAL -f lavfi -i "testsrc=duration=10:size=720x576, format=pix_fmts=yuv420p" -aspect 4:3 video_720x576_43.mp4
768x576 1:1
-f lavfi -i "testsrc=duration=10:size=768x576, format=pix_fmts=yuv420p" video_768x576_43.mp4
14:9 720x576 56:45 PAL 14:9 -f lavfi -i "testsrc=duration=10:size=720x576, format=pix_fmts=yuv420p" -aspect 14:9 video_720x576_149.mp4
896x576 1:1
-f lavfi -i "testsrc=duration=10:size=896x576, format=pix_fmts=yuv420p" video_896x576_149.mp4
16:9 720x576 64:45 PAL anamorphic -f lavfi -i "testsrc=duration=10:size=720x576, format=pix_fmts=yuv420p" -aspect 16:9 video_720x576_169.mp4
1024x576 1:1
-f lavfi -i "testsrc=duration=10:size=1024x576, format=pix_fmts=yuv420p" video_1024x576_169.mp4
1280x720 1:1 720 -f lavfi -i "testsrc=duration=10:size=1280x720, format=pix_fmts=yuv420p" video_1280x720_169.mp4
1920x1080 1:1 1080 -f lavfi -i "testsrc=duration=10:size=1920x1080, format=pix_fmts=yuv420p" video_1920x1080_169.mp4
3840x2160 1:1 4K, UHD -f lavfi -i "testsrc=duration=10:size=3840x2160, format=pix_fmts=yuv420p" video_3840x2160_169.mp4
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
4:3
16:9
720x576 720x576 4:3
720x576
-
- -vf "scale=540:576, pad=720:576:-1:-1"
- -s 540x576 -padleft 90 -padright 90 -aspect 16:9
768x576
-s 720x576
-aspect 4:314:9
720x576
-s 720x492
-padtop 42 -padbottom 42
-aspect 4:3
- -vf "scale=630:576, pad=720:576:-1:-1"
- -s 630x576 -padleft 44 -padright 46 -aspect 16:9
896x576
16:9
720x576
-s 720x432
-padtop 72 -padbottom 72
-aspect 4:3-
1024x576
- -vf "scale=720:576"
- -s 720x576 -aspect 16:9
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
NOTE: scale preserves dar; pad preserves sar
4:3 16:9 dar
sar 720x576 (out_sar=16/15) 720x576 (out_sar=64/45) 4:3 720x576 16:15 - - -vf "scale=540:576, pad=720:576:-1:-1"
768x576 1:1 - -vf "scale=720:576"
- -s 720x576 -aspect 4:3
14:9 720x576 56:45
- -vf "scale=..."
- -s 720x492 -padtop 42 -padbottom 42 -aspect 4:3
- -vf "scale=630:576, pad=720:576:-1:-1"
896x576 1:1 16:9 720x576 64:45 - -vf "..."
- -s 720x432 -padtop 72 -padbottom 72 -aspect 4:3
- 1024x576 1:1 - -vf "scale=720:576"
- -s 720x576 -aspect 16:9
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Parameter calculation:
- intermediate_width = in_width * (in_sar) /
(out_sar) * out_height / in_height = in_dar /
out_dar * out_width
- examples:
- 720 * (16/15) / (64/45) = 540
- 720 * (56/45) / (64/45) = 630
- examples:
- intermediate_height = in_height * (out_sar) /
(in_sar) * out_width / in_width = out_dar / in_dar *
out_height
- examples:
- ...
- examples:
- intermediate_width = in_width * (in_sar) /
(out_sar) * out_height / in_height = in_dar /
out_dar * out_width
- Càlculs / Calculations (aspecte.ods, aspecte.c):
- Input image
- Wi: given input image width
- Hi: given input image height
- DARi: given input display aspect ratio
- input anamorphic factor: Di = DARi / (Wi/Hi)
- Output image
- Wo: given output image width
- Ho: given output image height
- DARo: given output display aspect ratio
- output anamorphic factor: Do = DARo / (Wo/Ho)
- W'o: calculated output active image width
- H'o: calculated output active image height
- LR: calculated total number of pixels at sides (LR/2 at each side)
- TB: calculated total number of pixels at top and bottom (TB/2 at each zone)
- Pillar box (if calculated LR
gives >0)
- W'o=Wi * Di/Do * Ho/Hi
- H'o=Ho
- LR=Wo - W'o
- Letter box (if calculated TB
gives >0)
- W'o=Wo
- H'o=Hi * Do/Di * Wo/Wi
- TB=Ho - H'o
- Input image
-
- Rotació / Rotation
- Tall / Cut
- Info
- Other tools, based on ffmpeg
- -t <duration>
- -to <position>
- -accurate_seek
- Obté un tall de 10 segons a partir de la posició
00:02:00.0
ffmpeg -ss 00:02:00.0 -t 00:00:10.0 -i toto.mp4 -c copy tall_00:02:00.0-00:02:10.0.mp4ffmpeg -ss 00:02:00.0 -i toto.mp4 -t 00:00:10.0 -c copy tall_00:02:00.0-00:02:10.0.mp4
- Obté un tall que va dels 00:02:00.0 als 00:02:20.0
ffmpeg -ss 00:02:00.0 -to 00:02:20.0 -i toto.mp4 -c copy tall_00:02:00.0-00:02:20.0.mp4- If you put -to option after -i option, you will get a file with duration 00:02:20.0, as -to position will be referred to the output
- Problemes / Problems
- Using
ffmpeg to trim HEVC video: correct duration, but
output file size too large
- trim position in ASCII art
- when using -c copy (e.g. from SRT)
tag xxxx incompatible with output codec yyyy- because input has:
Stream ... Video: h264 (High) (xxxx / xxxx_in_hex), ...- Exemple:
Stream #0:0[0x41]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(tv, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn
- Solució / Solution
- video
-tag:v yyyy- Exemple:
tag HDMV incompatible with output codec avc1
- input:
Stream #0:0[0x41]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(tv, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 90k tbn - you must add:
-tag:v avc1
- audio
-tag:a yyyy
- Exemple / Example:
-tag:v avc1 -tag:a mp4a
- video
- because input has:
- Using
ffmpeg to trim HEVC video: correct duration, but
output file size too large
- trim
/ atrim
- ...
- Problemes
- ...
- select / aselect
- ...
- Entrellaçat / Interlaced
- Extracció / Extraction
- Transport stream
- Extract only video
track
- ffmpeg -i toto.vob -an -vcodec copy toto.m2v
- Extract only audio
(vn: no video) track:
- ffmpeg -i toto.mxf -vn -acodec copy toto.mp2
- ffmpeg -i toto.vob -map 0:3 -vn -acodec copy toto.wav
- Extract only subtitles track:
- ffmpeg -i toto.mov -vn -an -scodec copy toto.srt
- ffmpeg -i toto.mov -map s:0 -vn -an -c:s copy toto2.srt
- extract the second subtitles track from program
801 in a TS:
- ffmpeg -i toto.ts ...
- extract the cat dvb subtitles (in bold) from a SP
TS file:
- ffmpeg -i 120208_2318\(33\).ts
Program 802
Metadata:
service_name : ?33
service_provider: ?TVC
Stream #0:0[0x79]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 720x576 [SAR 64:45 DAR 16:9], 15000 kb/s, 26.94 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0:1[0x7a](cat): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16, 160 kb/s
Stream #0:2[0x7c](v.o): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16, 96 kb/s
Stream #0:3[0x7e](a.d): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, mono, s16, 96 kb/s
Stream #0:4[0x85](cat): Subtitle: dvb_teletext ([6][0][0][0] / 0x0006)
Stream #0:5[0x322](cat): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:6[0x32e](eng): Subtitle: dvb_subtitle ([6][0][0][0] / 0x0006)
Stream #0:7[0x386]: Unknown: none ([5][0][0][0] / 0x0005)
Stream #0:8[0x259]: Unknown: none ([12][0][0][0] / 0x000C) - ffmpeg -i 120208_2318\(33\).ts -map 0:5 -vn -an -scodec copy toto.srt
- ffmpeg -i 120208_2318\(33\).ts -map 0:5 -vn -an -scodec copy -f rawvideo dvbsub.dat (*)
- ffmpeg -i 794_20121105_0026.ts -map 0:8 -vn -an -scodec copy -copyinkf -f srt dvbsub.srt (*)
- ffmpeg -i 120208_2318\(33\).ts
- [Ffmpeg-user]
encode
multiple audio tracks to a single output file
- ffmpeg -i toto.vob -map 0:0 -map 0:1 -map 0:2 -acodec copy -vcodec copy toto_multi.vob -acodec copy -newaudio
- Multiangle
generation:
- ffmpeg -i toto1.m2v -i toto2.m2v -vcodec copy toto.vob -vcodec copy -newvideo
- Convert from VOB
to TS:
- ffmpeg -i toto.vob -sameq -acodec copy toto.ts
- Multiplex ES:
- ffmpeg -i toto.h264 -i toto.aac -vcodec copy -acodec copy toto.mp4
- Àudio / Audio
- Multilanguage
- HLS
- genera un fitxer amb dos àudios replicant un sol
àudio:
ffmpeg \
-f lavfi -i "testsrc=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-map 0:v \
-map 1:a -map 1:a \
multilang.mp4- amb metadades (
-metadata) de llengua (ISO 639-2: 3 caràcters) per als àudios:ffmpeg \
-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10.0:colour=pink:amplitude=0.5:sample_rate=48000" \, aformat=channel_layouts=stereo
-map 0:v \
-map 1:a -map 1:a \
-metadata:s:a:0 language=cat -metadata:s:a:0 title="Primer àudio" \
-metadata:s:a:1 language=eng -metadata:s:a:1 title="Segon àudio" \
multilang.mp4- àudios i subtítols
- create_multilang.sh
- #!/bin/bash
number_langs=$1;
function create_map_opts {
num=0;
for i in $(seq 0 25);
do second_char=$(printf \\$(printf '%03o' $[97+$i]) | tr -d '\n');
for f in $(seq 0 25);
do third_char=$(printf \\$(printf '%03o' $[97+$f]) | tr -d '\n');
map_opts+=(-map 1:a)
map_opts+=(-metadata:s:a:${num} language=q${second_char}${third_char})
map_opts+=(-metadata:s:a:${num} title="Audio number ${num}")
(( num+=1 ));
if (( num>=number_langs ))
then
return;
fi;
done;
done;
}
map_opts=()
create_map_opts
ffmpeg \
-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10.0:colour=pink:amplitude=0.5:sample_rate=48000, aformat=channel_layouts=stereo" \
-map 0:v \
"${map_opts[@]}" \
multilang.mp4
exit
- #!/bin/bash
- a partir de dos àudios diferents:
ffmpeg \
-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=10.0:colour=pink:amplitude=0.5:sample_rate=48000" \, aformat=channel_layouts=stereo
-f lavfi -i "sine=-map 0:v \duration=10.0:frequency=500:sample_rate=480000, aformat=channel_layouts=stereo" \
-map 1:a -map 2:a \
-metadata:s:a:0 language=cat -metadata:s:a:0 title="Primer àudio" \
-metadata:s:a:1 language=eng -metadata:s:a:1 title="Segon àudio" \
multilang.mp4
- redimensiona el vídeo d'un fitxer que conté un
(o més) vídeo, diversos àudios i diversos
subtítols:
- ffmpeg -i toto_2_4.mp4 -map 0 -vf scale=w=1280:h=720 -c:a copy -c:s copy multi_720p.mp4
- ffmpeg
-i toto_2_4.mp4 -map 0 -vf
scale=w=1280:h=720 -c:a copy -c:s copy
multi_720p.mp4 \
-map 0 -vf scale=w=128:h=72 -c:a copy -c:s copy multi_72p.mp4 - ffmpeg -i toto_1_4.mp4 -filter_complex "[0:v]scale=1280:720[v0]" -map '[v0]' -c:v h264 -map 0:a -c:a copy -map 0:s -c:s copy toto_720.mp4
- genera un fitxer amb 2 vídeos (llengua de signes
catalana, llengua de signes valenciana) i 3 àudios
(replicant el mateix àudio: català, anglès,
francès):
ffmpeg \
-f lavfi -i "testsrc=duration=10:size=640x360, format=pix_fmts=yuv420p" \-f lavfi -i "testsrc2=duration=10:size=640x360, format=pix_fmts=yuv420p" \-f lavfi -i "anoisesrc=duration=10.0:colour=pink:amplitude=0.5:sample_rate=48000" \, aformat=channel_layouts=stereo
-map 0:v -map 1:v \
-map 2:a -map 2:a -map 2:a \-metadata:s:v:0 language=csc-metadata:s:v:0 title="Primer vídeo" \-metadata:s:v:1language=vsv-metadata:s:a:0 language=cat -metadata:s:a:0 title="Primer àudio" \title="Segon vídeo" \-metadata:s:v:1
-metadata:s:a:1 language=eng -metadata:s:a:1 title="Segon àudio" \
-metadata:s:a:2 language=fra -metadata:s:a:2 title="Tercer àudio" \multilang.mp4
- Multicanal / Multichannel
- Manipulating audio channels
- 2.8 Channel layout
- Text to speech
flite -v -voice slt -t "left channel" FL.wav
- Dolby ProLogic II
- How to determine if an audio track is a Dolby Pro Logic II mixdown
- Create test 7.1, 5.1 and Pro Logic II audio/video files
ffmpeg -i toto_multichannel.mp4 -c:a flac -af "aresample=matrix_encoding=dplii" -ac 2 toto_dplii.flac
- listen stereo from channels 0 and 1:
ffmpeg -filter:a "pan=stereo|c0=c0|c1=c1" -f wav - | ffplay -
- listen stereo from channels 2 and 3:
ffmpeg -filter:a "pan=stereo|c0=c2|c1=c3" -f wav - | ffplay -
- extract single channel from 4.0 audio:
ffmpeg -i toto.mp4 -filter:a "pan=mono|c0=c0" c0.mp4ffmpeg -i toto.mp4 -filter:a "pan=mono|c0=c0" -f wav - | ffplay -ffmpeg -i toto.mp4 -filter:a "pan=mono|c0=c1" c1.mp4ffmpeg -i toto.mp4 -filter:a "pan=mono|c0=c2" c2.mp4ffmpeg -i toto.mp4 -filter:a "pan=mono|c0=c3" c3.mp4
- two mono audios in a stereo track (and a video
stream)
ffmpeg \
-f lavfi -i "pal75bars=duration=2.0:size=640x360:r=25/1, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-c:v h264 \
-filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo[a]" \
-c:a aac \
-map 0:v -map "[a]" \
video_stereo.mp4ffmpeg \
-f lavfi -i "pal75bars=duration=2.0:size=640x360:r=25/1, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-c:v h264 \
-filter_complex "[1:a][1:a]join=inputs=2:channel_layout=stereo[a]" \
-c:a aac \
-map 0:v -map "[a]" \
video_stereo.mp4
- one mono audio on left channel, silence on right
channel:
ffmpeg \
-f lavfi -i "pal75bars=duration=2.0:size=640x360:r=25/1, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anullsrc=duration=2.0:sample_rate=48000:channel_layout=mono" \
-c:v h264 \
-filter_complex "[1:a][2:a]join=inputs=2:channel_layout=stereo[a]" -c:a aac \
-map 0:v -map "[a]" \
video_stereo.mp4
- six mono audios in a 5.1 track (and a video
stream)
ffmpeg \
-f lavfi -i "pal75bars=duration=2.0:size=640x360:r=25/1, format=pix_fmts=yuv420p" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-c:v h264 \
-filter_complex "[1:a][2:a][3:a][4:a][5:a][6:a]join=inputs=6:channel_layout=5.1[a]" \
-c:a aac \
-map 0:v -map "[a]" \
video_5_1.mp4ffmpeg \
-f lavfi -i "pal75bars=duration=2.0:size=640x360:r=25/1, format=pix_fmts=yuv420p" \-f lavfi -i "anoisesrc=duration=2.0:colour=pink:amplitude=0.5:sample_rate=48000" \
-c:v h264 \
-filter_complex "[1:a][1:a][1:a][1:a][1:a][1:a]join=inputs=6:channel_layout=5.1[a]" \
-c:a aac \
-map 0:v -map "[a]" \
video_5_1.mp4
- Mesures / Measurements
- altres
- ebur128
- volumedetect
- general levels
ffmpeg -hide_banner -i toto.mp4 -filter:a "volumedetect" -f null /dev/null
- levels only from left channel
ffmpeg -hide_banner -i toto.mp4 -filter:a "pan=mono|c0=FL,volumedetect" -f null /dev/nullmean_volume=$(ffmpeg -hide_banner -i toto.mp4 -filter:a "pan=mono|c0=FL,volumedetect" -f null /dev/n2>&1 | awk '/mean_volume/ {print $5}')
- levels only from right channel
ffmpeg -hide_banner -i toto.mp4 -filter:a "pan=mono|c0=FR,volumedetect" -f null /dev/null
- general levels
- ...
- VU-meter
ffmpeg -hide_banner -i toto.mp4 -filter_complex "showvolume=rate=30:f=0.95:o=h:m=p:dm=1:h=60:w=480:ds=log:s=2" -c:v libx264 -c:a aac -f mpegts - | ffplay -window_title "Peak Volume" -i -
- Multilanguage
- Sincronització
àudio/vídeo / Audio/video synchronisation
- aresample
async
(audio
filter)
- FFmpeg Resampler Documentation
- "Setting this to 1 will enable filling and
trimming"
ffmpeg ... -af aresample=async=1 ...
- Fixing out-of-sync audio and video with ffmpeg
-itsoffset
- aresample
async
(audio
filter)
- Subtítols / Subtitles
- llista de còdecs de subtítols suportats / list of
supported subtitle codecs:
ffmpeg -codecs | grep "^...S"
- extract subtitles
- inclusió de subtítols / include
subtitles
- els colors per a diferents personatges es mantenen
/ colours for different characters in webvtt
subtitles are preserved:
ffmpeg -i input.mp4 -i subtitles.ca.vtt -c copy -metadata:s:s:0 language=cat ouptut_cat.mkv
- els colors per a diferents personatges no es
mantenen / colours for different characters in
webvtt subtitles are not preserved:
ffmpeg -i input.p4 -i subtitles.ca.vtt -c copy -c:s mov_text -metadata:s:s:0 language=cat ouptut_cat.mp4
- els colors per a diferents personatges es mantenen
/ colours for different characters in webvtt
subtitles are preserved:
- delay and hardcode (using -filter_complex)
subtitles:
ffmpeg -i input.ts -filter_complex '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' -sn -map '#0x2dc' output.mkv
- Subtitle manipulation tools for Linux
- llista de còdecs de subtítols suportats / list of
supported subtitle codecs:
- Metadades
/ Metadata
- FFmpeg Metadata
- get metadata
- ffprobe -i toto.mp4 -show_format -v quiet | grep TAG
- get creation_time:
- creation_time=$(ffprobe -i toto.mp4 -show_format -v quiet | sed -n 's/TAG:creation_time=//p')
- midentify (mplayer)
- x from 0 to ID_CLIP_INFO_N:
- ID_CLIP_INFO_NAMEx = ID_CLIP_INFO_VALUEx
- Now playing... para mplayer (bash shell to extract metadata, xosd)
- x from 0 to ID_CLIP_INFO_N:
- set metadata
- ffmpeg -i toto.mov -metadata title="Title of videoclip" ... -acodec copy -vcodec copy toto_metadata.mov
- art cover
- How to Add Album Art Cover to Audio Files Using the Command Line (lame, ffmpeg, eyeD3, mid3v2, metaflac)
- copy metadata
- ffmpeg -i toto.mp4 -map_metadata 0 -c copy toto_out.mp4
- Bug
- Supplying FFmpeg With Metadata
- Atomic Parsley (MPEG-4)
- How to create and use Flash video metadata to add cue-points with flvtool2
- Editing video metadata
- Adobe XMP metadata (wp)
-
mminfo
QT/MOV/MP4
AVI
Matroska
MP3
MP4
MPEG TS
NUT
Realmedia
SDP
title
title Title title title
title title title s=
artist
author Artist
Author
author
author author
composer
album Album
album
year
year
track Track
track
comment Comment
comment
comment
language
language
genre Genre
genre
copyright copyright Copyright
copyright
copyright copyright
description
description
synopsis
show
episode_id
network
major_brand
minor_version
compatible_brands
creation_time
location
location-eng
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Sobreimpressió
/ Superimpose
- Video filters
- libav sobreimpressió / overlay
- How to make dynamic timestamp in ffpmeg, not static?
- Overlaying an Image on a Video Using FFmpeg on Ubuntu
- vhook (Video
hook documentation) (ffmpeg
and vhooks - Ubuntu forums)
- insert a text (strftime
format)
ffmpeg -i toto1.vob -vhook '/usr/lib/vhook/imlib2.so -F /usr/share/fonts/TTF/VeraMono.ttf/14 -c black -x 0 -y 0 -t %A-%D-%T' toto.aviffmpeg -i toto1.vob -vhook '/usr/lib/vhook/drawtext.so -f /usr/share/fonts/TTF/VeraMono.ttf -c #000000 -x 0 -y 0 -t Bondia' toto.avi
- insert an image
ffmpeg -i toto1.vob -vhook '/usr/lib/vhook/imlib2.so -x 0 -y 0 -i logo.jpg' toto2.avi
- insert a text (strftime
format)
- libavfilter
- Conversió automàtica / Automatic conversion
- Enregistrament / Recording
- [FFmpeg-user]
Best
format for arbitrary start/stop stream recording?
- ffmpeg -y -isync -i INPUT -vcodec copy -acodec copy -f mpegts pipe:1 | tee -a OUTPUT1 OUTPUT2 ... OUTPUTn > /dev/null
- [FFmpeg-user]
Best
format for arbitrary start/stop stream recording?
- Streaming
(see also libav
streaming)
- Streaming guide (ffmpeg wiki)
- FFmpeg ? the swiss army knife of Internet Streaming ? part IV
- Buffers:
-
buffer_size
fifo_size
infbuf
s->buffer_size s->circular_buffer_size
transmission
- setsockopt(... SO_SNDBUF, ...)
- default: 32kB (UDP_TX_BUF_SIZE)
- parameter in command:
- -f rtp -buffer_size 212992 rtp://234.5.6.7:5100
- ...
-
-
reception
- setsockopt(... SO_RCVBUF, ...)
- default: 64kB (UDP_MAX_PKT_SIZE)
- parameter in command:
- "... -i rtp://234.1.2.3:5100?buffer_size=212992..."
- "... -i udp://234.1.2.3:5100?buffer_size=212992 ..."
- -buffer_size 212992 -i bbb.sdp
- default: 7 * 4096 * 188 bytes
- parameter in command:
- "... udp://127.0.0.1:1234?fifo_size=... "
- -fifo_size 64k -i bbb.sdp
- only for ffplay
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Pèrdua de paquets RTP / RTP packet loss
- Per a veure la mida del buffer que s'ha establert
finalment / To see the effectively set receiving or
sending buffer size (double the specified
buffer_size):
- ffmpeg/ffplay -v
debug ...
- [udp @ 0x7f4ddc00e8c0] end receive buffer size reported is 131072
- ffmpeg/ffplay -v
debug -buffer_size 65536 ...
- [udp @ 0x7f4ddc00e8c0] end receive buffer size reported is 131072
- ffmpeg/ffplay -v
debug -buffer_size 212992 ...
- [udp @ 0x7f4ddc00e8c0] end receive buffer size reported is 425984
- ffmpeg/ffplay -v
debug ...
- El valor màxim que es pot especificar a
buffer_size està limitat pel valor del paràmetre del
kernel / Maximum value than can be specified
by buffer_size option is maximum value limited by kernel
parameters:
- sudo sysctl net.core.rmem_max
- net.core.rmem_max = 212992
- Si especifiqueu un valor més gran que
net.core.rmem_max, se us mostrarà un avís / If
you specify a value greater than
net.core.rmem_max you will get a warning
message:
- sudo sysctl net.core.rmem_max
- net.core.rmem_max = 212992
- ffmpeg -v debug -buffer_size=851968 ...
- [udp @ 0x15a2280] attempted to set receive buffer to size 851968 but it only ended up set as 425984
- sudo sysctl net.core.rmem_max
- Per a poder incrementar el buffer_size més
enllà de net.core.rmem_max, haureu de modificar
el valor del paràmetre
del kernel / To increase buffer_size
beyond net.core.rmem_max you need to increase
the kernel
parameter value:
- sudo sysctl -w net.core.rmem_max=851968
- ffmpeg -v debug -buffer_size=851968 ...
- [udp @ 0x1782280] end receive buffer size reported is 1703936
- sudo sysctl net.core.rmem_max
-
- emission (use pkt_size=1316 to allocate 7 TS packets
into one IP packet: 188*7=1316 < 1500):
- ffmpeg -i toto -f mpegts udp://...:port?option1=value1&option2=value2
- ffmpeg -f video4linux2 -i /dev/video0 -an -s 352x288 -vcodec mpeg2video -f mpegts udp://172.16.2.146:1234?pkt_size=1316
- ffmpeg -f video4linux2 -i /dev/video0 -s 352x288 -f mpegts -vcodec libx264 -vpre ultrafast -vpre baseline udp://172.16.2.146:1234?ttl=10&buffer_size=65536&pkt_size=1316
- RTP
- Jearquia
de streaming / Streaming hierarchy
- SDP
- Fragmentation and
packet size
ffmpeg -f rtp rtp://...?pkt_size=1472-
headers (bytes)
RTP (pkt_size)
ethernet IP UDP header
payload
14
20
8
12
1460
1472 (default pkt_size)
1500 (default MTU for ethernet)
1514
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- when streaming to Janus (WebRTC) streaming plugin, the value of pkt_size must be lower than 1472 (e.g. 1400). Otherwise the addition of headers for SRTP will overpass the MTU limit, and NACKs will appear.
- No coding (from file)
- Using SDP with increased buffer_size
- transmission (if not specified,
buffer_size is 32kB (UDP_TX_BUF_SIZE))
- ffmpeg -v debug -protocol_whitelist rtp,udp,file,http,https,tcp,tls,rtmp -re -i bbb_stereo.mp4 -an -c:v copy -f rtp -buffer_size 128k rtp://234.5.6.7:5100 -vn -c:a copy -f rtp -buffer_size 256k rtp://234.5.6.7:5102 -sdp_file bbb_stereo.sdp
- with specified RTP packet size (32000
bytes) (not recommended, as network
errors imply worse consequences):
- ffmpeg -v debug -protocol_whitelist rtp,udp,file,http,https,tcp,tls,rtmp -re -i bbb_stereo.mp4 -an -c:v copy -f rtp -buffer_size 128k rtp://234.5.6.7:5100?pkt_size=32000 -vn -c:a copy -f rtp -buffer_size 256k rtp://234.5.6.7:5102?pkt_size=32000 -sdp_file /mnt/nfs/sdp/bbb.sdp
- reception (if not specified, buffer_size
is 64kB (UDP_MAX_PKT_SIZE))
- ffplay -v debug -protocol_whitelist rtp,udp,file,http,https,tcp,tls,rtmp -buffer_size 256k -i bbb.sdp
- transmission (if not specified,
buffer_size is 32kB (UDP_TX_BUF_SIZE))
- Using SDP with increased buffer_size
- Coding
- H.264
- ffmpeg -re -f lavfi -i testsrc=size=320x240:r=15 -c:v libx264 -g 15 -profile:v baseline -level 31 -keyint_min 15 -sc_threshold 0 -b:v 1M -pix_fmt yuv420p -f rtp rtp://127.0.0.1:8004 >/tmp/barres_h264.sdp
- H.264 / AAC
- ffmpeg -re -f lavfi -i testsrc=size=320x240:r=15 -f lavfi -i sine=f=440:b=1 -c:v libx264 -profile:v baseline -b:v 1M -pix_fmt yuv420p -an -f rtp rtp://224.1.2.3:8004 -c:a aac -b:a 16k -vn -f rtp rtp://224.1.2.3:8002 >/tmp/barres_h264_aac.sdp
- VP8 / Opus (e.g. for Janus
streaming plugin with default example
janus.plugins.streaming.cfg.sample.in)
- ffmpeg -re -f lavfi -i testsrc=size=320x240:r=15 -f lavfi -i sine=f=440:b=1 -c:v vp8 -b:v 1M -pix_fmt yuv420p -an -f rtp -payload_type 100 rtp://224.1.2.3:5004 -c:a opus -b:a 16k -vn -f rtp -payload_type 111 rtp://224.1.2.3:5002 -sdp_file /tmp/barres_vp8_opus.sdp
- ffmpeg -re -f lavfi -i testsrc=size=320x240:r=15 -f lavfi -i sine=f=440:b=1 -c:v vp8 -b:v 1M -pix_fmt yuv420p -an -f rtp rtp://224.1.2.3:5004 -c:a opus -b:a 16k -vn -f rtp rtp://224.1.2.3:5002 >/tmp/barres_vp8_opus.sdp
- H.264
- Specify payload
type (pt):
ffmpeg ... -f rtp -payload_type 100 rtp://...
- RTCP
- Specify CNAME in both streams (audio and
video), to be included in RTCP SR "Source
Description" (SDES)
packets:
ffmpeg -an ... -f rtp -cname user123456789@host-87654321 rtp://... ... -vn ... -f rtp -cname user123456789@host-87654321 rtp://...- Source Description in RTCP packets is needed by gstreamer as an RTP client, to honour RTCP information
- check with tshark that now RTP flow contains RTCP packets with "Source Description" (SDES) information
- Specify CNAME in both streams (audio and
video), to be included in RTCP SR "Source
Description" (SDES)
packets:
- Specify title, to be included in SDP as
s=<title> - Problemes / Problems
- Pèrdua
de paquets en recepció / Packet loss in
reception
- Info
- GStreamer RTP
- FFMPEG RTSP streaming over UDP - Image Smearing
- Live555 FAQ
- Deployment guide (liveMediaStreamer)
- max delay reached. need to consume packet
RTP: missed xx packets - Solució / Solution
- tune
buffers: buffer_size, fifo_size
- e.g.: if receiving buffer_size is
65536 (ffmpeg default, or specified
with buffer_size 65536)
- [udp @ 0x7f548c00e8c0] end receive buffer size reported is 131072
- NALs larger than 65536*2=131072 will be truncated, and rtp packets from this point will be dropped, and kernel will mark them as dropped (it can be seen by running: dropwatch -l kas)
- maximum value for buffer_size
depends on Linux
kernel network parameter:
- check that net.core.rmem_max is, at least, 212992 (default)
- ffmpeg -buffer_size=212992
- this will open an udp buffer of 212992*2=425984 and NALs could have up to 425984 bytes (416kB)
- e.g.: if receiving buffer_size is
65536 (ffmpeg default, or specified
with buffer_size 65536)
- tune
buffers: buffer_size, fifo_size
- Info
- En recepció / In reception
- [h264 @ 0x1795060] co located POCs
unavailable
- Solució / Solution
- ...
- Solució / Solution
- [h264 @ 0x1795060] co located POCs
unavailable
- En transmuxació / Transmuxing
- No H.264
NAL units of type
7 (SPS), 8 (PPS)
when transmuxing from RTMP
(at RTMP: NAL units of type 7,8 are only
available at the beginning of the
connection, but they are needed by RTP
client)
- Solució / solution
ffmpeg -protocol_whitelist rtp,udp,file,http,https,tcp,tls,rtmp -re -i rtmp://... -an -bsf:v h264_mp4toannexb -c:v copy -f rtp rtp://...
- Solució / solution
- Too many packets buffered for output
stream 0:1
- Solució / Solution
- Set a high value for -max_muxing_queue_size
- [bug][regression] Too many packets buffered for output stream
- Solució / Solution
- No H.264
NAL units of type
7 (SPS), 8 (PPS)
when transmuxing from RTMP
(at RTMP: NAL units of type 7,8 are only
available at the beginning of the
connection, but they are needed by RTP
client)
- Pèrdua
de paquets en recepció / Packet loss in
reception
- Jearquia
de streaming / Streaming hierarchy
- RTMP
- rtmp
- ffserver accepts RTMP input - can it output to RTMP?
- from inverted camera to an rtmp server:
ffmpeg -f video4linux2 -i /dev/video1 -s 640x480 -f flv -c:v libx264 -profile:v baseline -pix_fmt yuv420p -an -vf "vflip,hflip" -r 30 rtmp://...
- from file to an rtmp server:
ffmpeg -re -i sintel-1024-stereo.mp4 -c:v copy -c:a aac -strict -2 -f
flv rtmp://...
- from an rtmp server:
ffmpeg -i rtmp://...- Problemes /
Problems
- if ffmpeg is not receiving data from
the rtmp server (because the process
that feeds it has not cleanly
terminated), it cannot be terminated
(kill -TERM) (see nginx
rtmp module)
- workarounds:
- kill -TERM again
- send some content to the rtmp server
- workarounds:
- if ffmpeg is not receiving data from
the rtmp server (because the process
that feeds it has not cleanly
terminated), it cannot be terminated
(kill -TERM) (see nginx
rtmp module)
- Problemes /
Problems
- low-latency
- Latency (Streaming guide)
- Format options
- libav x264 settings for zero-latency encoding (arash@work)
- compile the latest ffmpeg and libx264
- export LD_LIBRARY_PATH=/usr/local/lib; /usr/local/bin/ffmpeg -an -f video4linux2 -s 640x480 -r 15 -i /dev/video0 -vcodec libx264 -preset ultrafast -tune zerolatency -x264opts "vbv-maxrate=2000:vbv-bufsize=200:slice-max-size=1500" -f h264 - | /usr/local/bin/ffplay -i -
- x264: the best low-latency video streaming platform in the world
- x264 encoder latency
- Streaming x264 zerolatency
- x264 zerolatency - How to do it?
- Using WebM/VP8 for low latency streaming
- reception:
- allow reuse multicast packets (UDP sockets) in reception (see also LIMBOS / mcreflect, Darwin reflector) (if not, only one application per computer will be able to receive the stream):
- ffmpeg ... -i udp://...?reuse=1
- vlc udp://@:1234
- UDP
- ffmpeg -i udp://...?fifo_size=... (similar to -infbuf for ffplay/avplay?)
- ffmpeg live stream transcoding
- Tutorial:
HD-PVR
to Twitch on Mac OS with ffmpeg
- ffmpeg -i 'udp://127.0.0.1:1234?fifo_size=1000000 &buffer_size=10000000 &overrun_nonfatal=1? ...
- HLS
- hls muxer
- hls demuxer (ffmpeg documentation)
- Segmentació / Segmentation
- #5419 HLS EXT-X-DISCONTINUITY tag is not supported
- Exemple / Example
ffmpeg -i toto.mp4 -c copy -hls_time 2 -hls_list_size 0 -start_number 0 out.m3u8- all file (
-hls_list_size 0), variants with names (name:my_hdname:my_sd) and a master.m3u8 (-master_pl_name)ffmpeg -i toto.mp4 \
-b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
-map 0:v -map 0:a -map 0:v -map 0:a \
-f hls \
-var_stream_map "v:0,a:0,name:my_hd v:1,a:1,name:my_sd" \
-master_pl_name master.m3u8 \
-hls_list_size 0 \
out_%v.m3u8
- same, with EXT-X-PROGRAM-DATE-TIME tags
ffmpeg -i toto.mp4 \
-b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
-map 0:v -map 0:a -map 0:v -map 0:a \
-f hls \
-var_stream_map "v:0,a:0,name:my_hd v:1,a:1,name:my_sd" \
-master_pl_name master.m3u8 \
-hls_list_size 0 \
-hls_flags program_date_time \
out_%v.m3u8
- MPEG
DASH
- compile
with options:
--enable-demuxer=dash --enable-libxml2
- Reproducció / Play
ffplay toto.mpd
- Selecció de qualitat / Quality selection
ffprobe toto.mpdffplay -map ... -map ... toto.mpd
- WebM DASH
- compile
with options:
- Problemes / Problems
- RTMP problems
- RTP problems
- Tee problems
- Timestamps problems
- HLS problems
- empty m3u8 after termination
- from v4.4
- Empty m3u8 after a Ctrl+C (#9234)
- EXT-X-PROGRAM-DATE-TIME:1970-01-01...
- empty m3u8 after termination
[https @ 0x1adbbe0] Stream ends prematurely at xxxx, should be yyyy- Solució / Solution
ffmpeg -reconnect 1 ...
- Solució / Solution
Past duration ... too large- #4700 Past duration 0.999992
- #4401
Past duration
- Only supress warnings:
- -loglevel error
- Possible solutions
- -filter:v fps=(your framerate)
- -vsync 1 (cfr)
- -vsync passthrough -i ...
- -vsync passthrough -frame_drop_threshold 4 -i ...
- Only supress warnings:
- Strange behaviours:
- frame-rate
conversion:
- ffmpeg -i toto.m2v -r 12.5 toto.h264
- ffmpeg -i toto.h264: ...12.50 tb(r)
- vlc plays toto.h264 2x too fast; mplayer plays it correctly
- ffmpeg -i toto.h264 -vcodec copy -r 12.5 toto.mp4
- mp4info toto.mp4: ...@25.00 fps
- vlc and mplayer play toto.h264 2x too fast;
- ffmpeg -r 12.5
-i toto.h264 -vcodec copy toto_12.5.mp4
- mp4info toto_12.5.mp4: ...@12.500 fps
- vlc and mplayer play toto.mp4 correctly
- ffmpeg -i toto.m2v -r 12.5 toto_direct.mp4
- mp4info toto_direct.mp4: ...@12.580 fps
- vlc and mplayer play toto.mp4 correctly
- ffmpeg -i toto.m2v -r 12.5 toto.h264
- frame-rate
conversion:
- Info
04libav / ffmpeg compilation on Linux#
- See also GPAC compilation
- How-To Build FFmpeg on Debian Squeeze
- Dependencies
-
- General
-
- Mageia
-
- 64 bits (x86_64)
-
urpmiglibc-devel libstdc++-devel gcc lib64SDL-devel lib64sdl2.0-devel lib64raw1394-devel lib64dc1394-devellib64gsm-devel lib64speex-devel lib64zlib-devel yasm
- 32 bits
-
urpmilibSDL-devel libdc1394-devellibgsm-devel libspeex-devel zlib-devel yasm
- Mandriva:
-
urpmi libSDL-devel libdc1394-devel libgsm-devel libspeex-devel zlib1-devel yasm
- Ubuntu
-
- 26.04
-
apt install gcc make yasm nasmapt install gcc make yasm nasm libssl-dev libpulse-dev libmp3lame-dev libfdk-aac-dev libtheora-dev libx264-dev libx265-dev libwebp-dev libffmpeg-nvenc-dev libopenjp2-7-dev libopus-devlibsrt-openssl-dev libvpx-dev libxvidcore-devlibsdl2-dev
- CentOS
-
- CentOS 8
sudo dnf -y install epel-release
sudo dnf config-manager --set-enabled powertoolssudo dnf -y install --nogpgcheck https://mirrors.rpmfusion.org/free/el/rpmfusion-free-release-8.noarch.rpm https://mirrors.rpmfusion.org/nonfree/el/rpmfusion-nonfree-release-8.noarch.rpm
- CentOS 7
sudo yum install http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
sudo yum install gcc make yasm
- CentOS 8
- Specific
-
-
ffmpeg
dependencies
configure
src Mageia
Ubuntu
CentOS / Alma
--enable-gpl--enable-nonfree
32-bit
64-bit
general
gcc make yasm
lib64freetype6-devel
lib64freetype2-develgcc make yasm nasmgcc make yasm
ffplay
[--disable-ffplay]
libsdl2.0-devel
lib64sdl2.0-devel
libsdl2-dev
tls
--enable-openssl
libssl-devopenssl-develpulse audio
--enable-libpulse
libpulse-devpulseaudio-libs-develaudio codecs
MP3
--enable-libmp3lame
liblame-devellib64lame-devel
lib64mp3lame-devellibmp3lame-devlame-devel
AAC
(native)
--enable-libvo-aacenc
libvo-aacenc-devellib64vo-aacenc-devellibvo-aacenc-dev
--enable-libfaac
x
libfaac-devel
--enable-libfdk-aac
x
fdk-aac
lib64fdk-aac-devel
libfdk-aac-dev
fdk-aac-devel
AAC+
--enable-libaacplus
--enable-libfdk-aac
x
fdk-aac-devel
HE-AAC
--enable-libfdk-aac
x
fdk-aac-devel
Opus
--enable-libopus
lib64opus-devel
libopus-dev
opus-devel
Vorbis
libvorbis-devel
libvorbis-develvideo codecs
AV1
Dirac
--enable-libschroedinger
libdirac-devel
libschroedinger-devellib64dirac-devel
lib64schroedinger-devellibschroedinger-dev
Theora
--enable-libtheora
libtheora-devellib64theora-devellibtheora-devlibtheora-develVPX (VP8, VP9)
--enable-libvpx
libvpx
libvpx-devellib64vpx-devellibvpx-devlibvpx-devel
H.264 / AVC
--enable-libx264x
x264 libx264-devellib64x264-devellibx264-devx264-devel
H.265 / HEVC
--enable-libx265
x265
libx265-devx265-develXvid
--enable-libxvidx
libxvid-devellib64xvid-devel
lib64xvidcore-devel
libxvidcore-dev
image
JPEG
jpeg-devel
JPEG 2000
--enable-libopenjpeg
libopenjpeg-devellib64openjpeg-devellibopenjp2-7-dev
PNG
libpng-devel
WebP --enable-libwebp
lib64webp-devel
libwebp-dev
libwebp-develfilters
drawtext
--enable-libfreetype--enable-libharfbuzz[--enable-fontconfig]
google-droid-sans-fontslibharfbuzz-dev
subtitles
--enable-libass
transport
https
--enable-openssl
x
SRT --enable-libsrt
srt
libsrt-openssl-dev
muxers DASH --enable-demuxer=dash --enable-libxml2
hardware acceleration
./configure --list-hwaccels
CUDA [--enable-cuvid]
(auto enabled if devel libraries are installed)
ffnvcodec
nv-codec-headers(ffnvcodec)
nvenc [--enable-nvenc] (auto enabled)
ffnvcodec
nv-codec-headers(ffnvcodec)libffmpeg-nvenc-dev
nv-codec-headersVDPAU (Nvidia) [--enable-vdpau](auto enabled if devel libraries are installed)
lib64vdpau-devel
OpenMAX --enable-omx
--enable-omx-rpi
...
v4l M2M
VA API (Intel) [--enable-vaapi]
(auto enabled if devel libraries are installed)
lib64va-devel
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- ffmpeg >= 0.6.1:
-
urpmi tetex-texi2html libjack-devel libvpx-devel jpeg-devel libpng-devel bzip2-devel rtmp-devel vdpau-devel libva-devel libfaad2-devel opencore-amr-devel [x264-devel]
-
- Baixada / Download
-
- ffmpeg
-
- releases
version="4.2.3"
wget http://ffmpeg.org/releases/ffmpeg-${version}.tar.gz
tar xvf ffmpeg-${version}.tar.gz
- development (git repository):
-
git clone git://git.ffmpeg.org/ffmpeg.git(git clone git://github.com/FFmpeg/FFmpeg.git ffmpeg)-
- libvpx-decoder >=0.9.1
- libx264 >= 0.99 (/usr/include/x264.h: #define X264_BUILD 99)
- releases
- libav
-
- versions
- development (git repository):
-
- first time:
-
git clone git://git.libav.org/libav.git libav
cd libav- not the first time:
-
git pull
- Dependències
- x264
- x265
- ffnvcodec
- Mageia 9
- version provided by package nv-codec-headers is 11.1.5.2, not valid for ffmpeg compilation
- use git version instead
git clone https://github.com/FFmpeg/nv-codec-headers.gitcd nv-codec-headers- checkout version that matches installed cuda version
git checkout n11.1.5.3
sudo make install- IMPORTANT: before compiling ffmpeg:
- export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
- pkg-config --exists --print-errors "ffnvcodec >= 11.1.5.3"
- Mageia 9
- Compilació / Compilation
-
- Passos / steps
-
- configuration
- License:
configure option
resulting license
(no option)
LGPL v3 or later
--enable-nonfreenonfree and unredistributable
--enable-gplGPL v3 or later
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Acceleració per maquinari / Hardware acceleration (Linux graphics (Intel))
- AAC audio (MPEG-4)
-
- option 1:
-
- use native embedded aac encoder (not experimental any more)
- if you are coding your own client, you need to allow experimental codecs:
-
p_codec =avcodec_find_encoder_by_name("aac");
AVDictionary *opts = NULL;
av_dict_set(&opts, "strict", "experimental", 0);
if (avcodec_open2(p_codec_ctx, p_codec, &opts) < 0) {
...
- option 2:
-
- use an external coder:
-
./configure ... --enable-libfdk-aac --enable-nonfree ...-
p_codec =avcodec_find_encoder_by_name("libfdk_aac");
./configure ... --enable-libvo-aacenc ...-
p_codec =avcodec_find_encoder_by_name("libvo_aacenc");
- Exemples / Examples:
- Configuration examples:
-
- Complet / Complete: ffplay, aac, x264, x265, vpx, nv, DASH, SRT, openssl, ...
- Ubuntu 26.04
sudo apt install gcc make yasm nasm libssl-dev libpulse-dev libmp3lame-dev libfdk-aac-dev libtheora-dev libx264-dev libx265-dev libwebp-dev libffmpeg-nvenc-dev libopenjp2-7-dev libopus-devlibsrt-openssl-dev libvpx-dev libxvidcore-devlibsdl2-dev./configure--enable-shared--enable-nonfree --enable-gpl --enable-openssl --enable-libpulse --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libopenjpeg --enable-libwebp --enable-libfreetype--enable-fontconfig --enable-libsrt --enable-demuxer=dash --enable-libxml2--enable-libharfbuzz- Mageia
sudo dnf install lib64freetype2-devel lib64sdl2.0-devel lib64mp3lame-devel lib64vo-aacenc-devel lib64fdk-aac-devel lib64opus-devel lib64dirac-devel lib64schroedinger-devel lib64theora-devel lib64vpx-devel lib64x264-devel lib64x265-devel lib64xvidcore-devel lib64openjpeg-devel lib64webp-devel nv-codec-headers lib64vdpau-devel lib64va-develPKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig/./configure--enable-shared--enable-nonfree --enable-gpl --enable-openssl --enable-libpulse --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libopenjpeg --enable-libwebp --enable-libfreetype --enable-fontconfig --enable-libsrt --enable-demuxer=dash --enable-libxml2- H264 + AAC (native) + [https]
-
./configure --enable-gpl --enable-libx264--enable-shared [--enable-nonfree --enable-openssl]
- H264 + HE-AAC (Fraunhofer)
-
./configure --enable-nonfree --enable-libfdk-aac --enable-gpl --enable-libx264--enable-shared
- Usual codecs
-
./configure --enable-nonfree --enable-libfdk-aac --enable-gpl --enable-libx264 --enable-libtheora --enable-libvpx --enable-shared
./configure [--enable-nonfree --enable-libfdk-aac] [--enable-gpl --enable-libx264--enable-libxvid] --enable-libtheora --enable-libvpx--enable-shared
./configure [--enable-nonfree --enable-libfdk-aac] [--enable-gpl --enable-libx264--enable-libxvid] --enable-libtheora --enable-version3 --enable-libmp3lame --enable-libvpx--enable-shared
./configure [--enable-nonfree --enable-libfdk-aac] [--enable-gpl --enable-libx264--enable-libxvid] --enable-libtheora --enable-version3 --enable-libschroedinger --enable-libmp3lame --enable-libvpx--enable-shared
- SRT (srt.pc is
installed in
/usr/local/lib64/pkgconfig/)PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig/ ./configure --enable-libsrt ...- SRT + H264 + AAC (native) + https
PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig/ ./configure --enable-libsrt--enable-gpl --enable-libx264--enable-shared --enable-nonfree --enable-openssl
- Complet (inclou SRT) / Complete (including
SRT)
sudo dnf install lib64freetype2-devel lib64sdl2.0-devel lib64mp3lame-devel lib64vo-aacenc-devel lib64fdk-aac-devel lib64opus-devel lib64dirac-devel lib64schroedinger-devel lib64theora-devel lib64vpx-devel lib64x264-devel lib64x265-devel lib64xvidcore-devel lib64openjpeg-devel lib64webp-devel nv-codec-headers lib64vdpau-devel lib64va-develPKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/:/usr/local/lib/pkgconfig/./configure--enable-shared--enable-nonfree --enable-gpl --enable-openssl --enable-libpulse --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libopenjpeg --enable-libwebp --enable-libfreetype --enable-fontconfig --enable-libsrt --enable-demuxer=dash --enable-libxml2
- close to dextop for CentOS
-
--prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic'
--enable-nonfree--enable-libfdk-aac
--enable-gpl --enable-libx264 --enable-libx265
--enable-avfilter --enable-avresample --enable-postproc --enable-pthreads
--disable-static --enable-shared --shlibdir=/usr/lib64 --enable-runtime-cpudetect
- CentOS dextop
-
ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect
- License:
makesudo make install- update ld:
echo "/usr/local/lib" > /etc/ld.so.conf.d/local.confldconfig
- configuration
- Problemes / Problems:
-
- compatibility with gstreamer
compilation
- ffmpeg must be installed after gstreamer, because
gstreamer is going to install its own version of
ffmpeg headers in /usr/local/include/libavcodec ...
and a missmatch between (minor) versions will occur:
- installed by gstreamer:
grep "define LIBAVCODEC_VERSION_" /usr/local/include/libavcodec/version.h
- installed by ffmpeg:
grep "define LIBAVCODEC_VERSION_" ~/src/ffmpeg-4.2.3/libavcodec/version.h
- installed by gstreamer:
- if gstreamer were installed after ffmpeg, janus will not be able to be compiled with postprocessing option --enable-post-processing
- ffmpeg must be installed after gstreamer, because
gstreamer is going to install its own version of
ffmpeg headers in /usr/local/include/libavcodec ...
and a missmatch between (minor) versions will occur:
libavcodec/libavcodec.so: undefined reference to `x264_encoder_open_160'- ls -l /usr/local/lib64/ | grep libx264
- lrwxrwxrwx. 1 root
root
14 15 març 18:47 libx264.so -> libx264.so.160
-rwxr-xr-x. 1 root root 9014288 15 març 18:42 libx264.so.160
- lrwxrwxrwx. 1 root
root
14 15 març 18:47 libx264.so -> libx264.so.160
- ls -l /usr/local/lib64/ | grep libx264
- missing some libx264-*ffpresets
-
- They have been removed
- solution:
-
- use -preset instead of -vpre
- compatibility with gstreamer
compilation
05ffmpeg compilation on MSWindows#
- using cygwin
-
- [Mplayer-cygwin] list
- setup Cygwin. Install packages:
-
- make
- gcc
- diffutils (cmp)
- patch
- install and compile yasm (nasm not always works)
-
static dynamic x264
(*)svn co svn://svn.videolan.org/x264/trunk x264
patch -p0 < dll.patch./configure./configure --enable-sharedmodify config.mak:
delete all -mno-cygwin occurences
make libx264.amakeinstall -m 644 libx264.a /usr/local/lib
install -m 644 x264.h /usr/local/includemake installffmpeg svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpegmodify libavcodec/mpegaudiodec.c. Add line:
#define llrint lrintor apply a patch
./configure --enable-libx264 --enable-gpl./configure --enable-shared --disable-static --enable-libx264 --enable-gplmakemake installAquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- using MinGW
- ffmpeg Windows help
- setup MinGW
-
- install MSYS in c:\msys (from minGW / Download / Current)
-
MSYS_1.0.10.exe
- install MinGW in c:\MinGW (from minGW / Download / Current) (use f.i. 7zip to untar)
-
- MinGW Runtime:
mingw-runtime-3.9.tar.gz - Windows API:
w32api-3.6.tar.gz - binutils:
binutils-2.15.91-20040904-1.tar.gz - GCC:
gcc-core-3.4.2-20040916-1.tar.gz, gcc-g++-3.4.2-20040916-1.tar.gz
- MinGW Runtime:
- copy needed tools from MS Visual:
-
- copy c:\Archivos de programa\Microsoft Visual Studio .NET 2003\Vc7\bin\lib.exe, link.exe -> c:\MinGW\bin
- copy c:\Archivos de programa\Microsoft Visual Studio .NET 2003\Common7\IDE\mspdb71.dll -> c:\MinGW\bin
- Start / MinGW / MSYS / msys.exe
- install and compile yasm (nasm not always works)
- compile x264
- compile ffmpeg
cd /c/.../gpac_extra_libs/ffmpeg
./configure --enable-shared --disable-debug --enable-memalign-hack
make
06x264 compilation#
- Dependencies
- Alma
sudo dnf install git nasm gcc make
- Alma
git clone https://code.videolan.org/videolan/x264.gitcd x264git checkout stable./configure --enable-sharedmakesudo make install- if you will want to compile ffmpeg with x264 support:
sudo make install-lib-shared- and configure ffmpeg with:
- ...
- if ...:
sudo make install-lib-static
07x265 compilation#
- dependències / dependencies
-
- Mageia
-
urpmi task-c++-devel
- one of the following
-
- x265.org
-
hg clone https://bitbucket.org/multicoreware/x265
- Videolan x265
-
hg clone http://hg.videolan.org/x265
cd x265/buildcmake ../sourcemakesudo make install- to avoid "ERROR: x265 not found" when configuring ffmpeg with --enable-x265, check that /usr/local/lib/pkgconfig is on pkg-config path:
-
pkg-config --list-all | grep x265- if nothing appears, then:
-
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/- to make it permanent:
-
- ...
08GPAC#
- Linux compilation
-
-
fmpeg / libav gpac
ffmpeg configure
errors when compiling gpac
solutions
dashcast problems
library
version
./configure
gpac modifications from mpeg2video source
extra_lib
libav 9
9.8
9.10
--enable-debug --enable-gpl --enable-libx264 --enable-version3 --enable-sharedaudio_decoder.c:215:58: error: ‘AVFrame’ has no member named ‘channels’: solved in r4959
ok
incorrect mp2 output audio (estrident) from aac input 10
git
git
ffmpeg 1.2
1.2.4
2.0
2.0.2
--enable-debug --enable-gpl --enable-libx264 --enable-version3 --enable-shared
(no errors)
ok incorrect mp2 output audio (estrident) from aac input
2.1
2.1.1 --enable-debug --enable-gpl --enable-libx264 --enable-version3 --enable-shared
(no errors)
-
ok
incorrect mp2 output audio (estrident) from aac input 2.1.2
2.1.3
2.2
2.2 --enable-debug --enable-gpl --enable-libx264 --enable-libx265 --enable-version3 --enable-shared --enable-avresample
2.3
2.3.3
--enable-debug --enable-gpl --enable-libx264 --enable-libx265 --enable-version3 --enable-shared --enable-avresample --enable-libfreetype
2.4
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- step 1: install needed libraries
-
- to compile your own version of libav/ffmpeg, choose one of the following:
-
- ffmpeg from source
-
- install and compile ffmpeg 2.2.x with needed configure options
- GPAC rev >=4772: install and compile ffmpeg 2.0.1
- libav from source
-
- libav 9.10
-
cd libav-9.10; ./configure --enable-debug --enable-gpl --enable-libx264 --enable-version3 --enable-shared
- GPAC rev >=4772 (22nd sep 2013): install and compile libav from git (55)
- GPAC rev >= 4731: install or compile libav 9.8 (54) (only libs are needed):
- GPAC rev < 4731: install or compile libav version 0.8.7 (53) (only libs are needed):
-
cd ~/src/libav-0.8.7/make install-libs
- gpac_extra_lib (ffmpeg and other libraries, provided by gpac)
-
- steps
-
urpmi automake(to avoid aclocal not found)cd gpac/extra_libwget https://sourceforge.net/p/gpac/code/HEAD/tree/trunk/gpac_extra_libs/gpac_extra_libs.zipunzip gpac_extra_libs.zipchmod +x compile.sh */configure */bootstrap./compile.sh
- problems
-
- configure.in:27: error:
'AM_CONFIG_HEADER': this macro is obsolete.
You should use the 'AC_CONFIG_HEADERS' macro instead.
- configure.in:27: error:
'AM_CONFIG_HEADER': this macro is obsolete.
- Paquets / Packages
-
- CentOS
sudo yum install ...
- Mageia 2/3/4, 64bit:
-
- if you have compiled your own version of libav/ffmpeg:
-
urpmilib64pulseaudio-devellib64xv-devellib64xmlrpc-c-devel lib64cairo-devellib64wxgtku2.8-devellib64openjpeg-devel lib64faad2-devel lib64mad-devel lib64a52dec-devel [lib64sdl2.0-devel]
- if you use the system libav/ffmpeg:
-
urpmilib64pulseaudio-devellib64xv-devellib64xmlrpc-c-devel lib64cairo-devellib64wxgtku2.8-devellib64openjpeg-devel lib64faad2-devel lib64mad-devel lib64a52dec-devellib64ffmpeg-devel[lib64sdl2.0-devel]
- Ubuntu (*)
-
- if you have compiled your own version of libav/ffmpeg:
-
sudo apt-get install make pkg-config g++ zlib1g-devlibsdl1.2-dev [libsdl2-dev]
- if you use the system libav/ffmpeg:
-
sudo apt-get install make pkg-config g++ zlib1g-dev firefox-dev libfreetype6-dev libjpeg62-dev libpng12-dev libopenjpeg-dev libmad0-dev libfaad-dev libogg-dev libvorbis-dev libtheora-dev liba52-0.7.4-dev libavcodec-dev libavformat-dev libavutil-dev libswscale-dev libxv-dev x11proto-video-dev libgl1-mesa-dev x11proto-gl-dev linux-sound-base libxvidcore-dev libssl-dev libjack-dev libasound2-dev libpulse-dev libsdl1.2-dev dvb-apps libavcodec-extra-53 libavdevice-dev libmozjs185-dev
- Mageia 1:
-
urpmi libmad-devellibxvid-devellibjs-devellibopenjpeg-devellibjpeg-devel liba52dec-devellibSDL-devellibcairo-devellibwxgtku2.8-devellibpulseaudio-devellibxmlrpc-c-devellibxulrunner-devellibxv1-devellibffmpeg-devel libdirectfb-devel
- Mandriva 2010.2:
-
- add plf to your distribution sources (Easy URPMI)
urpmi libmad-devel libxvid-devellibjs-devel libopenjpeg-devel libjpeg-devel liba52dec-devel libSDL-devel libwxgtku2.8-devel libpulseaudio-devel libxmlrpc-c-devel libxulrunner-devel xulrunner-headless-devel libxv1-devellibffmpeg-devel
- Mandriva 2008.x:
-
- from 2008.1: urpmi
libfaad2-devellibffmpeg-devel (liblame-devel libfaac-devel libmpeg4ip-devel liba52dec-devel libmrnb-devel libtheora-devel libvorbis-devel libx264-devel libmrwb-devel) libglib2.0-devellibmesaglut3-devel - from 2008.0: urpmi
libfreetype6-devellibjs-devellibmad0-devellibopenjpeg1-devellibopenssl0.9.8-devellibpng-devellibSDL1.2-devellibwxgtk2.8-devel (libxml2-devel)libwxgtku2.8-devel
- from 2008.1: urpmi
- Mandriva 2007.x:
-
urpmi libfaad2_0-devel libffmpeg51-devel libfreetype6-devel libjpeg62-devel libjs1-devel libmad0-devel libogg0-devel libopenjpeg1-devel libopenssl0.9.8-devel libpng3-devel libSDL1.2-devel libtheora0-devel libvorbis0-devel libwxgtk2.6-devel libwxgtku2.6-devel libxml2-devel libxvid4-devel zlib1-devel libmesaglut3-develln -s /usr/include/js-1.5 /usr/include/js
- CentOS
-
-
- step
2:
get GPAC
source:
- gpac / gpac
(GitHub)
git clone [-b master] [--depth 1] https://github.com/gpac/gpac.git
- gpac tar or CVS
- SVN
-
- first time:
-
svn co svn://svn.code.sf.net/p/gpac/code/trunk/gpac- or get a specific revision (e.g. r5382):
- if old site was used:
-
svn co https://gpac.svn.sourceforge.net/svnroot/gpac/trunk/gpac gpacsvn co svn://svn.code.sf.net/p/gpac/code/trunk/gpac gpac
- next times:
-
- head (latest):
-
svn update
- specific revision (e.g. r5382):
-
svn update -r 5382
- patch some Makefile files:
-
- gpac/applications/{mp4client,mp4box,mp4ts}/Makefile:
-
... $(LINKLIBS) $(JS_LIBS)
- gpac / gpac
(GitHub)
- step 3: compile gpac (Compiling GPAC on Ubuntu)
-
- Problemes / Problems
- Dashcast modifications
- modify GPAC code according to libav / ffmpeg versions used:
-
- ffmpeg 2.2 (compiled with
--enable-avresample) -
- gpac/applications/dashcast/Makefile (GPAC svn > r5237)
-
CFLAGS+=-DDC_AUDIO_RESAMPLER
LINKLIBS+=-lavresample
- ffmpeg 2.1
-
- (no modifications needed on latest svn gpac)
- libav git
-
- if using GPAC rev>=4772 (2013-09-22)
-
- ffmpeg_decode.c:112:7: error:
‘CODEC_ID_SVQ3’ undeclared (first use in
this function)
... - modules/ffmpeg_in/ffmpeg_decode.c:633: undefined reference to `avcodec_decode_audio3'
-
- Solution:
-
- use libav 9.x
- ffmpeg_decode.c:112:7: error:
‘CODEC_ID_SVQ3’ undeclared (first use in
this function)
- if using GPAC rev. >= 4731 (2013-09-05)
-
- error: ‘AV_CH_LAYOUT_STEREO’ undeclared
-
- Solució / Solution:
-
- audio_muxer.h
-
#include "libavcodec/version.h"
#if (LIBAVCODEC_VERSION_MAJOR>53)
#include "libavutil/channel_layout.h"
#endif
- error: ‘AVStream’ has no member named ‘r_frame_rate’
-
- libavformat/avformat.h
- solució / solution
-
- video_decoder.c
-
- comment if statament where r_frame_rate appears
- error: ‘CODEC_ID_RAWVIDEO’ undeclared
-
- solució / solution
-
sed -i 's/CODEC_ID/AV_CODEC_ID/g' video_decoder.c
- error: ‘CODEC_ID_H264’ undeclared
-
- sol:
-
sed -i 's/CODEC_ID/AV_CODEC_ID/g' video_encoder.c
- video_encoder.o: In function
`dc_video_encoder_encode':
video_encoder.c:(.text+0x26b): undefined reference to `avcodec_encode_video' -
- in libav from git, avcodec_encode_video has changed to avcodec_encode_video2 and parameters are different (libavcodec/avcodec.h)
- sol:
-
- use libav 9.1
- make sure that extra_lib is not refrenced by configure:
-
rm -rf extra_lib
- error: ‘CODEC_ID_MPEG4’ not declared in this scope
- applications/dashcast/audio_encoder.h
-
#include "libautil/channel_layout.h"
- ‘AVStream’ has no member named ‘r_frame_rate’
-
- it is an issue in libav from repository; use libav-9.1 instead
- libav 9.10
-
- ...
- libav 9.8
-
- if using GPAC rev. >= 4731 (2013-09-05)
-
- error: ‘AV_CH_LAYOUT_STEREO’ undeclared
-
- Solució / Solution:
-
- audio_muxer.h
-
#include "libavcodec/version.h"
#if (LIBAVCODEC_VERSION_MAJOR>53)
#include "libavutil/channel_layout.h"
#endif
- libav 53 / 0.8.7 / ffmpeg
-
- no GPAC modifications needed
- ffmpeg 2.2 (compiled with
./configure [--enable-debug] [--use-js=no]makemake install- update ld.so:
-
- new fashion (e.g. Mageia 3):
-
echo /usr/local/lib > /etc/ld.so.conf.d/local32.confldconfig
- old fashion
-
- add lines to
/etc/ld.so.conf -
/usr/local/lib/usr/lib/xulrunner-1.9.../
- add lines to
ldconfig- MP4Box usage
- Problemes / Problems
-
- durant la compilació / during compilation
-
- with libav
- problems with libavformat/avio.h
-
error: ‘URL_WRONLY’ was not declared in this scope-
- Solució / Solution:
-
- build fail with ffmpeg 0.10 (Bug #1605) (OpenCV)
cd applications/dashcast/sed -i 's/URL_WRONLY/AVIO_FLAG_WRITE/g' audio_muxer.csed -i 's/URL_WRONLY/AVIO_FLAG_WRITE/g' video_muxer.c
- compilation with libav (>0.8.7) instead of ffmpeg or libav 0.8.7
/usr/bin/ld: /usr/local/lib/libavcodec.a(allcodecs.o): relocation R_X86_64_32 against `ff_a64multi_encoder' can not be used when making a shared object; recompile with -fPIC../../bin/gcc/libgpac.so: undefined reference to `JSVAL_NULL'
../../bin/gcc/libgpac.so: undefined reference to `JSVAL_VOID'-
- solution:
-
- ??
undefined reference to JS_ClearNewbornRoots-
- solved in rev 3646
- solution: check that "ldd libgpac.so" points to the correct libmozjs.so (libxulrunner-x.y.z)
-
- libxulrunner version > 1.9 is not working (JS_ClearNewbornRoots has been deprecated)
- urpmi libxulrunner1.9.x xulrunner1.9.x
- urpmi --allow-nodeps libxulrunner-devel-1.9.x
- solution: disable js support
-
./configure --use-js=no
- DirectFB not found by configure
-
- solution:
-
- bug: in
configurefile, you shoud have: -
directfb_inc="/usr/include/directfb"
- bug: in
- després de la compilació / after compilation
-
- confirm that the following files point to the right place (/usr/local/lib/libav...):
-
ldd /usr/local/lib/gpac/gm_ffmpeg_in.so-
- libavcodec.so.54 =>
/usr/local/lib/libavcodec.so.54
...
- libavcodec.so.54 =>
/usr/local/lib/libavcodec.so.54
ldd /usr/local/bin/DashCastldd /usr/local/bin/MP4Client- if not:
-
- /etc/ld.so.conf.d/local32.conf
-
/usr/local/lib
ldconfig
- ldd DashCast apunta a libavcodec.53, i heu compilat amb la versió 54:
-
- Solució:
-
- comproveu que els fitxers a bin/gcc/DashCast i altres .so són recents. Si no, esborreu-los i feu make
- en execució / on execution
-
- DashCast
-
- si feu servir l'ffmpeg (o bé altres paquets de
la distribució), us podeu trobar que DashCast us
dóna errors del tipus "Cannot open video file",
perquè es barregen versions de l'ffmpeg i libav
/ if you are using ffmpeg or libav packages from
your distribution, you may find errors like
"Cannot open video file", because several
versions of the libraries are mixed (confirm
with "
ldd DashCast") -
- Solució / Solution:
-
- desinstal·leu els paquets de la distribució, perquè gpac agafi els que acabeu de compilar / uninstall distribution development packages, so as gpac takes the newly compiled files:
-
- ubuntu:
-
sudo apt-get remove libavcodec-dev libavformat-dev libavutil-dev
- comproveu ldd / check ldd
"Cannot open output audio codec" / "Cannot open output audio stream"-
- us hi podeu trobar si feu servir aac com a còdec àudio de sortida amb el DashCast
- solució / Solution:
- "Cannot find a video stream"
-
- Solution:
-
- make sure that ./configure gives:
-
- FFMPEG: system
- L'àudio de sortida (mp2) és soroll estrident / Output audio (mp2) is an annoying noise:
-
- Wrong audio output from DashCast
- Solució / Solution
-
- (?) mp2 output from aac input is not working. Either use aac output or mp2 input.
- dashcast.conf file is not generated
-
- if -conf option is not used, a generic dashcast.conf file should be generated and written, but only after DashCast is cleanly closed (q)
- "Rep v1 UTC diff at segment close: 7769 is lower than cumulated segment duration 15000 (diff -7231) - frame rate is probably not correct or frames were lost !!"
-
- occurs with libav-9.10
- Solution
-
- ??
- si feu servir l'ffmpeg (o bé altres paquets de
la distribució), us podeu trobar que DashCast us
dóna errors del tipus "Cannot open video file",
perquè es barregen versions de l'ffmpeg i libav
/ if you are using ffmpeg or libav packages from
your distribution, you may find errors like
"Cannot open video file", because several
versions of the libraries are mixed (confirm
with "
- compile osmozilla (plug-in for Firefox)
-
urpmi libxulrunner-develcd applications/osmozillamakemake install(as user)- Desenvolupament / Development
-
applications/osmozilla/osmo_npapi.{cpp,h}applications/osmozilla/osmozilla.cpp
- Utilització / Usage
- Problems:
-
- Grey screen
- Crash
-
- Solution:
- compile MP4Client (ja es compila en la compilació general / already compiled in general compilation):
-
cd applications/mp4clientmodify Makefile:-
comment line:-
#rm...
makemake install- MP4Client usage
- compile gpac with OpenSVC
(
gpac/modules/opensvc_dec) -
- compile and install OpenSVC libraries
- modify modules/Makefile (solved in rev 3686):
-
PLUGDIRS=aac_in ... opensvc_dec
- compile gpac
- usage
-
~/.gpacrc-
- You can directly use ctrl+(H,L) or add shortcuts to ~/.gpacrc (during playback, they are taken into account when the MP4Client window has the focus: WINDOW SHORTCUTS):
-
[Shortcuts]
QualityDown=1
QualityUp=2
TemporalIdDown=8TemporalIdUp=9
- In [System] section, check that "codec_04_21" is not associated to "FFMPEG decoder". It must be associated to "OpenSVC Decoder":
-
codec_04_21="FFMPEG decoder"codec_04_21="OpenSVC Decoder"
- In [PluginsCache] section, check that opensvc_dec is not an invalid module.
MP4Client toto_svc.mp4(amb fitxers .264 no funciona bé)- To change layer:
-
- Ctrl+H
- Ctrl+L
- Problems
-
- Segmentation fault
-
- Cause: newest release 285 of OpenSVCDecoder "Add new variable into OPENSVCFRAME structure."
- Solution: get revision 284 of opensvcdecoder:
-
cd opensvcdecodersvn update -r 284
- [Thread MediaManager] Couldn't set priority(2) for
thread ID 0x00000000
[Thread MediaManager] Couldn't set priority(2) for thread ID 0xb1077b70 -
- Solution:
-
- ??
- compile hbbtvplayer
-
- cd applications/hbbtvplayer/hbbtvbrowserplugin
-
chmod +x autogen.sh./autogen.sh./configuremake install
- cd applications/hbbtvplayer/hbbtvterminal
-
- (webkit-1.0 >= 1.5.2)
chmod +x autogen.sh./autogen.sh./configuremake install
- compile with OpenHEVC decoder (HEVC)
- compile gpac
-
[chmod +x configure]- run configure:
-
- cvs:
./configure - svn (portivity):
./configure --disable-ipv6(to avoid error in utils/os_net.c: sin_port) - 0.4.2-rc2:
./configure --use-ffmpeg=local
- cvs:
- to prepare for debugging:
-
- ./configure --enable-debug
- to get an unstripped installed /usr/local/lib/libgpac-xx-DEV.so (to be used by gdb):
-
- src/Makefile: INSTFLAGS= (not INSTFLAGS=-s, which installs a stripped version in /usr/local/lib)
make- (
gcc -O3 -fno-strict-aliasing -Wno-pointer-sign -Wall -I/home/fpinyol/src/svn-portivity/trunk/wp5/gpac_0.4.4/include -DGPAC_HAS_SPIDERMONKEY -DXP_UNIX -I/usr/include/js -c -o laser/lsr_[dec,enc,tables].o laser/lsr_[dec,enc,tables].c) make install- add line to
/etc/ld.so.conf: -
/usr/local/lib
ldconfig
- using kdevelop
-
- Import project: C (?with automake)
- using Eclipse (Indigo) and subversion (SVN)
-
- Setup Eclipse with Subversion
- From scratch:
-
- ...
- From existing and working svn tree:
-
- File -> Import...
- C/C++ / Existing Code as Makefile project
- Existing code location: Browse...
- Toolchain for Indexer Settings: Linux GCC
- Config for using debug:
-
./configure --enable-debug
- Build targets
- using Eclipse and CVS
-
- CVS
-
- File / New / Project: CVS / Projects from CVS
- Create a new repository location
-
- Host:
gpac.cvs.sourceforge.net - Repository path:
/cvsroot/gpac - User:
anonymous - Password:
- Connection type: pserver
- Host:
- Use specified module name: gpac
- Check Out As: Check out as a project configured using New Project wizard
- Select tag: HEAD
- Select a wizard: C / C Project
- Project name: gpac_cvs
- Project types: Makefile project
- Configuration: Default
- cd gpac_cvs; chmod +x configure; ./configure --enable-debug
- Project / Build All
- Build targets
- Build on Eclipse
-
./configure --enable-debug- Make Targets: applications / testapps / broadcaster
-
- gpac
-
- select "gpac"
- Add make target:
-
- Project -> Make target -> Create...
-
- Target name: "gpac_all"
- Make target: "all"
- (?) Deactivate "Run all project builders"
- Build make target:
-
- Project -> Make target -> Build...
- broadcaster
-
- Add make "broadcaster_all" target:
-
- Target name: broadcaster_all
- Make target: all
- Deactivate "Run all project builders"
- Build:
-
- Select "broadcaster_all" / Build Make target
- Add make "broadcaster_clean" target:
-
- Target name: broadcaster_clean
- Make target: clean
- Deactivate "Run all project builders"
- Build:
-
- ...
- Launch an application on debug mode:
-
- Run -> Debug Configurations...
- C / C++ Application
- New
-
- Name: "DashCast_toto"
- Main
-
- C / C++ Application: bin/gcc/DashCast
- Project: gpac
- Arguments
-
- "
-av toto.mp4 -live-media -seg-dur 10000"
- "
- New
-
- Name: "MP4Box_1"
- Main
-
- C / C++ Application: bin/gcc/MP4Box
- Project: gpac
- New
-
- Name: "MP4Box_add"
- Main
-
- C / C++ Application: bin/gcc/MP4Box
- Project: gpac
- Arguments
-
- "-add toto.h264 toto.mp4"
- Debug
-
- Open Debug Dialog / C/C++ Local Application
- Environment:
-
- Variable: LD_LIBRARY_PATH
- Value: .../gpac_cvs/bin/gcc
- step
2:
get GPAC
source:
- DashCast usage
- DashCast modifications (gpac/applications/dashcast)
-
- audio transcode to AAC (instead of MP2) (needed by HbbTV 1.5):
-
- dashcast.conf
-
[a1]
type=audio
bitrate=192000
samplerate=48000
channels=2
codec=aac
- applications/dashcast/audio_muxer.h (not needed anymore?)
-
#include "libavcodec/version.h"
#if (LIBAVCODEC_VERSION_MAJOR>53)
#include "libavutil/channel_layout.h"
#endif
- applications/dashcast/audio_muxer.c, in function dc_gpac_audio_moov_create:
-
//esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_MPEG1;
esd->decoderConfig->objectTypeIndication = GPAC_OTI_AUDIO_AAC_MPEG4;//acfg.base_object_type = GF_M4A_LAYER2;
acfg.base_object_type = GF_M4A_AAC_LC;//audio_stream->codec->sample_fmt = AV_SAMPLE_FMT_S16;
audio_stream->codec->sample_fmt = audio_codec_ctx->sample_fmt;
- applications/dashcast/audio_encoder.c, in function
dc_audio_encoder_open:
-
//p_aout->p_codec = avcodec_find_encoder_by_name("mp2");p_aout->p_codec = avcodec_find_encoder_by_name(p_adata->psz_codec);//audio_output_file->codec_ctx->sample_fmt = AV_SAMPLE_FMT_S16;
if( strcmp(audio_data_conf->codec, "aac") == 0 ) {
audio_output_file->codec_ctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
}
else {
audio_output_file->codec_ctx->sample_fmt = AV_SAMPLE_FMT_S16;
}/* open the audio codec */
AVDictionary *opts = NULL;
if( strcmp(audio_data_conf->codec, "aac") == 0 ) {
av_dict_set(&opts, "strict", "experimental", 0);
}
//if (avcodec_open2(audio_output_file->codec_ctx, audio_output_file->codec, NULL) < 0) {
if (avcodec_open2(audio_output_file->codec_ctx, audio_output_file->codec, &opts) < 0) {
/*FIXME: if we enter here (set "mp2" as a codec and "200000" as a bitrate -> deadlock*/
GF_LOG(GF_LOG_ERROR, GF_LOG_DASH, ("Cannot open output audio codec\n"));
return -1;
}
- avc1 vs avc3 (revision >=4726)
-
- controler.c
-
- avc1:
-
#define VIDEO_MUXER GPAC_INIT_VIDEO_MUXER_AVC1
- avc3:
-
#define VIDEO_MUXER GPAC_INIT_VIDEO_MUXER_AVC3
applications/dashcast/video_encoder.c, in functiondc_video_encoder_open(needed for having SPS and PPS available on video_muxer.c) (solved on revision 4726: avc1)-
p_voutf->p_codec_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER;
applications/dashcast/video_muxer.c, in functiondc_gpac_video_moov_create-
avccfg = gf_odf_avc_cfg_new();- SPS and PPS on init mp4 (modification on video_encoder.c needed. see above) (solved on revision 4726: avc1)
-
int sps_size, pps_size, nal_separator_size;
nal_separator_size = 4; // 00 00 00 01
pps_size = 4;
sps_size = p_video_codec_ctx->extradata_size - 2*nal_separator_size - pps_size;
/*SPS*/
GF_AVCConfigSlot *sl_sps;
sl_sps = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot));
sl_sps->size = sps_size;
sl_sps->data = (char *)gf_malloc(sizeof(char) *sl_sps->size);
memcpy(sl_sps->data, p_video_codec_ctx->extradata + nal_separator_size, sizeof(char)*sl_sps->size);
gf_list_add(avccfg->sequenceParameterSets, sl_sps);
/*PPS*/
GF_AVCConfigSlot *sl_pps;
sl_pps = (GF_AVCConfigSlot*)gf_malloc(sizeof(GF_AVCConfigSlot));
sl_pps->size = pps_size;
sl_pps->data = (char *)gf_malloc(sizeof(char) * sl_pps->size);
memcpy(sl_pps->data, p_video_codec_ctx->extradata + sps_size + 2*nal_separator_size, sizeof(char)*sl_pps->size);
gf_list_add(avccfg->pictureParameterSets, sl_pps);
- avc1 instead of avc3 (inband). (Needed by HbbTV 1.5) Comment the following fragment: (solved on revision 4726: avc1)
-
/*
gf_odf_avc_cfg_del(avccfg);
//printf("time scale: %d \n",
// p_video_codec_ctx->time_base.den);
ret = gf_isom_avc_set_inband_config(p_voutf->p_isof, track, 1);
if (ret != GF_OK) {
fprintf(stderr, "%s: gf_isom_avc_set_inband_config\n",
gf_error_to_string(ret));
return -1;
}
*/
- size on [tkhd] and [avc1]:
-
u32 width, height;
width=640;
height=360;// set size in [tkhd]
gf_isom_set_track_layout_info(p_voutf->p_isof, track, width<<16, height<<16, 0<<16, 0<<16, 0);// set size in [avc1]
// requires adding GF_EXPORT before "GF_Err gf_isom_set_visual_info(GF_ISOFile...",
// in file src/isomedia/isom_write.c
ret = gf_isom_set_visual_info(p_voutf->p_isof, track, di, width, height);
- alternate brand:
-
// set alternate brand
gf_isom_modify_alternate_brand(p_voutf->p_isof, GF_4CC('a','v','c','1'), 1);
- other modifications to avccfg:
-
// other modifications to avccfg
avccfg->AVCLevelIndication = 31;
ret = gf_isom_avc_config_update(p_voutf->p_isof, track, di, avccfg);
ret = gf_isom_finalize_for_fragment(p_voutf->p_isof, 1);
- Linux usage
-
- Fonts
-
- import MSWindows fonts
-
- Mandriva Control Centre / System / Manage Windows fonts / Obtain Windows fonts
- modify ~/.gpacrc:
-
[FontEngine]
FontDirectory=/usr/share/fonts/drakfont/ttf
- MS Windows compilation
-
- get GPAC source:
- compile gpac_extra_libs
- compile ffmpeg
- install MSYS in c:\msys (from minGW / Download / Current)
MSYS_1.0.10.exe
- install MinGW in c:\MinGW (from minGW / Download / Current) (use f.i. 7zip to untar)
- MinGW Runtime:
mingw-runtime-3.9.tar.gz
- Windows API:
w32api-3.6.tar.gz
- binutils:
binutils-2.15.91-20040904-1.tar.gz
- GCC:
gcc-core-3.4.2-20040916-1.tar.gz, gcc-g++-3.4.2-20040916-1.tar.gz
- copy needed tools from MS Visual:
- copy c:\Archivos de programa\Microsoft Visual Studio .NET 2003\Vc7\bin\lib.exe, link.exe -> c:\MinGW\bin
- copy c:\Archivos de programa\Microsoft Visual Studio .NET 2003\Common7\IDE\mspdb71.dll -> c:\MinGW\bin
- Start / MinGW / MSYS / msys.exe
- some checks
cd /c/.../gpac_extra_libs/lib
mkdir w32_deb w32_rel- edit /c/.../gpac_extra_libs/libavformat/Makefile and fix the bug:
cp avcodec... should be:cp avformat...
cd /c/.../gpac_extra_libs/ffmpeg./configure --enable-shared --disable-debug --enable-memalign-hackmake
- compile the rest of gpac_extra_libs with MS Visual:
- Open build\msvc6\BuildAll.dsw
- Batch Build
- compile gpac with MSVisual 6.0
-
- Open gpac\build\msvc6\gpac.dsw
- set gpac_dll as active (StartUp) project
- Build libgpac_dll
- compile gpac with MSVisual 2005 (svn portivity)
-
- open build/win32/win32.sln
- check "Solution Platforms": Win32
- for computers with HT or dual core: set 1 parallel process
- Build solution
- MS Windows Mobile compilation
-
- Be sure you have VS2005 and WM 5.0 Developer Resource Kit installed
- From the VS2005 open the solution file for WM5 located at: <download folder>\build\wm5\wm5.sln
- Select the correct solution configuration and platform (Debug/Release and Windows Mobile 5.0 Pocket PC SDK (ARMV4I)
- Connect you device using the USB cable and verify that you can communicate with it (Explore from the ActiveSync)
- Compile and deploy as usual
09VideoLAN#
- Compilació/Compilation VLC:
-
- Dependències / Dependences:
-
- Mageia
-
- 64b:
-
urpmi lib64lua-devel lib64mad-devel lib64a52dec-devel lib64xcb-devel lib64xml2-devel lib64gcrypt-devel
- 32b:
-
urpmiautoconf automake libtool-baseurpmi liblua-devel libxpm-devellibqt4-devel libmad-devel libgcrypt-devel gcc-c++[liba52dec-devellibffmpeg-devel]
- Ubuntu
-
sudo apt-get install autoconf libtoolsudo apt-get installliblua5.2-dev lua5.2 libmad0-dev liba52-0.7.4-dev libxcb-shm0-dev libxcb-composite0-dev libxcb-xv0-dev libxml2-dev libxcrypt-dev libgcrypt20-dev libdvbpsi-dev
- option 1: from git
-
cd /usr/include; ln -s libxml2/libxmlgit clone git://git.videolan.org/vlc.git[git pull]
- option 2: from tarball
-
wget http://download.videolan.org/pub/videolan/vlc/2.1.4/vlc-2.1.4.tar.xztar xvJf vlc-2.1.4.tar.xz
cd vlc./bootstrap./configure [--disable-mkv]-
- when using your own ffmpeg compiled and installed in /usr/local/lib (needed for Mageia, not for Ubuntu):
-
./configurePKG_CONFIG_PATH=/usr/local/lib/pkgconfig/
make cleanmakemake install- Problemes / Problems
-
- blend.c not found
-
- Solution:
-
- cd modules/video_filter/
- ln -s blender.cpp blender.c
- Compilació/Compilation VLC amb/with MPEG-DASH plugin (build instructions):
-
- IMPORTANT: "The DASH plugin is officially part of VLC and could be checked out through the GIT repository."
(?) urpmi gettext-develurpmi liblua-devel libxpm-devellibqt4-develcd /usr/include; ln -s libxml2/libxmlgit clone git://git.videolan.org/vlc.gitgit checkout 6cc89ae733784777ccad8cabd7786cc1c801089fcd vlc- Apply patch:
-
wget http://www-itec.uni-klu.ac.at/dash/wp-content/dash/dash_stream_0_3_0_0.tar.gztar xvzf dash_stream_0_3_0_0.tar.gzgit apply 0001-Added-DASH-stream-filter.patch- Problem: "...patch does not apply"
-
- Solution: get commit 6cc89ae733784777ccad8cabd7786cc1c801089f
-
git checkout 6cc89ae733784777ccad8cabd7786cc1c801089f
./bootstrap./configure --disable-mkvmakemake install- Try it:
-
./vlc mtbike.mpd- Dataset
- Problems:
-
- "segmentation fault"
-
- Solution:
-
rm -rf ~/.local/share/vlc/
- dmesg: "
vlc[13127]: segfault at ffffffa4 ip b75b506d sp bfafba94 error 4 in libpthread-2.12.1.so[b75ad000+15000]" -
- Solution:
-
- ??
- Compilació/Compilation VLMC (editor)
-
- Dependències / Dependences
-
- Mageia
-
urpmi cmake libvlc-devel libqt4-devel frei0r-plugins
git clone git://git.videolan.org/vlmc.gitmkdir build && cd buildcmake ..makemake package
10OpenSVC#
- mplayer compilation
-
- RTSP/RTP streaming support for MPlayer (Live555)
- dependencies
-
- Mageia 1:
-
urpmi make libvdpau-devel live-devel live libdirac-devellibxv1-devellibopenjpeg-devellibjpeg-devellibSDL-devellibpulseaudio-develliba52dec-devel
- Mandriva
urpmi libvdpau-devel libfaac-devel live-devel live libdirac-devellibxv1-devellibopenjpeg-devellibjpeg-devellibSDL-devellibpulseaudio-develliba52dec-devel
- get the code
-
svn co https://opensvcdecoder.svn.sourceforge.net/svnroot/opensvcdecoder opensvcdecoder[svn update]
- compile
-
cdopensvcdecoder/Mplayer./configure --enable-svc --enable-menumake
- installation
-
make install(it will install to/usr/local/bin/mplayer)- [install OpenSVC libraries]
- with Eclipse:
-
./configure --enable-svc --enable-menu --enable-debug- In C/C++ Perspective -> Make Target (second tab on right panel) -> select Mplayer -> New...
-
- Target name: all
- usage
-
- (file.mp4 must be coded using JSVM)
mplayer -fps 25 video_5.264[-setlayer DQId -settemporalid temporal_id]mplayer -fps 25 -aspect 16:9 video_1.264- keys
-
- "l", "b": lower/higher level (DQId)
- ";", ",": lower/higher temporal level (temporal_id)
- compilació de només les biblioteques / only libraries compilation (per a ser utilitzades, per exemple, amb GPAC MP4Client)
-
- dependencies
-
- Mageia 1
-
urpmi cmake gcc-c++ libSDL-devel
- compilation
-
cd opensvcdecoder/Libscmake CMakeLists.txtmake
- installation
-
make install(it will install/usr/local/lib/libOpenSVCDec.so)
- with Eclipse:
-
- In C/C++ Perspective -> Make Target (second tab on right panel) -> select Libs -> New...
-
- Target name: all
- player usage
-
Libs/OpenSVCDecoder -h264video_5.264-layer DQId -tempID temporal_id
- GPAC with OpenSVC
11SVC reference software (JSVM)#
- Modules:
-
- DownConvertStatic
- H264AVCEncoderLibTestStatic
- H264AVCDecoderLibTestStatic
- AvcRewriter
- BitStreamExtractorStatic
- QualityLevelAssignerStatic
- MCTFPreProcessor
- PSNRStatic
- FixedQPEncoderStatic
- SIPAnalyser
- YUVCompareStatic
- Compilació / Compilation
-
- dependencies
- get the code
-
- GitHub
-
- floriandejonckheere/jsvm
- cvs (outdated)
-
cvs -d :pserver:jvtuser:xxxxx@garcon.ient.rwth-aachen.de:/cvs/jvt logincvs -d :pserver:jvtuser@garcon.ient.rwth-aachen.de:/cvs/jvt checkout jsvmcvs update
- compile
cd jsvm/JSVM/H264Extension/build/linuxmake
- Utilització / Usage
-
H264AVCEncoderLibTestStatic -pf encoder.cfg- example configuration files:
-
JSVM/H264Extension/dataJSVM0-config-samples
- AVC / MVC:
-
- encoder.cfg
-
- AVCMode 1
- InputFile toto.yuv
- OutputFile toto_avc.264
- ReconFIle toto_recon.yuv
- SourceWidth win
- SourceHeight hin
- FrameRate fps
- FramesToBeEncoded frames
SequenceFormatString(A: IDR intra; I: non-IDR intra; P: predicted: B: bidirectional) (upper case: to be used as reference; lower case: not to be used as reference):-
- A0*2{P2b0b1}
- A0*1{P2P5P8b0b1b3b4b6b7b9b10}
- ...
GOPSize, IntraPeriod, IDRPeriodnot working? Only for SVC (AVCMode 0)?
- SVC
-
- Number of layers:
-
- Spatial or CGS quality (D):
-
NumLayers
- MGS quality (Q):
-
MgsVectorModeMGSControl
- Temporal (T)
-
- log_2(
GOPSize) + 1
- log_2(
- Preparation:
-
- DownConvertStatic win hin toto.yuv w1 h1 toto_w1xh1.yuv method t skip frames
- DownConvertStatic win hin toto.yuv w2 h2 toto_w2xh2.yuv method t skip frames
- encoder.cfg
-
- [AVCMode 0]
- OutputFile toto_svc.264
- GOPSize
- IntraPeriod
- IDRPeriod
- NumLayers
- LayerCfg cfg/layer0.cfg
- LayerCfg cfg/layer1.cfg
- ...
- cfg/layer0.cfg
-
- InputFile orig/toto_w1xh1.yuv
- IntraPeriod
- IDRPeriod
- cfg/layer1.cfg
-
- InputFile orig/toto_w2xh2.yuv
- IntraPeriod
- IDRPeriod
- ...
12Butterflow#
- Motion interpolated videos
- Instal·lació / Installation
-
- Dependències / Dependencies
-
- Mageia
-
urpmi task-c++-devel lib64ffmpeg-devel python-numpy-devel
git clone https://github.com/dthpham/sminterpolate.gitcd sminterpolate- setup.py
-
np_includes = '/usr/lib64/python2.7/site-packages/numpy/core/include'
virtualenv env; source env/bin/activatepython setup.py develop
13libdash#
- How to use (libdash README.md)
- Dependencies
-
- Mageia
-
urpmi cmake lib64curl-devel
- Download
-
git clone git://github.com/bitmovin/libdash.git libdash
- Compilation(libdash)
-
cd libdash/libdashmkdir buildcd buildcmake ..makecd bin./libdash_networpart_test
- sampleclient compilation
-
- Dependencies
-
- Mageia
-
- urpmi lib64SDL-devel
- Problems
-
- error: ‘UINT64_C’ was not declared in this scope
-
- Solution
- mv sdl sdl_old
Renderer/SDLRenderer.h-
#include <SDL/SDL.h>
#include <SDL/SDL_thread.h>
Renderer/IVideoObserver.h-
#ifdef __cplusplus
#define __STDC_CONSTANT_MACROS
#ifdef _STDINT_H
#undef _STDINT_H
#endif
# include <stdint.h>
#endif
#ifndef UINT64_C
#define UINT64_C(c) (c ## ULL)
#endif
error : Sleep was not declared in this scope-
- Solution
-
- Decoder/LibavDecoder.cpp
-
#include <unistd.h>
...
sleep...
- cd libdash/libdash
- CMakeLists.txt
-
- add_subdirectory(sampleplayer)
- cd build
- cmake ..
- make
- qtsampleplayer compilation
-
- Dependencies
-
- Mageia
-
- urpmi lib64qt5widgets-devel lib64qt5multimedia-devel lib64qt5network-devel lib64qt5multimediawidgets-devel lib64qt5opengl-devel
- cd libdash/qtsampleclient
-
- CMakeLists.txt
-
set(CMAKE_PREFIX_PATH /usr/lib64/qt5/lib/cmake/)
- cd libdash/libdash
- CMakeLists.txt
-
- add_subdirectory(qtsampleplayer)
- cd build
- cmake ..
- make
- Problems
-
- error: ‘usleep’ was not declared in this scope
-
- Solution
-
- libdashframework/Portable/MultiThreading.h
-
#include <unistd.h>
- Usage
-
- ..
14Bento4#
- Get the source (choose one of the following methods)
-
- tarball
- subversion
-
- mkdir ~/src; cd ~/src/
- First time
-
svn checkout https://zebulon.bok.net/svn/Bento4/trunk bento4svn checkout http://www.bok.net/svn/Bento4/trunk Bento4
- Next times
-
svn update
- Prerequisites
-
urpmi gcc-c++ scons
- Compile
-
cd~/src/Bento4scons
- Binaries
-
- ~/src/Bento4/Build/Targets/x86_64-unknown-linux/Debug/
- Installation
-
- cd /usr/local/bin
- su; ln -s ~/src/Bento4/Build/Targets/x86_64-unknown-linux/Debug/* .
- Documentation
-
- ~/src/Bento4/Documents/SDK/Bento4_SDK_documentation.pdf
- unzip ~/src/Bento4/Documents/Doxygen/Bento4-HTML.zip
- ~/src/Bento4/Documents/Doxygen/Bento4-HTML/index.html
15LASeR reference software#
- Install eclipse
- Download ref_software_2007-01-26.zip (w8869) from MPEG site
(access needed)
mv LASeRCodec1206 LASeRJPlayer1206 ~/workspace
- Download and install Sun's J2ME Wireless Toolkit (WTK)
- Download and install eclipseme, a J2ME plugin from eclipse. On the web site, there are detailed instructions for setting up the plugin and for linking it with the WTK.
- From Eclipse, create a new Java Project, and give it the name of the directory you put into the workspace (eg. LaserJPlayer, J2ME_Renderer). Eclipse will import the project (the source files and the libraries). It is recommended to have different source/output directories (see "Window/Preferences/Java/Build path" before creating the project)
- Convert the newly created project into a J2ME project (right click on the project, J2ME/Convert to J2ME Midlet Suite). Select the MIDP 2.0 Platform
- Change the build settings as following. Right click on the project, Properties, Java Build Path, Order and Export - check library.jar.
- Add some .lsr input files. For doing that, create a new source
directory - eg res (right click on your project, New Source
Folder). Put inside the .lsr files, and rebuild
(if you have automatic build turned on - which is the case by default - right click on the directory, and click Refresh) - In the file iso.mpeg.streamezzo.player.tool.SceneLoader, you should change the INIT_LASER_URL attribute according to the input file you wish to play.
- For executing / debugging, right click on iso.mpeg.streamezzo.player.tool.LASeRPlayer, Run as / Debug as Emulated J2ME Midlet
16Subtítols / Subtitles#
- Conversió de subtítols / Subtitle conversion
- TV subtitles
- Validadors
- Estàndards / Standards
- DVB subtitles
- SMPTE Timed Text
- EBU TT
- W3C TTML
- CEA-708 Digital Television (DTV) Closed Captioning
- 3GPP Timed Text
- WebVTT
- SRT
- SRT Subtitles (Matroska technical)
- Generació de subtítols de test:
- generate_subtitles.sh
#!/bin/bash
# Usage: $(basename $0) >ca.srt
segment_duration=10.0
# e.g.: 00:00:54,400
total_duration=$1
# https://www.matroska.org/technical/subtitles.html#srt-subtitles
# 1
# 00:02:17,440 --> 00:02:20,375
# Senator, we're making
# our final approach into Coruscant.
#
# 2
# 00:02:20,476 --> 00:02:22,501
# Very good, Lieutenant.
segment_start="00:00:00,000"
segment_end=${segment_start}
segment_index=1
while [[ ${segment_end} < ${total_duration} ]]
do
segment_end=$(date -u -d "0 $(date -u -d "${segment_end}" +"%s,%03N") sec + $(date -u -d @"${segment_duration}" +"%s,%03N") sec" +"%H:%M:%S,%03N")
if [[ ${segment_end} > ${total_duration} ]]
then
segment_end=${total_duration}
fi
echo "${segment_index}"
echo "${segment_start} --> ${segment_end}"
echo "first line (${segment_start} --> ${segment_end})"
echo "second line (${segment_start} --> ${segment_end})"
echo
segment_start=${segment_end}
(( segment_index++ ))
done
# include to an mp4 file:
# ffmpeg -i input.mp4 -f srt -i input.srt \
# -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \
# -c:s mov_text output.mp4
# include to an mkv file:
# ffmpeg -i input.mp4 -f srt -i input.srt \
# -map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy \
# -c:s srt output.mkv
exit
- create_video_audio_subtitles.sh
- resize resulting file:
ffmpeg -i multi.mp4 -map 0 -vf scale=w=1280:h=720 -c:a copy -c:s copy multi_720p.mp4ffmpeg -i multi.mp4 -map 0 -vf scale=w=640:h=360 -c:a copy -c:s copy multi_360p.mp4
- generate_subtitles.sh
17Còdecs vídeo / Video codecs#
- Codecs (Videolan Wiki)
- Video codecs (Wikipedia)
- Video codecs (MultimediaWiki)
- Royalty-free codecs (Open Video Alliance)
- List of open source codecs (wp)
- Video encoding (Doom9)
- Llicències / Licenses
- MPEG-LA
- Via Licensing
- Licensing issues with H.264 video
- MPEG LA: H.264 streaming will be free forever
- Linux
- Why should we pay for codecs when working on Linux (Fluendo)
- The role of legal codecs in Linux installs (pdf) (Fluendo)
- FAQ (Fluendo)
- Videolan
FAQ (pdf) (Videolan)
- 3.4. What about personal/commercial usage?
- Comercial / Commercial
- HTML5
video
- HTML5 & Standards
- The State of HTML5 Video (JW Player)
- HTML5 video and codecs
- HTML5, ¿Con que códec nos quedamos H.264 o VP8?
- YouTube HTML5
- YouTube y Vimeo soportan HTML5 ¿comienza el fin de Flash?
- Decoding the HTML 5 video codec debate
- Google to Open-source VP8 for HTML5 Video
- Video for everybody
- HTML5 video (w3schools)
- "Towards Video on the Web with HTML5" (NEM Summit 2010)
- HTML5Video (demos)
- HTML5 video tutorial (HTML5Rocks)
- HTML5 Video Events and API (demo: playbackRate, ...) (requires Chrome/Chromium)
- Video on the web (W3c presentation)
- HTML encoding secrets (video)
- Video on the Web
- Videollamada en WebKit directamente desde HTML5
- Reproductors / Players
- Edició / Edition
- Streaming
- WebM streaming
- Why Flash is better than HTML5 for your live webcast (browsers table)
- Streaming via RTSP or RTP in HTML5
- Real-time video streaming with HTML5 (pdf) (Master's Thesis | Lund University 2014)
- Demos, tutorials
- Moving the Timeline Position (Tizen)
- Jumping
to
time offsets in HTML5 video
- currentTime
- timeupdate
- Media Fragments
- Video Timeline using HTML5 and javascript
- Subtítols / Subtitles
- WebVTT (Web Video Text Tracks)
- Info
- WebVTT and Video Subtitles
- Video Subtitling and WebVTT (HTML5 Doctor)
- Subtitles, Captions, WebVTT, HLS, and those magic flags (Mux)
- Recent developments around WebVTT (2011)
- Getting Started With the Track Element
- JavaScript: HTML5 Video with SRT Subtitles
- Understanding WebVTT file format (draft)
- WebVTT Presentation
- Demos
- HTML Video books (code) (Silvia Pfeiffer)
- Positioning WebVTT In Firefox
- Using JSON with the HTML5 video track element
-
text track kind
track element
subtitles
captions
descriptions
chapters
metadata
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- Specification
- Structure
WEBVTT
[STYLE ...]
[REGION ...]
[NOTE ...]
[cue_id]
[hh:]MM:ss.mmm --> [hh:]MM:ss.mmm [cue_settings]
[tag_begin]text line[tag_end]
[tag_begin]text line[tag_end]
...
[NOTE ...]
[cue_id]
[hh:]MM:ss.mmm --> [hh:]MM:ss.mmm [cue-settings]
[tag_begin]text line[tag_end]
[tag_begin]text line[tag_end]
...- cue-settings
-
key
values
(comma separated)
description
align:
- right,left,center
line:
position:
- xx%
- [line-left,line-right]
- percentage of the width (height if vertical) of the video viewport
- ...
region:
region
size:
- xx%
cue box size (percentage of the video viewport)
vertical:
- {lr,rl}
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- tags (cue
components)
-
tag
description
example
b
bold
<b>text</b>
c
class
<c.my_class_name>
i
italic
lang
language
ruby
ruby
rt
ruby text
u
underline
v
voice
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
-
- STYLE
::cue(v[voice="Esme"]) { color: cyan }
::cue(v[voice="Mary"]) { color: lime }
::cue(i) { font-style: italic }
::cue(.loud) { font-size: 2em }
- REGION
- Conversió / Conversion
- from srt
to webvtt:
ffmpeg -i toto.srt -f webvtt toto.webvtt
- from srt
to webvtt:
- Players
- HTML5 video
<video width="640" height="480" controls>
<source src="video.mp4" type="video/mp4" />
<source src="video.webm" type="video/webm" />
<track src="subtitles.vtt" kind="subtitles" srclang="en" label="English" />
<!-- fallback for rubbish browsers -->
</video>
- Navegadors / Browsers
- WebVTT - Web Video Text Tracks (CanIuse)
- Tracks & WebVTT (JWPlayer)
- Firefox
- Adding
captions
and subtitles to HTML5 video (MDN)
- close captions menu in controls
- about:config
media.webvtt.enabledmedia.webvtt.regions.enabled
- Bug 981280 - WebVTT / HTML5 track support too buggy to switch it on
- Adding
captions
and subtitles to HTML5 video (MDN)
- Problems
Access to Text track at 'file:///...vtt' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.- Solució / Solution
- use Firefox
- controls?
- use an http server
google-chrome --disable-web-security --user-data-dir=$HOME/.config/google-chrome/Default
- use Firefox
- Solució / Solution
- hls.js
- HTML5 video
- Info
- WebVTT (Web Video Text Tracks)
- Sincronització / Synchronisation
- Standards
- Timing object (W3C)
- Implementacions / Implementations
- Shared Motion (JavaScript) (Motion Corporation)
- Carnival (yt)
- Standards
- Position and timeline
- HTML5 audio
| file ext | file (UNIX) | MPEG-4 RA | FOUR CC | license
|
used
by |
||||
|---|---|---|---|---|---|---|---|---|---|
| handler | codec (1) | ||||||||
| MPEG | MPEG-1 | part 2 |
|||||||
| MPEG-2 | part 2 |
.m2v | MPEG sequence, v2, MP@ML progressive Y'CbCr 4:2:0 video,
CCIR/ITU PAL 625, 25 fps |
MP2V | |||||
| MPEG-4 | part 2: [advanced] simple profile |
.m4v | MPEG sequence, v4, video, [advanced] simple | vide | mp4v | MP4V | |||
| part 10: AVC/H.264 | .264 | JVT NAL sequence, H.264 video | avc1 | AVC1 | FLV, F4V, ... |
||||
| avc2 |
|||||||||
| avc3 (amdt2)(*) |
|||||||||
| svc1 |
|||||||||
| Apple |
ProRes (wp) |
||||||||
| Avid |
DNxHD (wp) | ||||||||
| Microsoft | WMV | ||||||||
| VC-1 | vc-1 | ||||||||
| Real Networks | RealVideo | ||||||||
| Xiph.org |
Theora (based on VP3) |
||||||||
| BBC |
Dirac (VC-2) | drac | - | ||||||
| Streambox |
ACT-L3 |
||||||||
| Adobe |
Flash Video |
FLV1 |
|||||||
| On2 (Google) |
VP3 |
Theora | |||||||
| VP6 (wp) |
|||||||||
| with alpha |
VP6A |
FLV |
|||||||
| VP8 |
|||||||||
| Sorenson |
Sorenson Video / SVQ |
QuickTime |
|||||||
| Sorenson Spark / H.263 |
FLV | ||||||||
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
- As shown by:
- vlc: Tools / Codec information
- mplayer: "VIDEO: [xxxx]"
- (ffmpeg shows "h264" instead of avc1)
- H.264
- On2 (Google) (wp)
- Dirac
(BBC
Research) (wp)
urpmi vlc-plugin-schroedinger dirac-utils- Dirac
Pro ?Light Compression? (pdf) (BBC) (EBU Technical)
- Dirac-Pro users: ORF (Austrian national broadcaster), Westminster Live, Asia Television ? Hong Kong, Television Broadcasts Limited (TVB) ?Hong Kong,Rainbow Media ? New York, Cambridge University & Essex University, BBC ? Beijing Olympics, OBs, Pacific Quay
- Evaluation of Dirac and Theora
- Performance Comparison of Emerging Dirac Video Codec with H.264/AV (IEEE): quality factor.
- COMPARISON OF OPEN AND FREE VIDEO COMPRESSION SYSTEMS A Performance Evaluation Till Halbach
- Theora (wp)
- Cortado (Java applet decoder) (Fluendo)
- YouTube / Ogg/Theora comparison
- ACT-L3 (Streambox)
- VPX: VP8, VP9
- WebM Project
- Users (supported players and browsers)
- Specs
- RTP payload
- libvpx
compilation
- Dependencies
- Mageia
urpmi yasm
- Mageia
- get source (one of the following):
git clone https://chromium.googlesource.com/webm/libvpxgit clone https://github.com/webmproject/libvpxmkdir libvpx
cd libvpx
version=v1.9.0
#version=v1.8.2
#wget https://chromium.googlesource.com/webm/libvpx/+archive/${version}.tar.gz
# https://github.com/webmproject/libvpx/archive/v1.9.0/libvpx-1.9.0.tar.gz
wget https://github.com/webmproject/libvpx/archive/v${version}/libvpx-${version}.tar.gz
tar xvzf ${version}.tar.gz
cd libvpx
./configuremakemake install- (compile
ffmpeg with
--enable-libvpx) - Usage:
ffmpeg ... -c:v libvpx_vp8 ...ffmpeg ... -c:v libvpx_vp9 ...
- Problemes / Problems
test/sad_test.cc:543:3: note: in expansion of macro ?DECLARE_ALIGNED?
DECLARE_ALIGNED(kDataAlignment, uint32_t, exp_sad[4]);- Issue 1690: Can't build using GCC 4.8.5/centOS
- Issue 1690 in webm: Can't build using GCC 4.8.5/centOS
- Build FFmpeg almost fully automatically on Linux (compatible with CentOS, Ubuntu, etc.) (original in Japanese)
- Solució / Solution
- ...
- Dependencies
- HTML5 video
- VP8 Data Format and Decoding Guide (IETF RFC draft-bankoski-vp8-bitstream)
- WebM VP8 vs. MPEG-4/H264 (*)
- Technical Overview of VP8, an Open Source Video Codec for the Web (AVCC / ICME 2011)
- The first in-depth technical analysis of VP8 (Diary Of An x264 Developer)
- H.264/AVC and VP8 performance analysis for consumer videoconference applications (STM) (EBU Broadthinking webinar)
- On2 VP8
- Rate distortion performance of VP8 (WebP and WebM) when compared to standard image and video compression techniques (MMSPG EPFL)
- NewTeeVee
- WebM Project
- Multiview
- Eye Vision (CMU / Super Bowl)
- iview (BBC)
- Multi view demo
- Apple 4K
- Low bit-rate
- Question about HDTV: several resolutions at 1Mbps
18Còdecs àudio / Audio Codecs#
- Audio codecs (Wikipedia)
- Digital Audio Formats (The MP3 and Internet Audio Handbook)
- The Computer Music Guide to Digital Audio Formats
- Examples of audio coding (AC-2, AC-3, PAC, ATRAC)
- Leopold's Comparison Between Audio Formats
- Samples per frame:
samples/frame
sample format
info
standard
flag
MPEG-1,2
384
576
1152 s16p
- 3 groups * 12 samples * 32 subbands
- MP3 (Hydrogenaudio knowledgebase)
MPEG-4, AAC
1024
fltp
ISO/IEC 14496-3 subpart 4. frameLengthFlag=0 960
frameLengthFlag=1 AC3
1536
- 6 groups * 256 samples
- Dolby Digital Audio CD explained
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
Aquesta taula continua cap a la dreta — desplaça-la o gira el mòbil.
19Còdecs d'imatges / Image codecs#
- WebP (Google, based on VP8/webM)
- Cru / Raw
- Visualitzador / Viewer
- ImageMagick
http://www.francescpinyol.cat/formats_av.html
Primera versió / First version: 3.IV.2006
Darrera modificació: 30 de maig de 2026 / Last update: 30th May
2026