Actually I've had a similar problem lately -- I've wanted to create an MP4 video form the PDF file. ImageMagick was slightly problematic when converting a PDF file with large number of pages (circa 1400). The trick is to convert a single PDF page per convert
invocation (when converting the whole PDF at once, ImageMagick was consuming at some point too much memory -- something around 10 GB
), i.e.,
for p in {0..1441}; do
name=`printf "frame-%04d" ${p}`;
convert -density 600 -quality 100 art.pdf[${p}] ${name}.png;
done
Then ffmpeg
can be used as follows.
ffmpeg -framerate 120 -i frame-%04d.png -vf "scale=1920:1080:force_original_aspect_ratio=decrease,pad=1920:1080:(ow-iw)/2:(oh-ih)/2:color=white" output.mp4
Option force_original_aspect_ratio=decrease
is for dealing with some images that are in slightly different size than others -- if so they are padded with the white colour (option color=white
).
I needed such an insane DPI
(-density 600
) due to tiny little details in image -- typically 300
is more than enough.