當(dāng)前是用的是3.4版本的FFmpeg
av_register_all
??? avformat_open_input
??????? avformat_find_stream_info
??????????? avcodec_find_decoder
??????????????? avcodec_open2
av_read_frame
??? avcodec_send_packet
??????? avcodec_receive_frame
創(chuàng)新互聯(lián)是專業(yè)的蒼梧網(wǎng)站建設(shè)公司,蒼梧接單;提供網(wǎng)站設(shè)計(jì)、網(wǎng)站建設(shè),網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行蒼梧網(wǎng)站開發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
申請(qǐng)過(guò)程
1)調(diào)用avformat_alloc_context創(chuàng)建一個(gè)AVFormatContext變量的實(shí)例pAVFormatContext
AVFormatContext* pAVFormatContext = avformat_alloc_context();
2)調(diào)用avio_alloc_context創(chuàng)建一個(gè)AVIOContext變量的實(shí)例pAVIOContext
AVIOContext* pAVIOContext = avio_alloc_context(mallocBuffer,? mallocBufferSize, 0, this, ReadStreamData, NULL, NULL);
該函數(shù)中ReadStreamData用于讀取讀取的網(wǎng)絡(luò)或者文件中的視頻或者音頻流的函數(shù),mallocBuffer用于保存讀取到的數(shù)據(jù)用于分析,mallocBufferSize是分配的緩存長(zhǎng)度,一旦mallocBufferSize申請(qǐng)的緩存長(zhǎng)度小于返回讀取的數(shù)據(jù)長(zhǎng)度會(huì)導(dǎo)致拷貝到緩存中的數(shù)據(jù)越界,導(dǎo)致程序崩潰
3)如果已經(jīng)知道數(shù)據(jù)的格式為h364,調(diào)用av_find_input_format創(chuàng)建一個(gè)AVInputFormat變量的實(shí)例pAVInputFormat
AVInputFormat* pAVInputFormat = av_find_input_format("h364");
pAVFormatContext->iformat = pAVInputFormat;
if (avformat_open_input(&pAVFormatContext, "", pAVInputFormat, NULL) < 0)
4)開始探測(cè)碼流格式
avformat_find_stream_info(pAVFormatContext, NULL);
釋放過(guò)程
avformat_close_input(pAVFormatContext);
分析該函數(shù)分為三部分
第一部分
關(guān)閉輸入:
??? if (s->iformat)
??????? if (s->iformat->read_close)
??????????? s->iformat->read_close(s);
對(duì)于播放rtsp://admin:admin888@192.168.28.130:554/h364/ch2/main/av_stream,主要是發(fā)送TearDown指令給攝像機(jī)
第二部分
avio_close(pb)
第三部分
avformat_free_context(s)
該函數(shù)的核心就是釋放申請(qǐng)創(chuàng)建的視頻和音頻的流??
?for (i = s->nb_streams - 1; i >= 0; i--)
??????? ff_free_stream(s, s->streams[i]);
分享題目:FFmpegAVFormatContext變量的申請(qǐng)以及釋放剖析
分享網(wǎng)址:http://jinyejixie.com/article14/gpscde.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站改版、網(wǎng)站收錄、做網(wǎng)站、軟件開發(fā)、面包屑導(dǎo)航、全網(wǎng)營(yíng)銷推廣
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)