ffmpeg:concat视频和图像 [英] ffmpeg: concat videos and images
问题描述
我有两个视频(相同的分辨率,相同的编码)文件,我想要连接,我想插入一些文本在他们之间3秒,作为分割器。我正在Windows中使用ffmpeg。
我可能会感兴趣的想法:
- 避免在流程中重新编码视频
- 在每个部分的交集处淡入/淡出
现在,我把文本作为一个图像(但我可以接受其他建议)。假设我有:
- video1.mp4:6:33
- splitter.png分辨率为video1.mp4)
- video2.mp4:16:44
一些事情,但我总是遇到同样的问题:视频是23:20(视频1 + 3秒+视频2),但3秒差距只是最后一个视频1帧冻结,而不是我的图像/文本...
任何想法我做错了或应该如何实现?
这是我迄今为止所尝试的:
方法1:图像到视频
将图像转换为3秒mp4影片,然后连接与其他人分开:
ffmpeg -loop 1 -f image2 -i splitter.png -r 30 -t 3分割器.mp4
ffmpeg -f concat -i input.txt -codec copy output.mp4
其中 input.txt
看起来像:
文件'E:\\ \\ video1.mp4'
文件'E:\splitter.mp4'
文件'E: \video2.mp4'
splitter.png $的内容c $ c>在
splitter.mp4
中可见,但不在 output.mp4
中。另外我并不完全确定splitter.mp4是否符合与2个视频完全相同的编码,而且我不知道如何验证。
方法2:插入图像帧
直接在图像上运行concat(demuxer)90次(30fps - > 3秒)
ffmpeg -f concat -i input.txt -codec copy output.mp4
input.txt
的位置如下所示:
文件'E:\video1.mp4'
文件'E:\splitter.png'
...
文件'E:\splitter.png'
文件'E:\video2.mp4'
编辑:可能的解决方案
由于我所做的一切都是屏幕截图,我也可以屏幕截图我的分割图像。这样我就确定音频和音频视频编码,并没有任何问题的合并,它不需要任何重新编码...我知道这可能听起来很愚蠢,但它可能会诀窍...
注意:我没有尝试过,因为我已经通过Openshot工作了。
我的猜测是这是所有的编解码器问题 - PNG转MP4可能不是与真正的MP4相同的编解码器。
尝试此操作 - 文件的连接不同的编解码器。
I have 2 videos (same resolution, same encoding) files that I want to concat and I want to insert some text for 3 seconds between them, as a splitter. I'm doing this with ffmpeg on Windows.
Optional ideas that I would be interested in:
- avoid reencoding the video in the process
- having a fade in / fade out at the intersection of each part
For now, I made the text as an image (but I am open to other suggestions). Let's say I have:
- video1.mp4: 6:33
- splitter.png (same resolution as video1.mp4)
- video2.mp4: 16:44
I have tried a few things, but I always end up with the same problem: the video is 23:20 (video1 + 3 seconds + video2), but the 3 seconds gap is just the last video1 frame frozen instead of my image/text...
Any Idea what I did wrong or how I should achieve this?
Here is what I tried so far:
Method 1: image to video
Turn the image into a 3 seconds mp4 film, then concat (demuxer) it with the others:
ffmpeg -loop 1 -f image2 -i splitter.png -r 30 -t 3 splitter.mp4
ffmpeg -f concat -i input.txt -codec copy output.mp4
Where the input.txt
looks like:
file 'E:\video1.mp4'
file 'E:\splitter.mp4'
file 'E:\video2.mp4'
The content of splitter.png
is visible in the splitter.mp4
, but not in the output.mp4
. Also I'm not entirely sure the splitter.mp4 respects the exact same encoding as the 2 videos, and I don't know how to verify that.
Method 2: insert image frames
Directly run the concat (demuxer) 90 times (30fps -> 3 seconds) on the image
ffmpeg -f concat -i input.txt -codec copy output.mp4
Where the input.txt
looks like:
file 'E:\video1.mp4'
file 'E:\splitter.png'
...
file 'E:\splitter.png'
file 'E:\video2.mp4'
Edit: possible solution?
Since all I'm doing is screencasting, I might as well screencast my splitter image. This way I would be sure of the audio & video encoding and wouldn't have any problem merging and it wouldn't need any reencoding... I know it might sound dumb, but it would probably do the trick...
Note: I didn't have try it, since I already worked through Openshot.
My guess is this is all a codec issue -- the PNG turned MP4 is probably not the same codec as your real MP4s.
Try this -- concatenation of files of different codecs.
这篇关于ffmpeg:concat视频和图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!