How do i loop thru video files in a directory with extension .flv and use exec to convert each one of them (one at a time ) to mpg using ffmpeg -i original.avi final.mpg
While current file is converting, the next filename in the array should wait until exec process is complete before moving on and converting other filename in the array.
I know i can use scandir($dir) to make an array of all filenames, then maybe use split to only target .flv files. Is this the best way to do it. If i use a while loop to run thru each filename and do an exec on it, how do i make sure exec file is fully converted before moving on to the next file in the array.
BASH code explanation:
cd.Refer: Moving around the filesystem @ tldp.org
$ivariable contains the name of a file from the current working directory that is of the following pattern:*.flv. Each iteration changes the value of$ito the next file name in the current working directory.Refer: The for loop @ tldp.org and Loops @ tldp.org.
$(basename "$i" .flv).mpgto the variable namedOUTFILE.Refer: Subshells @ tldp.org, basename @ tlpd.org and Command Substitution @ tlpd.org.
$ito a file named like$i, but with it’s suffix changed to “mpg” instead of “flv”. (The “suffix change” is done in the third line)The following should be the PHP equivalent:
Refer: glob(), chdir() and substr().