ffmepg来自png图像不均匀序列的视频 [英] ffmepg video from uneven sequence of png images

查看:111
本文介绍了ffmepg来自png图像不均匀序列的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将通过一系列屏幕截图(.png文件)制作视频.对于每个屏幕截图,都有有关拍摄时间的相关时间戳信息.屏幕截图之间的时间间隔可能会有所不同,因此非常需要保留视频中的这种差异.

I'm going to make a video from series of screenshots (.png files). For each screenshot there is assosiated timestamp information about when it was taken. The time intervals between screenshots may vary and it's highly desired to preserve that difference in the video.

有没有一种方法可以使用单个ffmpeg命令/API向其提供图像+时间(或帧)偏移量的序列,并获得一个视频文件作为输出? 现在,我必须为每个图像生成具有自定义长度的简短视频文件,然后手动合并它们:

Is there a way to use single ffmpeg command/API providing to it sequence of image + time (or frame) offset and getting one video file as output? By now I have to generate short video files of custom length for each image, and then merge them manually:

ffmpeg -y -loop 1 -i image1.png -c:v libx264 -t 1.52 video1.avi
ffmpeg -y -loop 1 -i image2.png -c:v libx264 -t 2.28 video2.avi
...
ffmpeg -y -loop 1 -i imageN.png -c:v libx264 -t 1.04 videoN.avi


ffmpeg -i "concat:video1.avi|video2.avi|...videoN.avi" -c copy output.avi

这很好,虽然间隔很大,但是整个方法对我来说似乎有点脆弱.

This is quite ok, while intervals are large, but the whole approach seems to me a bit fragile.

推荐答案

使用 concat多路复用器.


使用2、4和0.25秒的示例.

  1. 制作一个文本文件,指示每个文件所需的持续时间:

  1. Make a text file indicating the desired duration per file:

file 'image1.png'
duration 1.52
file 'image2.png'
duration 2.28
file 'image3.png'
duration 1.04

您可能必须重复最后的fileduration行才能显示最后一帧.

You may have to repeat the last file and duration lines to get it to display the last frame.

运行ffmpeg命令:

ffmpeg -f concat -i input.txt -c:v libx264 -pix_fmt yuv420p -movflags +faststart output.mp4

这篇关于ffmepg来自png图像不均匀序列的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆