Memo by Michikazu Kobayashi
ffmpeg

Notes on ffmpeg and images

  • Convert AVS/Express avi video to mpeg1

                    ffmpeg -r 20(frame rate of original file) -i file.avi -r 20(frame rate of generated file) -b 10000k(bit rate) -an file.mpg
    To create an avi by connecting png files generated by povray, etc. When creating an uncompressed 32-bit RGB avi file
                    ffmpeg -r 20 -i file-%3d.png -vcodec rawvideo -pix_fmt rgb32 -an file.avi
  • Extract still image from a video

                    ffpmeg -r 20(frame rate of the original file) -i hoge.mp4 -ss 0 (start time in seconds) -t 10 (end point in seconds) -r 20 (how many pictures to extract per second) -f image2 hoge%02d.png
    If it is a single image for a thumbnail
                    ffpmeg -r 20(frame rate of the original file) -i hoge.mp4 -ss 0 (start time in seconds) -t 1 -r 1 -f image2 hoge_tn.png
  • Extract part of video (time)

                    ffpmeg -ss 0 (start time in seconds) -i hoge.mp4 -t 10 (seconds to cut out) hoge2.mp4
    Encoding is safe, but -vcodec copy is faster
  • Extract a part of the video (image)

    See (Jpn)
  • WMV files converted to MP4 using ffmpeg (for video distribution of classes and such. Both audio and video are available)

                    ffpmeg -i hoge.wmv -acodec aac -strict experimental -aq 100 -ac 2 -vcodec libx264 -crf 20 -vsync 1 -vf scale=960(example: horizontal scale):-2 hoge.mp4
  • Video size is too big? Just lower the bitrate

                    ffpmeg -i hoge.mp4 -b:v 100k -vcodec copy -ab 64k -acodec copy hoge2.mp4
  • Convert from bmp to eps using RLE compression

                    convert -compress rle hoge.bmp hoge.eps
  • Convert eps or pdf to png

                    convert -density 200 hoge.eps hoge.png
    200 is an appropriate value. However, to do this in Ubuntu, you need to configure ImageMatick. Specifically, rewrite the corresponding part of /etc/ImageMagick-6/policy.xml with sudo as follows
                    <policy domain="coder" rights="read|write" pattern="PS" />
                    <policy domain="coder" rights="read|write" pattern="EPS" />
                    <policy domain="coder" rights="read|write" pattern="PDF" />
                    <policy domain="coder" rights="read|write" pattern="PNG" />
  • List of frequently used codecs (Jpn)