Jump to content

FFmpeg convert unknown video type to flv


CarbonCopy

Recommended Posts

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.

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

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 :D

 

No actually, anyone? I would like it

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.

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.

/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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.