PHPology.co.uk Collective of freelance web developers and designers

  • FFMpeg losing duration when converting to FLV

    Recently hit an issue where when I was converting a video file to a FLV format via FFMpeg (PHP) the duration of the video was lost during the export.

    Searching the t'internet, various options were found i.e. using FLVTool (which needed to be installed on the server) or by spitting out the raw data using PHP passthru().

    I went for the passthru() option and although the duration was not actually part of the metadata, I was at least able to tell Flash (in my case) that this video was x:x:x long.

    I did end up using this example code from LongTailVideo.com and then saved the duration value to the database:

    ob_start();
    passthru("ffmpeg-10141.exe -i "". $videofile . "" 2>&1");
    $duration = ob_get_contents();
    ob_end_clean();

    preg_match('/Duration: (.*?),/', $duration, $matches);
    $duration = $matches[1];

     

  • Comments

    0 comment(s)

    Be the first to comment!

    Add your comment
    Name*:
    Email*:
    Website URL (including full path e.g. http://www.yourwebsite.com/):
    Comment* (html/script tags will be removed):
    What do you see below?: