├── .gitignore ├── converted └── .gitkeep ├── index.php ├── original └── .gitkeep ├── process.php └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | converted/*.* 2 | original/*.* 3 | !.gitkeep 4 | 5 | .DS_Store 6 | .DS_Store? 7 | ._* 8 | .Spotlight-V100 9 | .Trashes 10 | ehthumbs.db 11 | Thumbs.db 12 | -------------------------------------------------------------------------------- /converted/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/perragnar/php-html5-video-converter/08341132951a35482051563808fd8709711b0236/converted/.gitkeep -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 |
2 | 3 | 4 |
5 | -------------------------------------------------------------------------------- /original/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/perragnar/php-html5-video-converter/08341132951a35482051563808fd8709711b0236/original/.gitkeep -------------------------------------------------------------------------------- /process.php: -------------------------------------------------------------------------------- 1 | 0, 'webm' => 0]; 7 | 8 | if(isset($_POST['submit'])) { 9 | if(move_uploaded_file($_FILES['file']['tmp_name'], $uploaded_file)) { 10 | // Make sure to get the correct path to ffmpeg 11 | // Run $ where ffmpeg to get the path 12 | $ffmpeg = '/usr/local/bin/ffmpeg'; 13 | 14 | // MP4 15 | $video_mp4 = $output_name . '.mp4'; 16 | exec($ffmpeg . ' -i "' . $uploaded_file . '" -c:v libx264 -an "./converted/' . $video_mp4 . '" -y 1>convert.txt 2>&1', $output, $convert_status['mp4']); 17 | 18 | // Debug 19 | // echo '
' . print_r($output, 1) . ' 
'; 20 | 21 | // WebM 22 | $video_webm = $output_name . '.webm'; 23 | exec($ffmpeg . ' -i "' . $uploaded_file . '" -c:v libvpx -c:a libvorbis -an "./converted/' . $video_webm . '" -y 1>convert.txt 2>&1', $output, $convert_status['webm']); 24 | 25 | // Debug 26 | // echo '
' . print_r($output, 1) . ' 
'; 27 | } 28 | } 29 | ?> 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | Document 38 | 100 | 101 | 102 |
103 |
104 |

105 |

106 | Fail' : 'MP4: Success'; 108 | echo ' - '; 109 | echo ($convert_status['webm'] != 0) ? 'WebM: Fail' : 'WebM: Success'; 110 | ?> 111 |

112 |
113 | 117 |
118 | 119 | 120 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Converting video files to HTML video compatible formats 2 | 3 | This simple script uploads a video file and converts it with **ffmpeg** to **mp4** and **webm** format. 4 | There's no error handling. This is just a rough initial test to solve a headache of mine. 5 | 6 | Note that converting to webm is painfully slow! Just give it some time and make a nice progress bar... 7 | 8 | Cheers! 9 | 10 | ## Requirements 11 | 12 | You need **ffmpeg** and also a couple of addons to be able to convert to webm. 13 | 14 | On Mac OS with Homebrew: 15 | 16 | ```bash 17 | brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aacc 18 | ``` 19 | 20 | If you already have ffmpeg installed and need the addons, just reinstall ffmpeg with the addons. 21 | 22 | ```bash 23 | brew reinstall ffmpeg --with-libvpx --with-libvorbis --with-fdk-aacc 24 | ``` 25 | 26 | ## Installation 27 | 28 | No installation besides ffmpeg needed. Just make sure you have the right file permission on the **original** and **converted** folders. 29 | 30 | ```bash 31 | sudo chmod -R 775 original converted 32 | ``` 33 | --------------------------------------------------------------------------------