CarbonCopy Posted May 20, 2009 Share Posted May 20, 2009 I am writing a PHP video conversion utility. Without knowing the video type (Or is there a way I can get it), how can I use ffmpeg and php to convert a movie to flash video? I have a dedicated server, so I can install any mod that would make this easier Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/ Share on other sites More sharing options...
BK87 Posted May 20, 2009 Share Posted May 20, 2009 I've always used flvtools along with ffmpeg to fix timing... $input="video.mpg"; $output="video.flv"; exec("ffmpeg -i '".$input."' -acodec mp3 -ar 22050 -ab 48 -f flv ".$output); exec("flvtool2 -U ".$output) ; Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-837859 Share on other sites More sharing options...
mandred Posted May 20, 2009 Share Posted May 20, 2009 I am writing a PHP video conversion utility. Without knowing the video type (Or is there a way I can get it), how can I use ffmpeg and php to convert a movie to flash video? I have a dedicated server, so I can install any mod that would make this easier Get the file type from the header. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-837874 Share on other sites More sharing options...
CarbonCopy Posted May 20, 2009 Author Share Posted May 20, 2009 I didn't ask how to get timing, as I have a script which does that. All I need is to convert a video to flash, regardless of format. I do have flvtools installed. Can headers not be forged? Either way, can you provide me with examples or information of hour to get file type based on headers? I will go try google now anyways. EDIT: http://ca.php.net/manual/en/function.finfo-file.php File info looks promising, if I get a working script I'll post it back for future references Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-837883 Share on other sites More sharing options...
CarbonCopy Posted May 21, 2009 Author Share Posted May 21, 2009 This just isn't working. I got it working for basic avi and mpg formats, and that's about it. Certain avi files don't convert, and many other problems exist. Anyone happen to have the code for youtube's converter No actually, anyone? I would like it Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838546 Share on other sites More sharing options...
mandred Posted May 21, 2009 Share Posted May 21, 2009 I didn't ask how to get timing, as I have a script which does that. All I need is to convert a video to flash, regardless of format. I do have flvtools installed. Can headers not be forged? Either way, can you provide me with examples or information of hour to get file type based on headers? I will go try google now anyways. EDIT: http://ca.php.net/manual/en/function.finfo-file.php File info looks promising, if I get a working script I'll post it back for future references <?php function http_content_type($url = '', $default_mime = 'application/octet-stream') { if ($headers = @array_change_key_case(get_headers($url, true)) AND isset($headers['content-type'])) { $headers['content-type'] = strtolower(is_array($headers['content-type']) ? end($headers['content-type']) : $headers['content-type']); $headers['content-type'] = explode(';', $headers['content-type']); return trim($headers['content-type'][0]); } return $default_mime; } if (http_content_type($epvideo) == 'video/x-flv') { // do stuff } ?> And figure out which content types you want, list them, then use this function to validate them. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838704 Share on other sites More sharing options...
CarbonCopy Posted May 21, 2009 Author Share Posted May 21, 2009 Free download for $35 >_<. Stupid spammers can GTFO AND STAY OUT. Anyways, I needed command line based :| Also, I got my script to get the mime type. I can now tell what type of video it is, I just don't have a good way of easily converting it. Actually, just no way at all. Like I said,, ffmpeg has no troubles doing BASIC avi or mpg files, but that is about it. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838823 Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 What other formats are you looking at? I'm sure most other formats are closed source / limited. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838830 Share on other sites More sharing options...
CarbonCopy Posted May 21, 2009 Author Share Posted May 21, 2009 /usr/local/bin/mencoder '$path" . "$name.$ext' -o $path" . "$name.flv -of lavf -oac mp3lame -lameopts abr:br=56 -ovc lavc -lavcopts vcodec=flv:vbitrate=500:mbd=2:mv0:trell:v4mv:cbp:last_pred=3 -srate 22050 -ofps 24 -vf harddup; Works for every type of video I've tried so far Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838846 Share on other sites More sharing options...
trq Posted May 21, 2009 Share Posted May 21, 2009 mencoder (or mplayer) does indeed have a hell of alot more dependencies on other libraries (and therefore support) than ffmpeg. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-838851 Share on other sites More sharing options...
CarbonCopy Posted May 21, 2009 Author Share Posted May 21, 2009 I don't mind extra dependencies. The only thing I cannot convert so far is IV41 which doesn't work in any of the 9 media players I've tried, so I just don't care about it. Quote Link to comment https://forums.phpfreaks.com/topic/158852-ffmpeg-convert-unknown-video-type-to-flv/#findComment-839302 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.