Play .ts video file on Android? - android

I am pretty new at streaming video, so please bear with me. :)
I am trying to port an m3u8 stream over from iPhone to Android. Looking in the m3u8 feed, I found some .ts files. From what I can tell, .ts files are, themselves, wrappers that contain the video stream (Elementary Stream).
Is it possible to play a .ts file in Android? (The docs only list 3gp and mp4 as supported formats.)
Is there a way to extract the Elementary Stream and just process the video feed? If that is in 3gp or mp4, I should be ok.
Will Stagefright handle .ts? Is Stagefright even available? I read that there are/were some problems with it.
(As a further caveat, I am not getting much help from my server guys. They are pushing for a Flash player solution, including a proprietary player. They will not provide me with a 3gp or an mp4 feed, but I'm hoping I can find that in the .ts file.)
I'm open to other suggestions. Thanks for your patience with this newbie. :)

There is a standard for that called HTTP Live Streaming. Android 3.0 supports this protocol to some extent which means you can pass the URL of the m3u8 playlist to the MediaPlayer and the player should be able to stream it over HTTP. Stagefright is bundled with Android 3.0.
You can browse its source code here.
Also, this thread might interest you: it summarizes support for HTTP Live Streaming.

Android stagefright in Gingerbread and prior versions does not support playback of .ts (transport stream) or elementary stream. As you have rightly pointed out, it only supports MP4/3GP/MP3 file formats.

You can play .ts video file in android by using NDK based project. Dolphine player is best open source player for android and also supports various formats of video.
You got the .ts link from m3u file. Now you can fetch binary data from .ts file and store this binary data in file, then play this file by using video player.

Related

Android HLS support using Media Codec, Media Extractor API

Hi I am writing a media player with the help of Media Codec and Media Extractor API. It is working fine, when I tested with some HTTP links. Then I tested it with HTTP live stream URL, it is not working.
ex: "http://mediamotiononline.ios.internapcdn.net/mediamotiononline/inapcms/CMS16042/flash/16042_adaptive2.mp4.m3u8"
I have tried to parse m3u8 file, but it is giving info of Bandwidth, resolution only. With VideoView widget these Http live stream URLs works fine. But I am using Surface to show decoded data. Anyone has any idea how to solve this problem?
this might be help you.
Download m3u8 parser from http://sourceforge.net/projects/m3u8parser/
Add it to your project either jar file or source files.
By using this parser you can get PlaylistInfo, elements.
Explore for playable .ts files in elements. Pass those ts files to your MediaExtractor. It worked for me. Hope it will work for you
too..

Create a demultiplexer for MPEG 2 TS in android

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
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.

How to use Stagefright in Android?

I want to play .ts video file in my application.I am not getting any way do it.
I doubt it whether it is possible to do it or not in Android.
I have heard about Stagefright framework.So please tell me how I can use Stagefright in my application & whether it is able to play a .ts file or not.
Or is there any other way to play .ts file?
Thanks
There are 2 frameworks in Android(Stagefright & Nu-Player)
For Local Playback & Progressive Download(You-Tube) - Stagefright
For Streaming(rtsp/HLS) - Nu-Player
Coming to TS, if it is hosted in server and if you try to stream(http:///1.ts), then it is treated as Progressive Download(PD) just like You-Tube by your Android phone.
To play a local/PD content, Stagefright loads a Parser component(MPEG2TSExtractor.cpp) to parse the TS contents. In older version, the above mentioned parser module didn't have support for Progressive Download. That's the reason playback was not successful.
In recent versions this support is added.
If you are writing an APP, then you can rely only on existing Stagefright.
MXPlayer has it's own Multimedia framework to play the content.
I think that Android stagefright does not support playback of .ts (transport stream) or elementary stream. It only supports MP4/3GP/MP3 file formats or HLS playback(m2u8).
You can use the HLS(HTTP Live Streaming) to play your file, but you have to pass an url with this type http://xxxxxxxxxx.com/playlist.m3u8. You have to store your .ts files in the server though. Please refer here for more details.
Use GStreamer. It has support for Android, and can decode TS files.
Tutorial 5 needs a slight modification in Android.mk (in jni directory) to include TS plugins in GSTREAMER_PLUGINS:
mpeg2dec mpegdemux2 mpegtsdemux mpegtsmux
Then you are good to go. This is for mpeg2 inside the TS. Remember that TS is a container, so you will perhaps need to be specific on what codec the streams inside the TS are coded with.
Libstagefright has support for mpeg2ts (see on Android JellyBean framewroks/av/media/libstagefright/mpeg2ts)
It is supported from GingerBread (i guess).
StageFright has support for TS files, even though it is very limited, for starters seek is not supported.
Also it depends what video codec is being used in the TS file, StageFright implementation supports very few (only H264 i think but not sure on this). Apart from this StageFright implementation for TS files is also limited by google's TS parser implementation which is very basic too. It plays a very small subset of "possible" TS files. I say "possible" because TS standard ( ISO/IEC 13818-1) leaves a lot of room for interpretation and possibilities for encoders.

streaming a mp4 file using RTSP?

I am developing an app. that will stream the video recorded from camera and stored as mp4 in sdcard...
I know there something called as RTSP which is used for that...
Please tell me where to start . .and is there any library that will do this for me...
I do not understand why you want to stream a local mp4 file, but maybe I misunderstood you problem. RTSP is used for live streaming, but you want to play a local mp4 file.
If you want to capture video and save it as mp4 onto a SD card, you need to use the Android MediaRecorder. Here a link to a simple example.
If you just want to playback a local mp4 file. Have a look at the Android API Demos.
These are part of the Android SDK installation and contain a good example of how to playback local media files.

How to play .aac format audio file in android

How to play .aac audio format in android.
I tried using ffmpeg convert audio format and play in android-ndk. But im not able to implement.
Please let me know any ideas or any ref link to follow
You can check this native aac player implementation. It is ffmpeg-based, and I heard it is fairly light on CPU.
http://code.google.com/p/aacplayer-android/

Categories

Resources