使用ffmpeg和时间戳顺序将目录中的所有图像转换为.mp4

杰克

我有一个目录,其中.jpg包含以UNIX时间戳格式命名的图像如何将所有从最早的时间戳开始的图像转换为最新的.mp4视频格式?

我发现了一个解决方案,但它使用的增量命名,如image001image002

我将不胜感激任何帮助。谢谢。

使用aergistal的解决方案时,我在输出中出现错误:我按照您说的做,但是出现了输出错误:

Input #0, concat, from 'list.txt':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 540x405 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
[swscaler @ 0x14751c0] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x14b7120] height not divisible by 2 (540x405)
Output #0, mp4, to 'out.mp4':
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 30 fps
Metadata:
  encoder         : Lavc56.26.100 libx264
Stream mapping:
Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
航空

使用以下格式,按照您希望它们出现的顺序列出文件:

file '<path/to/file>'

在Linux上,您可以使用时间戳顺序获取文件,并使用以下命令创建列表:

ls /path/to/*.jpg | sort -V | xargs -I {} echo "file '{}'" > list.txt

sort手册页:

-V,--version-对文本内的(版本)数字进行自然排序

示例列表:

file '1.jpg'
file '2.jpg'
file '3.jpg'

然后将FFmpeg concat多路分配器与您的列表一起使用:

ffmpeg -r 1/5 -f concat -i list.txt -c:v libx264 -r 25 -pix_fmt yuv420p -t 15 out.mp4

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章