I need to convert all (some 300GBs) of pdfs to avi (or some other video format).

I'll explain what I mean; for a certain research project I need to flash each page of pdf for (say 1s.). I know this can be done using available programs by first extracting images from pdfs and then using video editing applications to create the final video.

I want to know if I can automate the whole process? Is there something already available out there that I don't know of?

I use both GNU/Linux and windows.

up vote 4 down vote accepted

I haven't tested any of this, but I think you can do it with ImageMagick (convert PDF to JPG) and ffmpeg (convert JPG to MP4 or similar). Undoubtedly lots of tweaks will be required to pull this off, but hopefully this will get you started:

convert -density 400 n2010.pdf n2010.jpg

This should generate a JPG image per page. You may wish to play with various options, like using PNG instead of JPG, as well as tweaking the density option to get desirable quality/results.

Next I would use avconv/ffmpeg to glue the images together into a video. The link below provides a (hopefully) working example.

Good luck!

References

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.