[Live-devel] i can not transfer the h264 and ADTS AAC data together to STB From EasyDarwin

lijun at ndtv.com.cn lijun at ndtv.com.cn
Fri Feb 1 18:54:23 PST 2019


<span style="white-space:nowrap;"><span style="white-space:nowrap;"><span style="white-space:nowrap;">i can not transfer the h264 and ADTS AAC together to STB From EasyDarwin</span><br />
<span style="white-space:nowrap;"><br />
</span><span style="white-space:nowrap;">Below is my procedure</span><br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:nowrap;">step1:</span><br />
<span style="white-space:nowrap;">ffmpeg -re -stream_loop -1 -i D:\h264_and_aac.mp4   -rtsp_transport tcp -vcodec copy            -acodec copy  -f rtsp rtsp://127.0.0.1:554/test</span><br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:nowrap;">step2:</span><br />
<span style="white-space:nowrap;">use RTSPClient code get h264 and aac stream from rtsp://127.0.0.1:554/test</span><br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:nowrap;">step3:</span><br />
<span style="white-space:nowrap;">i add ADTS header for aac raw data,   by my test(store it to disk as AAC file then using VLC play) is ok.</span><br />
<span style="white-space:nowrap;">and h264 is ok too, by above test.</span><br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:nowrap;">step4:</span><br />
<span style="white-space:nowrap;">now i create my RTSPServer for pack these two streams to ts, so  STB(Set Top Box) can play it because STB only support TS.</span><br />
<span style="white-space:nowrap;">i create a media subsession  for mix these two stream   and convert it to TS stream</span><br />
<span style="white-space:nowrap;">#define SUPPORT_AAC_ADTS</span><br />
<span style="white-space:pre;"> </span>FramedSource * TSFromH264BlockServerMediaSubsession::createNewStreamSource(unsigned /*clientSessionId*/, unsigned & estBitrate)<br />
<span style="white-space:pre;"> </span>{<br />
<span style="white-space:pre;"> </span>estBitrate = 2500; // kbps, estimate<br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:pre;"> </span>// Then create a filter that packs the H.264 video data and ADTS AAC audio data into a Transport Stream:<br />
<span style="white-space:pre;"> </span>MPEG2TransportStreamFromESSource* tsFrames = MPEG2TransportStreamFromESSource::createNew(envir());<br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:pre;"> </span>BlockSource* blockSource = BlockSource::createNew(envir(), _strBlockName.c_str());//H264 from RTSPClient<br />
<span style="white-space:pre;"> </span>if (blockSource == NULL)<br />
<span style="white-space:pre;"> </span>return NULL;<br />
<span style="white-space:pre;"> </span>H264VideoStreamFramer* framer = H264VideoStreamFramer::createNew(envir(), blockSource, True/*includeStartCodeInOutput*/);<br />
<span style="white-space:pre;"> </span>tsFrames->addNewVideoSource(framer, 5/*mpegVersion: H.264*/);<br />
<span style="white-space:nowrap;">#ifdef SUPPORT_AAC_ADTS</span><br />
<span style="white-space:pre;"> </span>AACADTSSource* adtsSource = AACADTSSource::createNew(envir(), _strBlockName.c_str());//ADTS AAC from RTSPClient<br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:pre;"> </span>if (adtsSource != nullptr)<br />
<span style="white-space:pre;"> </span>{<br />
<span style="white-space:pre;"> </span>tsFrames->addNewAudioSource(adtsSource, 4/*mpegVersion: AAC*/);<br />
<span style="white-space:pre;"> </span>}<br />
<span style="white-space:nowrap;">#endif</span><br />
<span style="white-space:pre;"> </span>// Create a framer for the Video Elementary Stream:<br />
<span style="white-space:pre;"> </span>return MPEG2TransportStreamFramer::createNew(envir(), tsFrames);//blockSource<br />
<span style="white-space:pre;"> </span>}<br />
<span style="white-space:nowrap;"><br />
</span><br />
<span style="white-space:pre;"> </span>RTPSink * TSFromH264BlockServerMediaSubsession::createNewRTPSink(Groupsock * rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource * inputSource)<br />
<span style="white-space:pre;"> </span>{<br />
<span style="white-space:pre;"> </span>return SimpleRTPSink::createNew(envir(), rtpGroupsock,<br />
<span style="white-space:pre;"> </span>33, 90000, "video", "MP2T",<br />
<span style="white-space:pre;"> </span>1, True, False /*no 'M' bit*/);<br />
<span style="white-space:pre;"> </span>}<br />
<span style="white-space:pre;"> </span><br />
<span style="white-space:nowrap;">Final step:</span><br />
<span style="white-space:nowrap;"> finally i play from  my RTSPServer in STB</span><br />
<span style="white-space:nowrap;"> but only can play audio or only can play video,</span><br />
<span style="white-space:nowrap;"> if i mix them two only can play audio in STB.</span><br />
<span style="white-space:nowrap;"> </span><br />
<span style="white-space:nowrap;"> </span><br />
<span style="white-space:nowrap;"> </span><br />
<span style="white-space:nowrap;">There is going to be the Spring Festival after a few days, wish  all things are right in the New Year.</span><br />
</span></span><span style="white-space:nowrap;"></span><br />
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20190202/57cf05b6/attachment.html>


More information about the live-devel mailing list