Android: mpeg4/H.264 packetization example

让人想犯罪 __ 提交于 2020-01-02 09:59:36

问题


I need to split mpeg4 video stream (actually from android video camera) to send it through RTP. The specification is little large for quick reference.

I wonder if there any example/open source code for mpeg4 packetization?

Thanks for any help !


回答1:


Mpeg4 file format is also called ISO/IEC 14496-14. Google it any you will find specifications. However, what you are trying to do (RTP publisher) will be hard for the following reasons:

  1. Mpeg4 has header at the end of the file. Which means header will be written out only when video stream is finished. Since you want to do real time video streaming you will need to guess where audio and video packets start/end. This will not be the same on all Android devices as they might use different video sizes and codec parameters. So your code will be device-dependent and you'll need to support and test many different devices.

  2. Some devices do not flush video data to file in regular intervals. Some only flush once a minute or so. This will break your real-time stream.

  3. There is no example code. I know because I looked. There are a few companies that do something similar, but mainly they skip RTP. Instead they progressively upload the file to their own server and then implement video/audio stream "chopping" and then insert it into their video/transcoder backend. I used to work for one of those companies and that's how we did it. AFAIK competition took similar approaches. The upside is that all complexity is on server an you do not need to update clients when something breaks or new devices arrive on the market.



来源:https://stackoverflow.com/questions/5869522/android-mpeg4-h-264-packetization-example

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!