How to create a video from a PDF file in Linux

Source: Internet
Author: User
Tags imagemagick arch linux linux mint

How to create a video from a PDF file in Linux

I collected a large number of PDF files on my tablet, mainly Linux tutorials. Sometimes I am too lazy to watch it on a tablet. I think it would be better if I could create a video from a PDF and watch it on a large screen device, such as a TV or computer. Although I have some experience with FFMpeg, I don't know how to use it to create videos. After some Google searches, I came up with a good solution. For those who want to create video files from a set of PDF files, please continue reading. This is not difficult.

 

Create a video from PDF in Linux

Therefore, you need to install "FFMpeg" and "ImageMagick" in the system ".

To install FFMpeg, see the following link.

  • Compiling FFmpeg in Linux supports x264 and x265
  • Common FFmpeg commands
  • Cross-compile FFmpeg in Ubuntu 16.04
  • Install and compile FFmpeg in Ubuntu 16.04

Imagemagick can be found in the official repository of most Linux distributions.

Run the following command to install Arch Linux, Antergos, Manjaro Linux, and other derivative products.

  1. sudo pacman -S imagemagick

Debian, Ubuntu, and Linux Mint:

  1. sudoapt-get install imagemagick

Fedora:

  1. sudo dnf install imagemagick

RHEL, CentOS, and Scientific Linux:

  1. sudoyum install imagemagick

SUSE, openSUSE:

  1. sudo zypper install imagemagick

After ffmpeg and imagemagick are installed, convert your PDF file to an image format, such as PNG or JPG, as shown below.

  1. convert -density 400 input.pdf picture.png

Here,-density 400Specifies the horizontal resolution of the output image.

The above command will convert all the pages of the specified PDF to PNG format. Every page in the PDF will be converted to a PNG file and saved in the current directory. The file name is:picture-1.png,picture-2.png. Depending on the number of pages in the selected PDF, this takes some time.

After converting all pages in PDF to PNG format, run the following command to create a video file from PNG.

  1. ffmpeg -r 1/10-i picture-%01d.png -c:v libx264 -r 30-pix_fmt yuv420p video.mp4

Here:

  • -r 1/10: Each image is displayed for 10 seconds.
  • -i picture-%01d.png: Readpicture-Followed by a number (%01d)..pngAll the ending images. If the image name has two digits (that ispicture-10.png,picture11.pngIn the preceding command, use (%02d).
  • -c:v libx264: Output video encoder (h264 ).
  • -r 30: The Frame Rate of the output video.
  • -pix_fmt yuv420p: Output video resolution
  • video.mp4: Output video files in. mp4 format.

Okay. The video file is complete! You can play it on any device that supports the. mp4 format. Next, I need to find a way to insert a cool music for my video. I hope this is not difficult.

If you want a higher resolution, you don't have to start over. You only need to convert the output video file to any other higher/lower resolution, for example, 720 p, as shown below.

  1. ffmpeg -i video.mp4 -vf scale=-1:720 video_720p.mp4

Note that a configured PC is required to use ffmpeg to create a video. During video conversion, ffmpeg consumes a large amount of system resources. I suggest doing this in a high-end system.

That's all. I hope you will find this helpful. There will be better things. Stay tuned!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.