Is it possible to create a video from a pdf file?

I want to make a video from a pdf file. Is it possible? I created a video with images using ffmpeg, but not able to create video from pdf and doc.

+6
source share
4 answers

here is a script to convert pdf to video:

exec("convert -geometry 1600x1600 -density 200x200 -quality 100 -resize 800x $pdf_path $temp_images");
exec("ffmpeg -loop 1 -f image2 -framerate 0.5 -b 1800 -i $temp_images_wildcard -c:v libx264 -preset slow -tune stillimage -r 5 -t 22 -y $frame_target 2>&1",$output);
+6
source

Assuming your PDF files are in your working directory, to create a movie file from a set of PDF files that you can execute:

exec("mogrify -verbose -density 500 -resize 800 -format png ./*.pdf")
exec("convert -delay 600 *.png movie.mp4")

This requires Imagemagick and Ghostscript to install. Powered by Linux / Mac OS X / Microsoft Windows. Not a vector.


If you want to generate several PDF files for testing commands, here is the python script that generates the PDF files:

import pandas as pd  
import numpy as np
from matplotlib import pyplot as plt

for i in range(10):
    np.random.seed(i)
    dates = pd.date_range('1/1/2000', periods=50)
    print('dates: {0}'.format(dates))
    df = pd.DataFrame(np.random.randn(len(dates), 1), index=dates.astype(str), columns=['A'])

    print('df: {0}'.format(df))
    plt.figure(figsize=(60,15))
    df.plot(y='A', use_index=True)
    plt.xticks(rotation=70)
    plt.savefig('plot_{0}.pdf'.format(i), dpi=300, bbox_inches='tight')

FYI:

+3

PDF ,

+1

The standard FPS (frames per second) in the video is about 30, so saving it in conventional document formats using conventional paging is not practical. There is a way to convert a PDF file into images, then you can use it in your video.

0
source

All Articles