Last active
September 3, 2021 09:32
-
-
Save sakydev/d9a68e688849b4443d1e6abc33e50f04 to your computer and use it in GitHub Desktop.
php+ffmpeg: convert high size smartphone videos with minimal quality loss
This file contains 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
<?php | |
// My smartphone Note 8 outputs really heavy size videos. So I wrote this script | |
// to automatically convert videos in given directory | |
$inputDir = 'directory_with_all_videos'; | |
$outputDir = 'directory_to_save_converted_videos_to'; | |
$files = glob($inputDir); | |
$count = count($files); | |
foreach ($files as $key => $file) { | |
$done = $key + 1; | |
$filebase = basename($file); | |
$cmd = "C:\ffmpeg.exe -i " . __DIR__ . "/{$file} {outputDir}/{$filebase}"; | |
shell_exec($cmd); | |
echo "Done {$done} / {$count}\n"; | |
exit; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment