muaz-khan / WebRTC-Experiment

WebRTC, WebRTC and WebRTC. Everything here is all about WebRTC!!
https://www.webrtc-experiment.com/
MIT License
11.74k stars 3.95k forks source link

Browser compatibility issues with FFMPEG generated oggs #159

Open nathanathan opened 10 years ago

nathanathan commented 10 years ago

The ogg vorbis files I record using the FFMPEG demo won't play back in Android Chrome. I recorded test oggs using your demo in Windows Chrome, and they played back without error, however, I was unable to play those same audio files in Android Chrome. Other ogg vorbis files (such as the one here) will play in Android Chrome. I posted a question on SO about this issue: http://stackoverflow.com/questions/21898491/what-kind-of-ogg-does-android-chrome-support?noredirect=1#comment33181251_21898491

muaz-khan commented 10 years ago

The WAV stream that FFMPEG converts should end up being a Vorbis audio stream. I’m fairly sure Android Chrome supports the Vorbis codec, it might just not like the .ogg container.

My best suggestion would be to try to change the PostBlob function to use a .webm container instead of .ogg for the audio file. The only reason I didn’t use a .webm container is because the javascript FFMPEG build doesn’t include the VP8 codec, which would allow a .webm extension. But since it’s audio-only, I see no reason why a .webm wouldn’t work.

var blob = new Blob([result.data], {
    type: 'video/webm'
});

var webm = document.createElement('video'); // maybe we can use "audio" here!
webm.src = URL.createObjectURL(blob);
webm.download = 'Converted Video.webm';

Another trick might be to specify the codec in the audio tag by giving it properties like this: type='audio/ogg; codecs=vorbis’

<audio controls>
    <source src="blob:domain" type='audio/ogg; codecs=vorbis’>
</audio>

via Gregory McGee!

Demo: https://www.webrtc-experiment.com/ffmpeg/wav-to-ogg.html

nathanathan commented 10 years ago

Thanks! That got it working. I should mention that I used audio/weba as the type, and weba as the file extension but I'm not sure if it made a difference.