Android Video Coding H263 mp4v h264__ encoding

Source: Internet
Author: User

I said in the last article how to use JNI for H264 encoding, but it's not very practical because of the efficiency problem.

After several days of tossing, and referring to the general implementation of the http://www.javaeye.com/problems/27244 Android real-time coding problem, but only thinking, has not entered the stage of code implementation.

More important 2 classes of Mediarecorder Parcelfiledescriptor

Mediarecorder is a class that Android provides for collecting code, and Parcelfiledescriptor is a class that implements Setoutputfile with sockets.

In the process of testing the Liuzongan program, I found that the other person has achieved most of the functions we need, the only thing to deal with is the server-side program.

Here I guess the process of mediarecorder writing files

1, Mediarecorder writes a fixed head, estimates that the placeholder is 00H (the placeholder length seems to be related to the encoder used)

Insert more 6D (mdat box)


2, start coding, and the code after not a frame to add to the file, see 00 00 80 did not, understand h263 comrade must be very familiar with, is the 263 video logo.

(If there is audio data, it will be with the video data staggered together, but our goal is only real-time coding video streaming, do not need to process audio, so in the initialization of the Mediarecorder I do not want to Mediarecorder.setaudiosource, so there's no audio data. )

3 End capture. Mediarecorder should be returned to the head of the file to populate the header. But because it is not a real file relationship, can not return to the head, so the file header attached to the back of the file, feeling that is Liuzongan this guy asked the answer to the question.

This is the length of the file at the beginning of Mdat box, which replaces 00 00 00 08.

This is the header of the 3GP file, which replaces the beginning placeholder.

4 Finally, mediarecorder 3gp file Moov box, which is already part of the 3GP Media Index, the specific content for us has been less concerned about. We can refer to http://www.cnitblog.com/zouzheng/archive/2007/04/04/25155.html study.

Let's start by saying what we're doing.

In fact, with the above description, we should be able to think of what we want to achieve is actually the video of the frame can be.

Server-side processing h263 method

11 steps to find the Mdat this string, the following data is the video data we want,

2 in the stream to find 00 00 80 This flag, each is the beginning of a frame of data

For H264 and MPEG4, to prefetch data, this is because MP4V related decoding parameters, in the Esds box, and Esds box is at the end of the collection to write, so for our program to encode a first time to obtain the relevant decoding parameters mp4v, And then using the same parameters to collect, oh so we can get the original mp4v flow

H264 Just like the AvcC box.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.