ffmpeg/PHP - Problems converting any video format to ogg - Choppy Video / No Audio - win64

前端 未结 1 651
长情又很酷
长情又很酷 2021-01-14 09:31

Let me first appologize if this is a re-post/similar-post as I did my best to search for a specific solution to my issue within the already created posts on here, and on goo

相关标签:
1条回答
  • 2021-01-14 09:57

    As usual, upon posting my question here (after countless hours of troubleshooting), I believe I may have corrected the issue. I needed to specify, not only the audio/video codecs for converting the file, but also the audio/video bitrate for the outputted .ogg video:

    //CREATE CLASS INSTANCE
    $ffmpegObj = new ffmpeg_movie($srcFile);
    //GET AUDIO BITRATE FROM SOURCE FILE
    $srcAB = intval($ffmpegObj->getAudioBitRate());
    //GET VIDEO BITRATE FROM SOURCE FILE
    $srcVB = intval($ffmpegObj->getVideoBitRate());
    
    //SET THE AUDIO CODEC TO LIBVORBIS
    $aCodec = ' -acodec libvorbis';
    //SET THE VIDEO CODEC TO LIBTHEORA
    $vCodec = ' -vcodec libtheora';
    
    exec($ffmpegPath." -i ".$srcFile.$vCodec." -vb ".$srcVB." -ab ".$srcAB." ".$destFile);
    

    This outputs a video/audio with quality very close to that of the original video format.

    Obviously anyone who is trying to utilize the above code would need to add the references to $ffmpegPath/$srcFile/$destFile and have the ffmpeg class available to their script.

    Also, upon initially viewing the .ogg video in firefox locally on my pc, the video would freeze when it first started playing and then jump to the correct position (relative to the audio) after a few seconds, however, if replayed from start would play without issue. I am assuming my video card is just not up to par; which would explain the issue upon first viewing the file after conversion.

    In any case, the above code should work for any others who were having issues converting to the .ogg format properly using ffmpeg and php.

    0 讨论(0)
提交回复
热议问题