4

I have a requirement where I need to extract ID3 tags from a MPEG2 TS(HLS STREAM). MPEG2 has a limited support in android in regards to playing the file. But my concern is to extract the ID3 tags(playing the file is not necessary). Hence I am not concerned with the codecs(encoding and decoding).

I have explored the following options:

libstagefright and OpenMax : A playback engine implemented by Google from Android 2.0. It has a MediaExtractor is responsible for retrieving track data and the corresponding meta data from the underlying file system or http stream. But according to this post Adding video codec to Android I need to build my own firmware or my own media player.I am hoping I don't have to go down that path. More info on stagefright and openMax can be found here:

An overview of Stagefright player

Android’s Stagefright Media Player Architecture

Custom Wrapper Codec Integration into Android

How to integrate a decoder to multimedia framework

Compiling and using FFMPEG: A complete, cross-platform solution to record, convert and stream audio and video. We can demultiplex ts files with this library as mentioned here:

FFmpeg - Extracting video and audio from transport stream file (.ts).

But I am not sure if I will be able to extract the ID3 tags from the HLS Stream. libavformat might be able to do this but I still need to come up with a mechanism for signaling the read metadata to my application.

Compiling vlc for android: I have compiled vlc for android and made some modifications inside the transport module in demux component for extracting the tags, but it is not able to play all the streams that I am supplying to it.

After looking through these options , I am still at a fix in how to achieve this. I don't want to create a media player as I will not be playing the files nor do I want to build my own firmware. Using ffmpeg seems to be the most viable option, but I want to try this without using any third-party or open source library. My questions are:

Is it even possible to create a demultiplexer from scratch that will work on android?

If possible then ,how to go about it ?

Any options that I have missed?

I am new to this. Any help would be greatly appreciated..Thanks

Community
  • 1
  • 1
anz
  • 1,317
  • 2
  • 13
  • 25

1 Answers1

1

In android, there is a support to extract ID3 tags. Please refer to ID3 module for further details.

Integration of ID3 into MP3 extractor can be found here.

From a quick check, I have found that ID3 is supported from Froyo onwards.

Ganesh
  • 5,880
  • 2
  • 36
  • 54
  • Thanks for the reply..I have seen these files before, but does the android sdk expose these files in java? I have seen the MediaMetaDataRetriever class,but it does not work on MPEG 2 TS files. – anz Nov 12 '13 at 06:26
  • is there an java interface for MPEG2TSExtractor.cpp located in frameworks/base/media/libstagefright/mpeg2ts in android source tree – anz Nov 13 '13 at 08:21
  • @anz.. sorry about the delay. There is a `Java` interface to create the `MediaExtractor` as can be found here: http://androidxref.com/4.4_r1/xref/frameworks/base/media/java/android/media/MediaExtractor.java . The exact extractor would be created as part of `setDataSource` as can be observed here: http://androidxref.com/4.4_r1/xref/frameworks/base/tests/Camera2Tests/SmartCamera/SimpleCamera/src/androidx/media/filterfw/decoder/MediaDecoder.java#228 . Hopefully these links should help you. – Ganesh Nov 13 '13 at 15:26
  • One more useful link for `MPEG2-TS` is here: http://androidxref.com/4.4_r1/xref/frameworks/av/media/libstagefright/MediaExtractor.cpp#111 – Ganesh Nov 13 '13 at 16:38
  • 1
    Thanks for the help ... I have seen your expertise in this field and appreciate you helping me..Update here as soon as I find something – anz Nov 14 '13 at 06:42
  • I have finally worked out a solution for the problem..What I am doing is downloading the m3u8, parsing its contents, downloading the ts files individually to the local storage,started an HTTP server on the android device to make the files available to the mediaplayer...playing the individual ts files works fine but when I pass a local m3u8 file(everything is stored locally now), the media player throws an Error (1,-1010)..please help me out here – anz Nov 26 '13 at 06:09
  • @anz.. From your error `Error (1, -1010)`, I feel you are getting `ERROR_UNSUPPORTED` from the underlying player components (Ref: http://androidxref.com/4.4_r1/xref/frameworks/av/include/media/stagefright/MediaErrors.h#37) probably from here: http://androidxref.com/4.4_r1/xref/frameworks/av/media/libmediaplayerservice/nuplayer/StreamingSource.cpp#91 . If you can enable logs in `NuPlayer` and related modules, I can help you more. – Ganesh Nov 26 '13 at 08:41
  • thanks for the reply..players like mx player can play the local m3u8 files but not mediaplayer..Does it have to do with some internal implementation??How do I enable logs in NuPlayer? – anz Nov 26 '13 at 09:49
  • 1
    @anz.. I am not sure why `MediaPlayer` is not playing your file. IMHO, I feel its more a configuration issue than an implementation one. To enable logs, please check my response here: http://stackoverflow.com/questions/19923412/creating-omxcodec-encoder-in-hw-mode/20077707#comment29985028_20077707 – Ganesh Nov 26 '13 at 09:53
  • How can I recompile libStageFright.so . I am only working on an application level here..Thanks – anz Nov 26 '13 at 09:59
  • I implemented a local http server on my device to play some locally stored ts files and extract id3 tags...Now , I am looking into android mediaplayer framework to figure out their HLS implementation. But I am not able to find out the exact c++ source code where its done..It would be very helpful if you could point that out..Thanks – anz Dec 12 '13 at 06:21
  • @anz.. Could you please be specific on what you are trying to looking for? Is it `HLS` implementation or something different? – Ganesh Dec 12 '13 at 09:29
  • 1
    @anz.. I presume this should help: http://androidxref.com/4.4_r1/xref/frameworks/av/media/libstagefright/httplive/ – Ganesh Dec 16 '13 at 10:22
  • Sorry for asking again...but where is this code called from java – anz Dec 20 '13 at 06:27
  • is it possible to use libstagefright.so in our application without building the android source from scratch...something like include the header file i need to use and create a jni wrapper around it... – anz Dec 26 '13 at 12:14
  • @anz.. `libstagfright.so` is directly called from application already.. This library has the native implementations of `MediaPlayer`, `MediaRecorder`, `MediaExtractor`, `MediaCodec`, `MediaMuxer` etc.. I couldn't understand your query when you say you would like to use the same from JNI.. I will answer your previous query shortly – Ganesh Dec 26 '13 at 14:49