0

我在文件夹中的一个简单脚本有问题 .jpg 中有图像序列 所有 jpg 文件我想将它们转换为 tiff

这是我的脚本,但不能正常工作:

for I in *.jpg; do ffmpeg -start_number 000001 -f image2 -i "$I" -c:v tiff TIFF/"%6d.tif";

当我运行脚本时,每个 jpg 的 ffmpeg 会不断重新启动,并且在输出目录中我只有一个 tif 转换。

我如何不为每个 jpg ffmpeg 重新启动?

谢谢你

4

1 回答 1

2

In ffmpeg, the start number generally refers to your input images, not the output image. FFMPEG will also take *.jpg as input using the glob option (check the docs rather than looping through yourself and calling it 1000 times.

Currently, your script will generate the same tiff file for each of the different jpegs that you are calling, because you are just re-calling it with the same parameters.

You could try putting $I.tif at the end instead of "%6d.tif";

for I in *.jpg; do
    ffmpeg -i "$I"  -c:v tiff TIFF/${I%%.jpg}.tif
done

This part ${I%%.jpg} takes your original file name and strips off the .jpg

In Imagemagick you can simply do:

convert *.jpg tiff
于 2013-10-23T01:08:56.543 回答