我可以从带时间戳的图像创建 VFR 视频吗? [英] Can I create a VFR video from timestamped images?

查看:14
本文介绍了我可以从带时间戳的图像创建 VFR 视频吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我几乎没有使用图像制作视频的经验.

First, I have almost zero experience in making videos from images.

我拥有的是一组 BMP 时间戳图像,我想从中生成视频.由于时间戳不是等距间隔,我不能简单地使用从图像创建恒定帧速率视频的软件.

What I have is a set of BMP timestamped images from which I want to generate a video. Since the timestamps are not equally spaced, I cannot simply use software that create constant-frame-rate videos from images.

一种可能的解决方案是以固定的时间间隔创建人工图像,但如果我无法制作 VFR 视频,我更愿意将其作为最后的手段.

A possible solution would be to create artificial images at fixed time intervals, but I prefer to leave that as a last resort if I fail to make a VFR video.

关于如何实现我想要的有什么建议吗?

Any suggestions on how to achieve what I want?

推荐答案

你可以结合使用两个工具来做到这一点:ffmpeg 和 mp4fpsmod

You can use a combination of two tools to do this: ffmpeg and mp4fpsmod

第一步是使用ffmpeg生成一个恒定帧率的文件

Step 1 is to generate a constant frame rate file using ffmpeg

ffmpeg -i images%d.bmp -pix_fmt yuv420p ffmpeg-cfr.mp4

第 2 步是生成如下所示的时间码文件,每行包含一帧的相对时间戳(以毫秒为单位).

Step 2 is to generate a timecode file like the one below, with each line containing the relative timestamp for a frame in milliseconds.

# timecode format v2

0
33
88
100
120
160
200
230
330
347

第三步是使用mp4fpsmod生成VFR文件

Step 3 is to use mp4fpsmod to generate the VFR file

mp4fpsmod -o vfr.mp4 -t timecodes.txt ffmpeg-cfr.mp4 

此文件在 ffplay 中按预期播放,但在某些播放器中可能无法播放,在这种情况下运行

This file plays as expected with ffplay but may not with some players, in which case run

步骤 4 使用 FFmpeg 从 VFR 生成 CFR MP4

Step 4 Generate a CFR MP4 from the VFR using FFmpeg

ffmpeg -i vfr.mp4 final-cfr.mp4

这是一个 CFR 文件,但会根据 VFR 保留时间关系,但如果时间码间隔非常不规则,则会进行一些 PTS 调整.这可以通过指定高帧率来解决 -r N

This is a CFR file but the temporal relations are preserved as per the VFR, although there will be some PTS adjustments, if the timecode intervals are very irregular. That can be remedied by specifying a high framerate -r N

这篇关于我可以从带时间戳的图像创建 VFR 视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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