ExoPlayer icon indicating copy to clipboard operation
ExoPlayer copied to clipboard

Implement MP3 audio support for HLS

Open andudo opened this issue 12 years ago • 13 comments

Not a priority for us at the moment. But we might focus on it later.

andudo avatar Oct 06 '14 19:10 andudo

I have posted a mostly working patch #229 tor MPEG 1/2 Layer I/II/III support

tresvecesseis avatar Jan 08 '15 17:01 tresvecesseis

+1 for this. I'm trying to play back a demuxed video over HLS. The mp3 audio is in one playlist and the h264 video in another. The video plays find as you'd expect, but the audio stream gives an error.

04-01 16:02:50.824    5947-6586/com.example.droid.app E/LoadTask﹕ Unexpected error loading stream
    java.lang.IllegalArgumentException
            at com.google.android.exoplayer.util.Assertions.checkArgument(Assertions.java:39)
            at com.google.android.exoplayer.util.ParsableByteArray.setPosition(ParsableByteArray.java:110)
            at com.google.android.exoplayer.util.ParsableByteArray.skip(ParsableByteArray.java:123)
            at com.google.android.exoplayer.hls.parser.TsExtractor.read(TsExtractor.java:179)
            at com.google.android.exoplayer.hls.TsChunk.load(TsChunk.java:123)
            at com.google.android.exoplayer.upstream.Loader$LoadTask.run(Loader.java:206)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)

biddster avatar Apr 01 '15 15:04 biddster

@tresvecesseis - Did you ever get this fully working? It should be much easier to finish now, since the extractor re-factoring that we've done more recently. We also have an Mp3Extractor, which is probably useful to copy code from.

ojw28 avatar May 29 '15 15:05 ojw28

yes, we are using this patch https://github.com/google/ExoPlayer/pull/325 for four moths in our player without problems and we will like to know if you have any problem with the pull request.

The only problem we have is with the unsupported codecs in android, as mpeg L1 and L2 (our audio is mpeg 1 layer II) are not officially supported in android and there is not a clear naming convention with these codecs, each vendor use a different mime type for these and other vendors use the same mime type as the mp3 codec (audio/mpeg) so it´s very difficult to detect codec support. For example in google nexus player there is not support for mpeg L1 or L2 but mp3 is supported with a codec that announces audio/mpeg support, in a humax box mpeg L2 support is supported with a codec with mime type audio/mpeg2, other white box use audio/mpeg-L2 and a third box uses audio/mpeg for mpeg L3 and mpeg L2 so we dont have a way to detect accurately mpeg L2 support based on the mime type.

tresvecesseis avatar May 29 '15 15:05 tresvecesseis

Ah, sorry, that kinda passed me by. We'd like to pull something here, I think! I tried patching it in, and it seems like it produces a native crash on my devices for the test stream in #501, which contains a TS_STREAM_TYPE_MPA_LSF stream. Any idea about that?

ojw28 avatar May 29 '15 15:05 ojw28

I think the problems is the codec support in your box, as per the last explanation I don´t have a way to identify what codec support mpeg audio so i use the generic audio/mpeg mime type to request a codec, but depending on the mpeg layer you could need to specify other mime type to select the right codec.

I did my test mainly with mpeg 1 L2 audios but i tested with some mpeg 1 L3, unfortunately i don´t streams with mpeg 2 audio tracks

tresvecesseis avatar May 29 '15 16:05 tresvecesseis

the audio in the playlist is:

Audio
ID                                       : 257 (0x101)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Audio
Format version                           : Version 2.5
Format profile                           : Layer 3
Mode                                     : Joint stereo
Mode extension                           : Intensity Stereo + MS Stereo
Codec ID                                 : 4
Duration                                 : 11s 442ms
Bit rate mode                            : Constant
Bit rate                                 : 24.0 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 11.025 KHz
Compression mode                         : Lossy
Delay relative to video                  : 2ms
Stream size                              : 33.5 KiB (16%)

unfortunately mpeg 2.5 is a non standard format and I don´t have specs.

tresvecesseis avatar May 29 '15 16:05 tresvecesseis

Ok. Do you have some standard HLS+MP3 example streams to test with?

ojw28 avatar May 29 '15 16:05 ojw28

no, all the links that I can provide you (privately) are progressive HTTP (or HLS) with MP2 audio

tresvecesseis avatar May 29 '15 16:05 tresvecesseis

Ok. I think we need some samples (that we can use for ongoing testing) before we can sanely merge this. I'll have a hunt around for some. If you happen to find any, let me know.

ojw28 avatar May 29 '15 16:05 ojw28

you could try with:

http://www.endlesspools.com/iphone/iphone_streams/Fastlane/Fastlane_128k.m3u8 http://www2.lapresse.it/video/mp4/1.15753/1.15753_128k.m3u8

I can´t test right now with an android box.

tresvecesseis avatar May 29 '15 17:05 tresvecesseis

i have tested several MPA and MPA_LSF layer III streams without problems:

movistar_fubol_hd_13.1Mbps.mp1l3.ts:

MacBook-Pro:MP3 tests sergio$ mediainfo movistar_fubol_hd_13.1Mbps.mp1l3.ts
...
Audio
ID                                       : 257 (0x101)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Mode                                     : Joint stereo
Mode extension                           : MS Stereo
Codec ID                                 : 3
Duration                                 : 16s 704ms
Bit rate mode                            : Constant
Bit rate                                 : 192 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Delay relative to video                  : -804ms
Stream size                              : 392 KiB (1%)
Writing library                          : LAME3.99.5
...

movistar_fubol_hd_13.1Mbps.mp2l3.ts:

MacBook-Pro:MP3 tests sergio$ mediainfo movistar_fubol_hd_13.1Mbps.mp2l3.ts
...
Audio
ID                                       : 257 (0x101)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Audio
Format version                           : Version 2
Format profile                           : Layer 3
Mode                                     : Joint stereo
Mode extension                           : MS Stereo
Codec ID                                 : 3
Duration                                 : 16s 728ms
Bit rate mode                            : Constant
Bit rate                                 : 160 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 24.0 KHz
Compression mode                         : Lossy
Delay relative to video                  : -827ms
Stream size                              : 327 KiB (1%)
Writing library                          : LAME3.99.5
...

you can get the test streams from:

https://drive.google.com/folderview?id=0Bzu4Z1WNC2reaUlPTl8xQ3lqSzg&usp=sharing

tresvecesseis avatar Jun 01 '15 16:06 tresvecesseis

This is now supported on the dev branch.

ojw28 avatar Jun 26 '15 14:06 ojw28