Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPEG-TS, Android and FFMPEG

I am receiving the MPEG-TS (MPEG transport stream) packets with the multiplexed H.264 video and AAC audio streams. I need to be able to show the audio and video on the Android phone. My assumption is that I need:

  • MPEG-TS de-multiplexer
  • AAC decoder
  • H.264 decoder
  • Synchronize the audio and video playback

Assuming that I am right then (in Android 2.x) MPEG-TS de-multiplexer is not part of the OS and must be ported, both AAC and H.264 decoder are part of the Android OS, but I am not sure if they have interface, which allows passing the data in buffers and if they allow mutual timing synchronization. In the worst case those components must be ported here as well.

Can you give me some advices where to start? I was thinking about the FFMPEG porting. Are there any other ways?

Regards, STeN

like image 825
STeN Avatar asked Apr 01 '26 17:04

STeN


2 Answers

Android 4.x has OpenMAX which can play TS with H264 and AAC. You don't even need to worry about synchronisation of audio and video.

Look at the nativemedia sample in the NDK.

If you want to support previous versions of Android, then ffmpeg might be a good choice, but it the maximum it can give you is just decoded video frames in RGB or any other format and decoded audio in PCM. Then you will have to implement renderer and audio playback yourself. I would recommend reading this tutorial - http://dranger.com/ffmpeg/. It is not android specific but it will give you idea how video play works.

like image 192
Dmitry Avatar answered Apr 03 '26 06:04

Dmitry


You may refer to the android-ffmpeg project on github.

https://github.com/guardianproject/android-ffmpeg

like image 44
ciphor Avatar answered Apr 03 '26 08:04

ciphor



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!