Created
          November 17, 2013 16:17 
        
      - 
      
- 
        Save jastkand/7515043 to your computer and use it in GitHub Desktop. 
    Script that allows to convert pdf file to avi using ffmpeg
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | require 'RMagick' | |
| require 'fileutils' | |
| def clean_temp(dir) | |
| FileUtils.rm_rf(dir) if File.exists?(dir) | |
| end | |
| pdf = Magick::ImageList.new("input.pdf") | |
| dir = './temp' | |
| clean_temp(dir) | |
| Dir.mkdir(dir) | |
| FileUtils.rm_f('output.mp4') | |
| pdf.each_with_index do |page, index| | |
| # Duplicate first slide to prevent ffmpeg bug | |
| page.write("#{dir}/img#{index}.jpg") if index.zero? | |
| page.write("#{dir}/img#{index + 1}.jpg") | |
| end | |
| `ffmpeg -y -f image2 -r 1/15 -i ./temp/img%d.jpg -c:v libx264 output.mp4` | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment