1

I found this question and I was able to successfully convert my video to OGG, but it does not include the sound.

Here is the code:

//SET FFMPEG PATH
$ffmpegPath = 'ffmpeg';
//CREATE CLASS INSTANCE
$ffmpegObj = new ffmpeg_movie($video);
//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';
//EXECUTE THE CONVERSION
exec($ffmpegPath." -i ".$video.$vCodec." -vb ".$srcVB." -ab ".$srcAB." ".$ogg_video); 

What am I doing wrong?

Community
  • 1
  • 1
iamthestreets
  • 733
  • 1
  • 15
  • 38
  • Can you show what is your prepared command for exec? – mim. Jul 15 '15 at 00:02
  • I'm not sure I know what you're asking for. – iamthestreets Jul 15 '15 at 12:52
  • @mim is asking for the output of `echo $ffmpegPath." -i ".$video.$vCodec." -vb ".$srcVB." -ab ".$srcAB." ".$ogg_video;`. At present all we can see is a lot of variables, and it's not clear what command is actually being run. Please edit the output of that into your question, thanks! – halfer Jul 17 '15 at 20:24
  • here is an example of what the output would be: `ffmpeg -i video.mp4 -vcodec libtheora -vb xxxxx -ab xxxxx video.ogg` – iamthestreets Jul 20 '15 at 17:08

1 Answers1

1

You're not including $aCodec in the command line anywhere! As a result, the generated file probably ends up including an audio stream with an inappropriate codec.

As an aside, copying the audio and video bitrates from the input file to the output doesn't make sense in general. In particular, it will choose inappropriately high bitrates for lightly compressed or uncompressed audio/video input (e.g, motion JPEG, PCM audio, etc). Since you're forcing a new set of codecs on the video, it's probably more appropriate to force a single standard bitrate for audio, and a variable bitrate based on the resolution of the video.

  • Thank you! Can you give me an example of how I should do this? I want the converted video to be in as high quality as I can get it. – iamthestreets Jul 15 '15 at 12:50