ffmpeg
转换格式ffmpeg -i input.mp4 -vcodec h264 output.mp4
ffmpeg -i input.mp4 -vcodec mpeg4 output.mp4 这个支持微信播放
转换ts
ffmpeg -i b.mp4 -codec copy -bsf h264_mp4toannexb a.ts
ffmpeg -i input.mp4 output.avi ffmpeg -i input_file -vcodec copy -an output_file_video //分离视频流 ffmpeg -i input_file -acodec copy -vn output_file_audio //分离音频流
=================================================
合并:
ffmpeg -i 1.mp4 -qscale 0 1.mpg ffmpeg -i 2.mp4 -qscale 0 2.mpg cat 1.mpg 2.mpg | ffmpeg -f mpeg -i - -qscale 0 -vcodec mpeg4 output.mp4
合并2
ffmpeg -i myfile1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts ffmpeg -i myfile2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts // now join ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
ffmpeg -i input1 -i input2 -c copy -map 0 -map 1 output.mkv
===============================
=================================================
合并frames
In this example the input images are sequentially named img001.png, img002.png, img003.png, etc. ffmpeg -framerate 24 -i img%03d.png output.mp4
For example if you want to start with img126.png then use the -start_number option: ffmpeg -start_number 126 -i img%03d.png -pix_fmt yuv420p out.mp4
ffmpeg -framerate 10 -pattern_type glob -i '*.jpg' -c:v libx264 -pix_fmt yuv420p out.mp4
You can use cat or other tools to pipe to ffmpeg: cat *.png | ffmpeg -f image2pipe -i - output.mkv
single image
Example with output video duration set to 30 seconds with -t 30: ffmpeg -loop 1 -i img.jpg -c:v libx264 -t 30 -pix_fmt yuv420p out.mp4
add audio to your images
If you want to add audio (e.g. audio.wav) to one "poster" image, you need -shortest to tell it to stop after the audio stream is finished. The internal AAC encoder is used in this example, but you can use any other supported AAC encoder as well: ffmpeg -loop 1 -i img.jpg -i audio.wav -c:v libx264 -c:a aac -b:a 192k -shortest out.mp4
If your audio file is using a codec that the output container supports (e.g. MP3 audio in AVI or M4A/AAC audio in MP4), you can stream copy (re-mux) it instead of re-encoding, which will preserve the audio quality: ffmpeg -loop 1 -i img.jpg -i audio.m4a -c:v libx264 -c:a copy -shortest out.mp4
=================================================
video to images:
ffmpeg -i video.mpg image%d.jpg
video to mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192k -f mp3 sound.mp3
wav to mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192k -f mp3 son_final.mp3
video to gif
ffmpeg -i video_origine.avi gif_anime.gif
mix sound with video
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Exrs to video
ffmpeg -apply_trc iec61966_2_1 -start_frame 1100 -i input.$04d.exr output.mp4
bt709 .D.V.... BT.709
gamma .D.V.... gamma
gamma22 .D.V.... BT.470 M
gamma28 .D.V.... BT.470 BG
smpte170m .D.V.... SMPTE 170 M
smpte240m .D.V.... SMPTE 240 M
linear .D.V.... Linear
log .D.V.... Log
log_sqrt .D.V.... Log square root
iec61966_2_4 .D.V.... IEC 61966-2-4
bt1361 .D.V.... BT.1361
iec61966_2_1 .D.V.... IEC 61966-2-1
bt2020_10bit .D.V.... BT.2020 - 10 bit
bt2020_12bit .D.V.... BT.2020 - 12 bit
smpte2084 .D.V.... SMPTE ST 2084
smpte428_1 .D.V.... SMPTE ST 428-1
another expansion:
C:/ffmpeg.exe -y -gamma 2.2 -i C:/seq_v001.%04d.exr -vcodec libx264 -pix_fmt yuv420p -preset slow -crf 18 -r 25 C:/out.mov