Conversió / Conversion
|
- Programari/software
- HOWTO
Convert video files
- MPEG4IP
- rgb2yuv
- yuvdump (YUV
viewer)
- Using MJPEG-tools
- Using ffmpeg (options, more
options, ffmpegX
options)
(i: input file; b: bitrate; r: framerate; s: size; f: container/ES_type)
ffmpeg
[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
[output_file]] [options -newaudio] [options -newvideo]
- -map input_file:index
- example:
- ... -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
- info output is written to stderr (stdout is
used for media data)
ffmpeg -i toto.mp2 toto.aac 2>toto.log
- Read from 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
- -
vpre
/usr/share/ffmpeg/libx264-*.ffpreset
ffmpeg -formats
- H.264
- Specific formats
- Android video
- Converting
Videos For The
Android T-Mobile G1 Phone With Linux
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
- TomPlayer video
ffmpeg -i toto.xxx -vcodec mpeg4 -b
700k
-s 480x272 toto.avi
- iPhone
video
- iPod
video
- iPod
(Videolan)
- iPod
video guide
- 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
- 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
- Just copy the audio
ES
- Start
from time (-ss) hh:mm:ss[.xxx],
during duration (-t):
ffmpeg ... -ss hh:mm:ss[.xxx]
-t hh:mm:ss[.xxx] ...
- specify
-ss before -i
to avoid anything but key frames: much faster (*)
- General (ts -> h264/MP4) (plf
needed):
ffmpeg -i toto.ts -vcodec
{h264,libx264} -s 320x240 -r 15 -b 1000 -f mp4 toto.mp4
- 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 .yuv
file (-s must be the first
parameter):
ffmpeg -s 704x576 -i
toto_704x576.yuv -f mp4 -vcodec {h264,libx264}
toto.mp4
- To .yuv file:
ffmpeg -i toto.mp4 toto.yuv
- Video codecs
- MPEG-4
SP (simple
profile):
- 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:
-
| -[v]profile |
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 |
|
- 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
- I-frames
only
- B-frames
ffmpeg ... -bf number ...
- image -> video
- Make a Video File from a Single Frame:
ffmpeg -loop_input -vframes
<number_of_frames> -i <input_file> <output_file>
- 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 several
png files:
ffmpeg -i toto%02d.png -f mp4
-vcodec {h264,libx264}
toto.mp4
- 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
- video -> images
- 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
- ffmpegthumbnailer
- Extract all frames from file into several
jpeg files:
ffmpeg -i toto.mp4 toto%d.jpeg
- Multiple
thumbnails:
ffmpeg -ss $i*$interval -i intro.mov
-vframes 1 -s 320x240 thumb_$i.jpg
- Extract one
frame every 1 second (-r 1) to
several jpeg images:
ffmpeg -i toto.mp4 -r 1
toto%d.jpeg
- every 10 seconds:
ffmpeg -i toto.mp4
-r 1/10
toto%d.jpeg
- ffmpeg-php
- Generating
Video Thumbnail Storyboards
- Making
thumbnails for movies with ffmpeg
- Relació
d'aspecte / Aspect ratio
- 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
|
16:9
|
| 720x576 |
720x576 |
4:3
|
720x576
|
-
|
-s 540x576
-padleft 90 -padright 90
-aspect 16:9
|
768x576
|
-s
720x576
-aspect 4:3 |
14:9
|
720x576
|
-s 720x492
-padtop 42 -padbottom 42
-aspect 4:3
|
-s 630x576
-padleft 44 -padright 46
-aspect 16:9
|
896x576
|
16:9
|
720x576
|
-s 720x432
-padtop
72 -padbottom
72
-aspect 4:3 |
-
|
1024x576
|
-s
720x576
-aspect 16:9
|
- 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
- Extraction
- 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
- [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
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
- 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 ...
- Multiplex
ES:
ffmpeg -i toto.h264 -i
toto.aac -vcodec copy -acodec copy toto.mp4
- Metadades / Metadata
- Sobreimpressió
/ Superimpose
- Conversió automàtica / Automatic conversion
- 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
|
. |
Còdecs
vídeo / Video codecs
|
|
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
|
|
|
|
|
|
|
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 |
- As shown by:
- vlc: Tools / Codec information
- mplayer: "VIDEO: [xxxx]"
- (ffmpeg shows "h264" instead of avc1)
|
Còdecs
àudio / Audio Codecs
|
|
|
|
Còdecs d'imatges / Image
codecs
|
- WebP (Google,
based on VP8/webM)
|
|