使用ffmpeg和文件列表将图像序列转换为视频

ren*_*nsa 1 bash ffmpeg

我有一台照相机,每2到3秒钟拍摄一次延时拍摄,并保持了几天的滚动记录。因为有很多文件,所以我按天和小时将它们保存在子目录中:

images/
    2015-05-02/
        00/
            2015-05-02-0000-02
            2015-05-02-0000-05
            2015-05-02-0000-07
        01/
            (etc.)
    2015-05-03/
Run Code Online (Sandbox Code Playgroud)

我正在编写一个脚本,每天自动将日出时间间隔上传到YouTube。我可以提前从网上获取日出时间,然后在日出之后返回,并使用find以下命令获取该时间段内获取的文件列表:

touch -d "$SUNRISE_START" sunrise-start.txt
touch -d "$SUNRISE_END" sunrise-end.txt
find images/"$TODAY" -type f -anewer sunrise-start.txt ! -anewer sunrise-end.txt
Run Code Online (Sandbox Code Playgroud)

现在,我想使用将这些文件转换为视频ffmpeg。理想情况下,我希望不复制所有文件(因为我们正在谈论的是每小时3.5 GB的图像),并且我不希望将其重命名为类似的名称,image000n.jpg因为其他用户可能希望访问图片。复制图像是我的后备。

但是我一直find无法将的结果发送到ffmpeg。我知道ffmpeg可以在内部扩展通配符,但是我不确定这是否可以在文件不在一个目录中的情况下起作用。我还看到一些人使用find--execoption ffmpeg进行批量转换,但是我不确定这是否适用于图像序列输入(与将1000张图像转换为1000张单帧视频相对)。

关于如何将两者连接的任何想法(或者失败了,这是将多个子目录中的日期范围内的文件ffmpeg作为图像序列获取的更好方法)?

aer*_*tal 6

将解concat复用器与文件列表一起使用。列表格式为:

file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
Run Code Online (Sandbox Code Playgroud)

ffmpeg基本用法:

`ffmpeg -f concat -i mylist.txt ... <output>`
Run Code Online (Sandbox Code Playgroud)

连接 [FFmpeg Wiki]

  • 对于“mylist.txt”,请注意“file”不是文件名的占位符。每次都应该将其写在每个文件路径的前面。 (4认同)
  • 另请参阅[我的答案](http://stackoverflow.com/questions/30121222/convert-all-images-in-directory-to-mp4-using-ffmpeg-and-a-timestamp-order/30123156#30123156)这里。 (2认同)

Ste*_*ler 5

用于pattern_type glob

ffmpeg -f image2 -r 25 -pattern_type glob -i '*.jpg' -an -c:v libx264 -r 25 timelapse.mp4
Run Code Online (Sandbox Code Playgroud)