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
H264
The structure of Nalu is Nalu, and the structure of Nalu is nal head +rbsp. The data flow in actual transmission is shown in the figure:
Here is the picture description
The nal header accounts for one byte, and the lower 5 bit bits represent the nal type, as shown in the following table:
NAL type | Nal type |
0 | not used |
one | Non IDR films |
two | Slice data a partition |
three | Slice data partition B |
four | Slice data C partition |
five | The film of IDR image |
six | Supplementary enhancement information unit (SEI) |
seven | Sequence parameter set (SPS) |
eight | Image parameter set (PPS) |
nine | Demarcation mark |
ten | End of sequence |
eleven | End of stream |
twelve | fill |
13..23 | retain |
24..31 | No reservation |
RBSP is the original byte sequence load.
If the nal type is 5, the frame is I frame, i.e. keyframe, and non key frame (P frame...) when type is 1.
In the actual H264 data frame, the nal type of the frame is usually preceded by a 00, 001 or 00001 separator. Generally speaking, the first frame data compiled by the encoder is PPS and SPS, followed by frame I, and then P frame
Easypusher/easytmp video streaming push
Easypusher and easytmp are used to obtain H264 video stream and audio video stream to local as video source by calling camera SDK, pulling RTSP stream, reading MP4 file, etc., and then pushing them to streaming media server by RTSP and RTMP. They are all video streaming push programs that support windows, Linux, Android, IOS, arm and other platforms.
The following describes how they distinguish I frame and P frame after they get the video stream to local, and then push them:
//This code reads H264 data from the file and pushes it to the server
unsigned char *ptr=new unsigned char [sample_ size];
fread(ptr, sample_ size, 1, g_ fin);
//Write a frame of data - can be pushed directly on the network
//fwrite(ptr, sample_ size, 1, fout);
EASY_ AV_ Frame avFrame;
memset(&avFrame, 0x00, sizeof(EASY_ AV_ Frame));
/*
*The first 4 bytes of PTR are frame division character 0000001, and the fifth byte is nal type
*/
unsigned char naltype = ( (unsigned char)ptr[4] & 0x1F);
avFrame.pBuffer = (unsigned char*)ptr;
avFrame.u32AVFrameLen = sample_ size;
avFrame.u32VFrameType = (naltype==0x05)? EASY_ SDK_ VIDEO_ FRAME_ I:EASY_ SDK_ VIDEO_ FRAME_ P;
avFrame.u32AVFrameFlag = EASY_ SDK_ VIDEO_ FRAME_ FLAG;
avFrame.u32TimestampSec = lTimeStamp/1000000;
avFrame.u32TimestampUsec = (lTimeStamp%1000000);
If the video source is not a file, but an IPcamera or RTSP stream, they may have already informed the current frame whether the current frame is an I frame or a P frame in their video streaming back modulation, so the steps to judge the nal type are omitted.
HI_ S32 NETSDK_ APICALL OnStreamCallback(HI_ U32 u32handle, / * handle*/
HI_ U32 u32datatype, / * data type, video or audio data or audio video composite data*/
HI_ U8* pu8buffer, / * data contains frame header*/
HI_ U32 u32length, / * data length*/
HI_ Void* puserdata / * user data*/
)
{
HI_ S_ AVFrame* pstruAV = HI_ NULL;
HI_ S_ SysHeader* pstruSys = HI_ NULL;
if (u32DataType == HI_ NET_ DEV_ AV_ DATA)
{
pstruAV = (HI_ S_ AVFrame*)pu8Buffer;
if (pstruAV->u32AVFrameFlag == HI_ NET_ DEV_ VIDEO_ FRAME_ FLAG)
{
if(fPusherHandle == 0 ) return 0;
if(pstruAV->u32AVFrameLen > 0)
{
unsigned char* pbuf = (unsigned char*)(pu8Buffer+sizeof(HI_ S_ AVFrame));
EASY_ AV_ Frame avFrame;
memset(&avFrame, 0x00, sizeof(EASY_ AV_ Frame));
avFrame.u32AVFrameLen = pstruAV->u32AVFrameLen;
avFrame.pBuffer = (unsigned char*)pbuf;
avFrame.u32VFrameType = (pstruAV->u32VFrameType==HI_ NET_ DEV_ VIDEO_ FRAME_ I)? EASY_ SDK_ VIDEO_ FRAME_ I:EASY_ SDK_ VIDEO_ FRAME_ P;
avFrame.u32AVFrameFlag = EASY_ SDK_ VIDEO_ FRAME_ FLAG;
avFrame.u32TimestampSec = pstruAV->u32AVFramePTS/1000;
avFrame.u32TimestampUsec = (pstruAV->u32AVFramePTS%1000)*1000;
EasyPusher_ PushFrame(fPusherHandle, &avFrame);
}
}
else
if (pstruAV->u32AVFrameFlag == HI_ NET_ DEV_ AUDIO_ FRAME_ FLAG)
{
if(fPusherHandle == 0 ) return 0;
if(pstruAV->u32AVFrameLen > 0)
{
//Different IPcamera, the data header is different here, and the corresponding size needs to be skipped according to their SDK. Some may not have custom data
unsigned char* pbuf = (unsigned char*)(pu8Buffer+sizeof(HI_ S_ AVFrame));
EASY_ AV_ Frame avFrame;
memset(&avFrame, 0x00, sizeof(EASY_ AV_ Frame));
avFrame.u32AVFrameLen = pstruAV->u32AVFrameLen-4;// Remove the manufacturer-defined 4-byte header
avFrame.pBuffer = (unsigned char*)pbuf+4;
avFrame.u32AVFrameFlag = EASY_ SDK_ AUDIO_ FRAME_ FLAG;
avFrame.u32TimestampSec = pstruAV->u32AVFramePTS/1000;
avFrame.u32TimestampUsec = (pstruAV->u32AVFramePTS%1000)*1000;
EasyPusher_ PushFrame(fPusherHandle, &avFrame);
}
}
}
else
if (u32DataType == HI_ NET_ DEV_ SYS_ DATA)
{
pstruSys = (HI_ S_ SysHeader*)pu8Buffer;
printf("Video W:%u H:%u Audio: %u \n", pstruSys->struVHeader.u32Width, pstruSys->struVHeader.u32Height, pstruSys->struAHeader.u32Format);
}
return HI_ SUCCESS;
}
With data source, you can push RTSP and RTMP live by calling libeasypusher or libeasyrtmp!
|
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