FFmpeg 生成多个输出文件

来自艺搜天下
跳到导航 跳到搜索

creating_multiple_outputs2.png

ffmpeg -i input1 -i input2 \
-acodec … -vcodec … output1 \
-acodec … -vcodec … output2 \
-acodec … -vcodec … output3

输出使用相同的filter

use -filter_complex with the split filter.

ffmpeg -i input -filter_complex '[0:v]yadif,split=3[out1][out2][out3]' \
       -map '[out1]' -s 1280x720 -acodec … -vcodec … output1 \
       -map '[out2]' -s 640x480  -acodec … -vcodec … output2 \
       -map '[out3]' -s 320x240  -acodec … -vcodec … output3

不同输出使用不同的filter

ffmpeg -i input -filter_complex '[0:v]split=3[in1][in2][in3];[in1]boxblur[out1];[in2]negate[out2];[in3]yadif[out3]' \
       -map '[out1]' -acodec … -vcodec … output1 \
       -map '[out2]' -acodec … -vcodec … output2 \
       -map '[out3]' -acodec … -vcodec … output3

复制Duplicate outputs

Tee pseudo-muxer 伪复用器

ffmpeg -i input.file -c:v libx264 -c:a mp2 \
-f tee -map 0:v -map 0:a "output.mkv|[f=mpegts]udp://10.0.1.255:1234/"  #选项可以应用于单个输出,[f=mpegts] is equivalent to -f mpegts, 多个选项可以用转义的 \:分开

choose specific streams then use the select option.split and scaled to two different sized,audio is encoded only once ,The ignore value for the onfail option in the last output will keep the other outputs running even if that last output fails.:

ffmpeg -i input -filter_complex \
"[0:v]split=2[s0][s1]; \
[s0]scale=1280:-2[v0]; \
[s1]scale=640:-2[v1]" \
-map "[v0]" -map "[v1]" -map 0:a -c:v libx264 -c:a aac -f tee \
"[select=\'v:0,a\']local0.mkv| \
[select=\'v:0,a\':f=flv]rtmp://server0/app/instance/playpath| \
[select=\'v:1,a\']local1.mkv| \
[select=\'v:1,a\':f=flv:onfail=ignore]rtmp://server1/app/instance/playpath"

管道

ffmpeg -i input1 -i input2 -acodec … -vcodec … -f mpegts - | \

ffmpeg -f mpegts -i - \ -c copy output1 \ -c copy output2 \ -c copy output3 \

ffmpeg -f v4l2 -i /dev/video0 -vcodec libx264 -f mpegts - | \

ffmpeg -f mpegts -i - \ -c copy -f mpegts udp://1.2.3.4:5678 \ -c copy -f mpegts local.ts

参考

http://trac.ffmpeg.org/wiki/Creating%20multiple%20outputs