Created
June 15, 2015 20:58
-
-
Save georgiecasey/9027e171d4eb7be31867 to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* Created by PhpStorm. | |
* User: georgiecasey | |
* Date: 15/06/2015 | |
* Time: 18:17 | |
*/ | |
function timeDiff($firstTime,$lastTime) | |
{ | |
$one = new DateTime($firstTime); | |
$two = new DateTime($lastTime); | |
$difference=$two->diff($one, true); | |
//var_dump($difference); | |
return $difference->format('%H:%I:%s'); | |
//return $difference->h.":".$difference->i.":".$difference->s; | |
} | |
function sanitize($string, $force_lowercase = true, $anal = false) { | |
$strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", | |
"}", "\\", "|", ";", ":", "\"", "'", "‘", "’", "“", "”", "–", "—", | |
"—", "–", ",", "<", ".", ">", "/", "?"); | |
$clean = trim(str_replace($strip, "", strip_tags($string))); | |
$clean = preg_replace('/\s+/', "_", $clean); | |
$clean = ($anal) ? preg_replace("/[^a-zA-Z0-9_]/", "", $clean) : $clean ; | |
return ($force_lowercase) ? | |
(function_exists('mb_strtolower')) ? | |
mb_strtolower($clean, 'UTF-8') : | |
strtolower($clean) : | |
$clean; | |
} | |
$cut_times_input=file_get_contents("cut_times_input"); | |
//$cut_times_input="00:08:52,00:46:53,day1_ch1_full.mp4,DMAs"; | |
preg_match_all("/([0-9]{2}:[0-9]{2}:[0-9]{2}),([0-9]{2}:[0-9]{2}:[0-9]{2}),((day[0-9]_ch[0-9]_).+\.mp4),(.+)/",$cut_times_input,$match1); | |
//var_dump($match1); | |
for ($i=0;$i<count($match1[0]);$i++) { | |
$cmd="ffmpeg -i {$match1[3][$i]} -ss {$match1[1][$i]} -t ".timeDiff($match1[1][$i],$match1[2][$i])." -c:v copy -c:a copy edits/{$match1[4][$i]}".sanitize($match1[5][$i],true,true).".mp4"; | |
echo $cmd."\n"; | |
//system($cmd); | |
} | |
//var_dump($match1); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment