FMUSER Wirless Transmit Video And Audio More Easier !
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
Recently made an Android project to use the encoding and decoding function. The general requirements are: take a video through the camera, then extract frames, generate a short video, and reverse video. At the beginning, it directly uses H.264 encoding format, without using MP4 container packaging. After doing these functions, I feel that MP4 format is more compatible with all models and reduces bugs. Take an obvious example: when Android is hard coded, the combination of mediacodec and mediaextractor is often used. However, if you use the H.264 naked video file, the setsource function of mediaextractor will report an exception. It can't parse the video file on some models (such as Meizu Note2, system is 5.1).
After getting the general requirements, we initially used ffmpeg to do video codec, so-called software codec. Due to the slow processing speed and the need for fast display after decoding, the scheme can not achieve our desired effect (a ffmpeg video decoding and saved as JPEG example: https://github.com/xiaoxiaoqingyi/ffmpeg-android-video-decoder )。 But it also has some advantages, such as good compatibility and color conversion. After all, it's not hardware codec (so many models in China, you know). Secondly, ffmpeg can output the specified frame, while mediacodec can't output the specified frame. You need to input several frames to the decoder to decode one frame. At present, I still haven't found a scheme to input a frame and solve a frame, which God knows can guide.
In the case of software codec is not suitable, we can only consider using hardware codec. A few days ago, I attended the Tencent 2017live live Developer Conference and learned that most of the live broadcast now uses hardware to encode and decode. Just said, some models can't use mediaextractor to parse H.264 files. In order to be compatible with most models, they need to parse them by themselves. By analyzing each byte of the H.264 file, they can distinguish the position of each frame and what type of frame it is. To achieve this requirement, first of all, the data obtained from the camera is set to nv21 format if camera is used, but some people use Camera2 and the format is image. No matter which format it is, it needs to be converted to yuv420sp or yuv420p (Note: when transcoding, it's better to use JNI, use C / C + + to convert the format, the efficiency will be many times higher), so that it can be encoded by mediacodec, and then save the H.264 file. When creating an instance of mediacodec, in addition to setting the required parameters, you should also pay attention to some aspects, such as which encoder to choose. Generally, you will choose the following:
MediaCodec.createEncoderByType ("video/avc");
This seems to be no problem. The basic principle is to get the best encoder, the first one in the Android system's encoder registry, which is usually hardware decoding (mediacodec can also call software codec). In fact, it's not very reliable to create an encoder in this way. Although the official website also recommends it, in many domestic android models, some mobile phones will have problems, some codes will have a blue screen, and some will flash back directly. There is a foreign example, which roughly means to obtain the "video / AVC" type encoder first, and then test one by one through try catch. If there is no problem, choose this encoder. Source code: mediacodec_ rtsp_ h264
Another problem is that when I-frame interval is set, some mobile phones do not work. The settings are as follows:
mediaFormat.setInteger ( MediaFormat.KEY_ I_ FRAME_ INTERVAL, interval);
In view of this situation, we need to use another way to set the I frame, which is mandatory setting:
Bundle params = new Bundle();
params.putInt ( MediaCodec.PARAMETER_ KEY_ REQUEST_ SYNC_ FRAME, 0);
mMediaCodec.setParameters (params);
In encoding and decoding, when all the data are input into the codec, remember to input the end character, then the codec will output all the frames.
There is also a frame extraction problem. If mediacodec is used to extract frames, a new video will be generated. Can I just remove the frame from the H.264 file? It doesn't work like this. There's usually a splash screen. This needs to re input the H.264 file to the decoder, and then get the frame you want, and then input it into a new encoder to generate the H.264 file you want. There is also a format problem here. It is not that the data decoded from the decoder can be directly encoded by the encoder. Some mobile phones can, and some will have blue screen or even flash back. In this case, we need to unify the format of the decoder. If you use this form to get:
mMediaCodec.getOutputBuffer ()
There are all kinds of formats out there, and it's hard for you to be compatible. Google has launched a new format:
mMediaCodec.getOutputImage (outIndex)
The result is an image object, which can be saved as a JPEG image or converted to nv21, like the shooting part above, converted to YUV422 format, and then input to the encoder. So no matter what model can be compatible (I try more than 10 different manufacturers of mobile phones), although a lot of detours.
|
Enter email to get a surprise
es.fmuser.org
it.fmuser.org
fr.fmuser.org
de.fmuser.org
af.fmuser.org ->Afrikaans
sq.fmuser.org ->Albanian
ar.fmuser.org ->Arabic
hy.fmuser.org ->Armenian
az.fmuser.org ->Azerbaijani
eu.fmuser.org ->Basque
be.fmuser.org ->Belarusian
bg.fmuser.org ->Bulgarian
ca.fmuser.org ->Catalan
zh-CN.fmuser.org ->Chinese (Simplified)
zh-TW.fmuser.org ->Chinese (Traditional)
hr.fmuser.org ->Croatian
cs.fmuser.org ->Czech
da.fmuser.org ->Danish
nl.fmuser.org ->Dutch
et.fmuser.org ->Estonian
tl.fmuser.org ->Filipino
fi.fmuser.org ->Finnish
fr.fmuser.org ->French
gl.fmuser.org ->Galician
ka.fmuser.org ->Georgian
de.fmuser.org ->German
el.fmuser.org ->Greek
ht.fmuser.org ->Haitian Creole
iw.fmuser.org ->Hebrew
hi.fmuser.org ->Hindi
hu.fmuser.org ->Hungarian
is.fmuser.org ->Icelandic
id.fmuser.org ->Indonesian
ga.fmuser.org ->Irish
it.fmuser.org ->Italian
ja.fmuser.org ->Japanese
ko.fmuser.org ->Korean
lv.fmuser.org ->Latvian
lt.fmuser.org ->Lithuanian
mk.fmuser.org ->Macedonian
ms.fmuser.org ->Malay
mt.fmuser.org ->Maltese
no.fmuser.org ->Norwegian
fa.fmuser.org ->Persian
pl.fmuser.org ->Polish
pt.fmuser.org ->Portuguese
ro.fmuser.org ->Romanian
ru.fmuser.org ->Russian
sr.fmuser.org ->Serbian
sk.fmuser.org ->Slovak
sl.fmuser.org ->Slovenian
es.fmuser.org ->Spanish
sw.fmuser.org ->Swahili
sv.fmuser.org ->Swedish
th.fmuser.org ->Thai
tr.fmuser.org ->Turkish
uk.fmuser.org ->Ukrainian
ur.fmuser.org ->Urdu
vi.fmuser.org ->Vietnamese
cy.fmuser.org ->Welsh
yi.fmuser.org ->Yiddish
FMUSER Wirless Transmit Video And Audio More Easier !
Contact
Address:
No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620
Categories
Newsletter