Use MediaCodec for H264 streaming

后端 未结 3 1354
情深已故
情深已故 2021-02-06 06:47

I\'m currently trying to use Android as a Skype endpoint. At this stage, I need to encode video into H.264 (since it\'s the only format supported by Skype) and encapsulate it wi

3条回答
  •  我在风中等你
    2021-02-06 07:18

    UPDATE
    I was finally able to create proper RTP packages from the h264 frames. Here's what you have to keep in mind (it's actually quite simple):

    The encoder does create NAL headers for each frame. But it returns each frame as a h264 bytestream. This means that each frame starts with three 0-bytes and a 1-byte. All you have to do is remove those start prefixes, and put the frame into a RTP packet (or split them up using FU-As).

    Now to your questions:

    I cannot find a way to store its raw data into a buffer before encoding. Is addCallbackBuffer suited for this?

    You should use camera.setPreviewCallback(...), and add each frame to the encoder.

    I cannot find a lot of documentation about MediaCodec (since it's fairly new). Anyone who has a solid tutorial?

    This should be a good introduction as to how the MediaCodec works. http://dpsm.wordpress.com/2012/07/28/android-mediacodec-decoded/

    Lastly: any recommendations on RTP libraries?

    I'm using jlibrtp which gets the job done.

提交回复
热议问题