gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 22:22:24 48 4
gpt4 key购买 nike

我有一个目录 .jpg 命名的图像UNIX 时间戳 格式。如何将所有以最旧时间戳开头的图像转换为 .mp4 中的最新图像视频格式?

我找到了一个解决方案,但它使用增量命名,例如 image001 , image002 .

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

使用 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-sort natural sort of (version) numbers within text



示例列表:
file '1.jpg'
file '2.jpg'
file '3.jpg'

然后使用 FFmpeg concat demuxer与您的 list :
ffmpeg -r 1/5 -f concat -i list.txt -c:v libx264 -r 25 -pix_fmt yuv420p -t 15 out.mp4

关于ffmpeg - 使用 ffmpeg 和时间戳顺序将目录中的所有图像转换为 .mp4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30121222/

48 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com