avconv: make a video from a subset on images

让人想犯罪 __ 提交于 2019-12-03 04:42:58

问题


I am trying to make a bunch of png's into a video using avconv, the png's are numbered like filename_<number> so I usually just use the command:

avconv -r 10 -i filename_%d.png -b:v 1000k test.mp4

I now want to make a video from a subset of the files filename_8 - filename_50 lets say, so I've copied these files into a new directory and tried the same command but now I get the error:

filename_%d.png: No such file or directory

I assume this is because the numbering doesn't start from 1?

How can I achieve this?


回答1:


avconv -r 10 -start_number 8 -i filename_%d.png -b:v 1000k test.mp4

You will need a recent 9.x version of avconv for the -start_number option; it is not in version 0.8.x. Alternatively you could use a recent version of ffmpeg. Or rename the files to start with a number between 0 and 4, as it will check for those names by default.




回答2:


You can concatenate the files with cat and then use the image2pipe demuxer to read them in avconv. Like cat filename* | avconv -f image2pipe -i - ...




回答3:


Check this out; according to ffmpeg this is how they doing it and it works

  1. First, rename your pictures to follow a numerical sequence. For example: img1.jpg, img2.jpg, img3.jpg, ...
  2. Then you may run:

    ffmpeg -f image2 -i img%d.jpg /tmp/a.mpg
    

    Notice that %d is replaced by the image number.

    img%03d.jpg means the sequence img001.jpg, img002.jpg, etc.

  3. Use the ‘-start_number’ option to declare a starting number for the sequence. This is useful if your sequence does not start with img001.jpg but is still in a numerical order. The following example will start with img100.jpg:

    ffmpeg -f image2 -start_number 100 -i img%d.jpg /tmp/a.mpg
    
  4. If you have large number of pictures to rename, you can use the following command to ease the burden. The command, using the bourne shell syntax, symbolically links all files in the current directory that match *jpg to the /tmp directory in the sequence of img001.jpg, img002.jpg and so on.

    x=1;  
    for i in *jpg;  
    do counter=$(printf %03d $x);  
    ln -s "$i" /tmp/img"$counter".jpg;  
    x=$(($x+1));
    


来源:https://stackoverflow.com/questions/16315192/avconv-make-a-video-from-a-subset-on-images

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!