更新时间:2023-01-06 09:49:04
您必须生成一个4秒钟的视频,该视频具有与现有视频(包括时基)的参数匹配的虚拟音频,然后将concat多路分配器与streamcopy一起使用.
You'll have to generate a 4 second video with dummy audio matching the parameters of the existing video, including timebase, and then use the concat demuxer with streamcopy.
对于Q中显示的示例文件:
For the sample files shown in Q:
步骤1 生成文字视频
ffmpeg -f lavfi -r 30 -i color=black:1280x720 -f lavfi -i anullsrc -vf "drawtext="fontfile=/path/to/font.ttf:fontcolor=FFFFFF:fontsize=50:text='Your text':x=(main_w-text_w)/2:y=(main_h-text_h)/2",fade=t=in:st=0:d=1,fade=t=out:st=3:d=1" -c:v libx264 -b:v 1000k -pix_fmt yuv420p -video_track_timescale 15360 -c:a aac -ar 48000 -ac 2 -sample_fmt fltp -t 4 intro.mp4
对于WebM,将-c:v libx264
替换为-c:v libvpx
,将-c:a aac
替换为-c:a libvorbis
,将intro.mp4
替换为intro.webm
.您可能会删除-video_track_timescale 15360
,因为WebM倾向于使用单个时标,这已经见过.
For WebM, replace -c:v libx264
with -c:v libvpx
, -c:a aac
with -c:a libvorbis
and intro.mp4
with intro.webm
. You may remove the -video_track_timescale 15360
since WebMs tend to use a single timescale, that I've seen.
步骤2 ,准备concat文件,例如list.txt
Step 2 Prepare concat file, say, list.txt
file 'intro.mp4'
file 'input.mp4'
第3步 Concat
ffmpeg -f concat -i list.txt -c copy -fflags +genpts joined.mp4
这里重要的变量是视频大小1280x720
,帧速率-r 30
,-pix_fmt yuv420p
,采样率-ar 48000
,格式-sample_fmt fltp
,频道布局-ac 2
,当然还有编解码器.
The variables important here are video size 1280x720
, frame rate -r 30
, -pix_fmt yuv420p
, sample rate -ar 48000
, format -sample_fmt fltp
, channel layout -ac 2
and of course, codecs.