It seems I want to convert audios, which I want to stream on my website, to audio/mp4; codecs="mp4a.40.2"
.
Using ffmpeg-cli-wrapper
, I am converting my uploaded audio files with this command here:
ffmpeg -i /tmp/input.any -acodec aac -b:a 256000 /tmp/output.aac
On the client I am creating a SourceBuffer like this:
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/mp4; codecs="mp4a.40.2"');
The errors are:
Chrome:
NotSupportedError: Failed to load because no supported source was found.
Firefox:
NotSupportedError: The media resource indicated by the src attribute or assigned media provider object was not suitable.
Here comes the fun part:
If I create the SourceBuffer using audio/aac
as mime-type:
this.sourceBuffer = this.mediaSource.addSourceBuffer('audio/aac');
the audio gets played correctly on Chrome but Firefox says:
MediaSource.addSourceBuffer: Type not supported in MediaSource
Update
After changing the command to
ffmpeg -i /tmp/input.any -acodec aac -b:a 256000 /tmp/output.mp4
^^^
Chrome/Firefox do not give an error when using audio/mp4; codecs="mp4a.40.2"
, but the audio is not being played.