Feb 5, 2010

Animate image files

With a sequence of image files, we can code them into a video file. Suppose that they are named beginning from 1, use

ffmpeg -qscale 1 -r 20 -b 96000 -i %08d.png animate.mp4

If the file names do not start from 1, we can use a script do rename them in batch.

#!/bin/bash

d=1
for fname in *.png
do
  mv $fname `printf "%08d.png" $d`
  d=$(($d+1))
done

To enable mp3 etc.
>>sudo apt-get install ffmpeg libavcodec-extra-52
One example of extracting audio from mp4:
>>ffmpeg -ss 00:05:00:00 -t 00:02:00:00 -i input.mp4 -acodec libmp3lame -ab 128k output.mp3
ss: time offset from beginning of input in hh:mm:ss:frames.
t: duration of encode
ab: audio bitrate

1 comment:

数声风笛离亭晚,我想潇湘君想秦! said...

Although I know some other methods to create animate images, this seems the most extendable one!