简体   繁体   English

FFMPEG Concat丢帧

[英]FFMPEG Concat Dropping Frames

I'm using FFMPEG to do the following two things: 我正在使用FFMPEG做以下两件事:

  • create an mp4 given a set of images 给定一组图像创建一个mp4
  • compile mp4s to create a longer video (mp4) 编译mp4以创建更长的视频(mp4)

To create mp4s from images, I use the following command: 要从图像创建mp4,请使用以下命令:

ffmpeg -r 5 -i 'img%03d.jpg' output.mp4

As far as I know, this creates a video with a framerate of 5fps. 据我所知,这将创建一个帧率为5fps的视频。

But when I try to compile mp4s, it seems like frames within each mp4 are being dropped. 但是,当我尝试编译mp4时,似乎每个mp4中的帧都被丢弃了。

To create the compiled footage, I create a text file that points to all the mp4s that should be included in the compilation, eg 要创建已编译的素材,我创建了一个文本文件,该文件指向应包含在编译中的所有mp4,例如

file 'set1/output.mp4'
file 'set2/output.mp4'
file 'set3/output.mp4'
file 'set4/output.mp4'
file 'set5/output.mp4'
file 'set6/output.mp4'
file 'set7/output.mp4'

Then I run the following command: 然后我运行以下命令:

ffmpeg -f concat -i input.txt -codec copy compilation.mp4

The resulting video seems to drop 2-3 frames from each of the output videos. 生成的视频似乎从每个输出视频中丢失了2-3帧。

How do I ensure that the compiled video doesn't drop any frames? 如何确保编译后的视频不会丢失任何帧?

(For reference, I used the following tutorial: https://trac.ffmpeg.org/wiki/Concatenate ) (作为参考,我使用了以下教程: https : //trac.ffmpeg.org/wiki/Concatenate

I was able to find a work-around using the following tutorial: 我可以使用以下教程找到解决方法:

FFmpeg making video from images placed in different folders FFmpeg通过放置在不同文件夹中的图像制作视频

Rather than compiling mp4s, I could point to all the image assets that should be compiled into the final video file. 除了编译mp4之外,我还可以指向所有应编译到最终视频文件中的图像资产。

I created a text file that looked like this: 我创建了一个文本文件,如下所示:

file 'set1/img%03d.jpg'
file 'set2/img%03d.jpg'
file 'set3/img%03d.jpg'
file 'set4/img%03d.jpg'
file 'set5/img%03d.jpg'
file 'set6/img%03d.jpg'
file 'set7/img%03d.jpg'

Where each set folder contains images with the naming convention img001.jpg, img002.jpg, etc. 每个设置的文件夹都包含具有命名约定img001.jpg,img002.jpg等的图像。

Then I can compile all the images into a final video using the following command: 然后,我可以使用以下命令将所有图像编译成最终视频:

ffmpeg -f concat -r 5 -i input.txt compilation.mp4

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM