国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

FFmpeg源碼分析:avcodec_send_packet()與avcodec_receive_frame()音視頻解碼

這篇具有很好參考價(jià)值的文章主要介紹了FFmpeg源碼分析:avcodec_send_packet()與avcodec_receive_frame()音視頻解碼。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

FFmpeg在libavcodec模塊,舊版本提供avcodec_decode_video2()作為視頻解碼函數(shù),avcodec_decode_audio4()作為音頻解碼函數(shù)。在FFmpeg 3.1版本新增avcodec_send_packet()與avcodec_receive_frame()作為音視頻解碼函數(shù)。后來(lái),在3.4版本把a(bǔ)vcodec_decode_video2()和avcodec_decode_audio4()標(biāo)記為過(guò)時(shí)API。版本變更描述如下:

FFmpeg 3.1

2016-04-21 - 7fc329e - lavc 57.37.100 - avcodec.h
Add a new audio/video encoding and decoding API with decoupled input
and output -- avcodec_send_packet(), avcodec_receive_frame(),
avcodec_send_frame() and avcodec_receive_packet().

FFmpeg 3.4

2017-09-26 - b1cf151c4d - lavc 57.106.102 - avcodec.h
Deprecate AVCodecContext.refcounted_frames. This was useful for deprecated
API only (avcodec_decode_video2/avcodec_decode_audio4). The new decode APIs
(avcodec_send_packet/avcodec_receive_frame) always work with reference
counted frames.

avcodec_send_packet()和avcodec_receive_frame()函數(shù)聲明位于libavcodec/avcodec.h。我們來(lái)看看函數(shù)聲明介紹:

/**
 * Supply raw packet data as input to a decoder.
 *
 * @param avctx codec context
 * @param[in] avpkt The input AVPacket. Usually, this will be a single video
 *                  frame, or several complete audio frames.
 *
 * @return 0 on success, otherwise negative error code:
 *      AVERROR(EAGAIN):   input is not accepted in the current state - user
 *                         must read output with avcodec_receive_frame()
 *      AVERROR_EOF:       the decoder has been flushed, and no new packets
 *      AVERROR(EINVAL):   codec not opened, it is an encoder, or requires flush
 *      AVERROR(ENOMEM):   failed to add packet to internal queue, or similar
 */
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt);


/**
 * Return decoded output data from a decoder.
 *
 * @param avctx codec context
 * @param frame This will be set to a reference-counted video or audio
 *              frame (depending on the decoder type) allocated by the
 *              decoder. Note that the function will always call
 *              av_frame_unref(frame) before doing anything else.
 *
 * @return
 *      0:                 success, a frame was returned
 *      AVERROR(EAGAIN):   output is not available in this state
 *      AVERROR_EOF:       the decoder has been fully flushed
 *      AVERROR(EINVAL):   codec not opened, or it is an encoder
 *      AVERROR_INPUT_CHANGED: current decoded frame has changed parameters
 */
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame);

由描述可知,avcodec_send_packet()負(fù)責(zé)把AVpacket數(shù)據(jù)包發(fā)送給解碼器,avcodec_receive_frame()則從解碼器取出一幀AVFrame數(shù)據(jù)。返回0,代表解碼成功;返回EAGAIN,代表當(dāng)前狀態(tài)無(wú)可輸出的數(shù)據(jù);返回EOF,代表到達(dá)文件流結(jié)尾;返回INVAL,代表解碼器未打開(kāi)或者當(dāng)前打開(kāi)的是編碼器;返回INPUT_CHANGED,代表輸入?yún)?shù)發(fā)生變化,比如width和height改變。

avcodec_send_packet()和avcodec_receive_frame()的解碼流程圖如下:

FFmpeg源碼分析:avcodec_send_packet()與avcodec_receive_frame()音視頻解碼

一、avcodec_send_packet發(fā)送AVPacket

1、avcodec_send_packet

avcodec_send_packet()函數(shù)位于libavcodec/decode.c,具體如下:

int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
{
? ? AVCodecInternal *avci = avctx->internal;
? ? int ret;
    // 判斷解碼器是否打開(kāi),是否為解碼器
? ? if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
? ? ? ? return AVERROR(EINVAL);
? ? if (avctx->internal->draining)
? ? ? ? return AVERROR_EOF;
? ? if (avpkt && !avpkt->size && avpkt->data)
? ? ? ? return AVERROR(EINVAL);

? ? av_packet_unref(avci->buffer_pkt);
? ? if (avpkt && (avpkt->data || avpkt->side_data_elems)) {
? ? ? ? ret = av_packet_ref(avci->buffer_pkt, avpkt);
? ? ? ? if (ret < 0)
? ? ? ? ? ? return ret;
? ? }
? ? // 發(fā)送packet到bitstream濾波器
? ? ret = av_bsf_send_packet(avci->bsf, avci->buffer_pkt);
? ? if (ret < 0) {
? ? ? ? av_packet_unref(avci->buffer_pkt);
? ? ? ? return ret;
? ? }
? ? if (!avci->buffer_frame->buf[0]) {
? ? ? ? ret = decode_receive_frame_internal(avctx, avci->buffer_frame);
? ? ? ? if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF)
? ? ? ? ? ? return ret;
? ? }

? ? return 0;
}

2、av_bsf_send_packet

由此可見(jiàn),內(nèi)部是調(diào)用av_bsf_send_packet()函數(shù)把packet發(fā)送給bitstream濾波器,代碼位于libavcodec/bsf.c,具體如下:

int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
{
    AVBSFInternal *bsfi = ctx->internal;
    int ret;

    if (!pkt || IS_EMPTY(pkt)) {
        bsfi->eof = 1;
        return 0;
    }
    if (bsfi->eof) {
        return AVERROR(EINVAL);
    }
    if (!IS_EMPTY(bsfi->buffer_pkt))
        return AVERROR(EAGAIN);
    // 申請(qǐng)AVPacket內(nèi)存,并拷貝數(shù)據(jù)
    ret = av_packet_make_refcounted(pkt);
    if (ret < 0)
        return ret;
	// 把pkt指針賦值給bsfi->buffer_pkt
    av_packet_move_ref(bsfi->buffer_pkt, pkt);

    return 0;
}

av_bsf_send_packet()函數(shù)內(nèi)部調(diào)用av_packet_make_refcounted()來(lái)申請(qǐng)AVPacket內(nèi)存,并拷貝數(shù)據(jù)。然后調(diào)用av_packet_move_ref()函數(shù)把pkt指針賦值給bsfi->buffer_pkt。

二、avcodec_receive_frame接收AVFrame

1、avcodec_receive_frame

avcodec_receive_frame()函數(shù)同樣位于libavcodec/decode.c,主要是調(diào)用內(nèi)部函數(shù)decode_receive_frame_internal()實(shí)現(xiàn)解碼,具體代碼如下:

int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
    AVCodecInternal *avci = avctx->internal;
    int ret, changed;

    av_frame_unref(frame);
    // 判斷解碼器是否打開(kāi),是否為解碼器
    if (!avcodec_is_open(avctx) || !av_codec_is_decoder(avctx->codec))
        return AVERROR(EINVAL);
    if (avci->buffer_frame->buf[0]) {
        av_frame_move_ref(frame, avci->buffer_frame);
    } else {
        ret = decode_receive_frame_internal(avctx, frame);
        if (ret < 0)
            return ret;
    }
    if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) {
        ret = apply_cropping(avctx, frame);
        if (ret < 0) {
            av_frame_unref(frame);
            return ret;
        }
    }

    ......
	
    return 0;
}

2、decode_receive_frame_internal

decode_receive_frame_internal()函數(shù)判斷是否支持avctx->codec->receive_frame,如果支持就調(diào)用avctx->codec->receive_frame()函數(shù)進(jìn)行解碼,否則調(diào)用decode_simple_receive_frame()函數(shù)進(jìn)行解碼。具體如下:

static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame)
{
    AVCodecInternal *avci = avctx->internal;
    int ret;

    if (avctx->codec->receive_frame) {
        ret = avctx->codec->receive_frame(avctx, frame);
        if (ret != AVERROR(EAGAIN))
            av_packet_unref(avci->last_pkt_props);
    } else {
        ret = decode_simple_receive_frame(avctx, frame);
	}
    ......
	
    /* free the per-frame decode data */
    av_buffer_unref(&frame->private_ref);
    return ret;
}

3、decode_simple_receive_frame

decode_simple_receive_frame()函數(shù)又調(diào)用decode_simple_internal()內(nèi)部函數(shù)進(jìn)行解碼:

static int decode_simple_receive_frame(AVCodecContext *avctx, AVFrame *frame)
{
    int ret;
    int64_t discarded_samples = 0;

    while (!frame->buf[0]) {
        if (discarded_samples > avctx->max_samples)
            return AVERROR(EAGAIN);
        ret = decode_simple_internal(avctx, frame, &discarded_samples);
        if (ret < 0)
            return ret;
    }

    return 0;
}

4、decode_simple_internal

由描述可知,decode_simple_internal()函數(shù)是解碼器的核心封裝函數(shù)。我們應(yīng)該循環(huán)調(diào)用avcodec_receive_frame()函數(shù),直到返回EAGAIN。通過(guò)判斷是否需要特定線程進(jìn)行解碼,如果需要就調(diào)用ff_thread_decode_frame()函數(shù),否則調(diào)用avctx->codec->decode指向的解碼函數(shù)。具體調(diào)用過(guò)程如下:

/*
 * The core of the receive_frame_wrapper for the decoders implementing
 * the simple API. Certain decoders might consume partial packets without
 * returning any output, so this function needs to be called in a loop until it
 * returns EAGAIN.
 **/
static inline int decode_simple_internal(AVCodecContext *avctx, 
										 AVFrame *frame, 
										 int64_t *discarded_samples)
{
    AVCodecInternal   *avci = avctx->internal;
    DecodeSimpleContext *ds = &avci->ds;
    AVPacket           *pkt = ds->in_pkt;
    int got_frame, actual_got_frame;
    int ret;

    if (!pkt->data && !avci->draining) {
        av_packet_unref(pkt);
        ret = ff_decode_get_packet(avctx, pkt);
        if (ret < 0 && ret != AVERROR_EOF)
            return ret;
    }
    if (avci->draining_done)
        return AVERROR_EOF;

    if (!pkt->data &&
        !(avctx->codec->capabilities & AV_CODEC_CAP_DELAY ||
          avctx->active_thread_type & FF_THREAD_FRAME))
        return AVERROR_EOF;

    got_frame = 0;

    if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) {
        ret = ff_thread_decode_frame(avctx, frame, &got_frame, pkt);
    } else {
        ret = avctx->codec->decode(avctx, frame, &got_frame, pkt);

        ......
    }
    
	......

    return ret < 0 ? ret : 0;
}

5、ff_thread_decode_frame

ff_thread_decode_frame()函數(shù)位于libavcodec/pthread_frame.c。首先是調(diào)用submit_packet()函數(shù)提交packet到下一個(gè)解碼線程,然后調(diào)用數(shù)組中最前面線程進(jìn)行解碼。相關(guān)代碼如下:

int ff_thread_decode_frame(AVCodecContext *avctx,
                           AVFrame *picture, 
						   int *got_picture_ptr,
                           AVPacket *avpkt)
{
    FrameThreadContext *fctx = avctx->internal->thread_ctx;
    int finished = fctx->next_finished;
    PerThreadContext *p;
    int err;
    async_unlock(fctx);

    /*
     * Submit a packet to the next decoding thread.
     */
    p = &fctx->threads[fctx->next_decoding];
    err = submit_packet(p, avctx, avpkt);
    if (err)
        goto finish;

    ......

    /* Return the next available frame from the oldest thread.*/
    do {
        p = &fctx->threads[finished++];
        if (atomic_load(&p->state) != STATE_INPUT_READY) {
            pthread_mutex_lock(&p->progress_mutex);
            while (atomic_load_explicit(&p->state, memory_order_relaxed) != STATE_INPUT_READY)
                pthread_cond_wait(&p->output_cond, &p->progress_mutex);
            pthread_mutex_unlock(&p->progress_mutex);
        }
        av_frame_move_ref(picture, p->frame);
        *got_picture_ptr = p->got_frame;
        picture->pkt_dts = p->avpkt->dts;
        err = p->result;
        p->got_frame = 0;
        p->result = 0;

        if (finished >= avctx->thread_count) finished = 0;
    } while (!avpkt->size && !*got_picture_ptr && err >= 0 && finished != fctx->next_finished);

    update_context_from_thread(avctx, p->avctx, 1);
    if (fctx->next_decoding >= avctx->thread_count)
		fctx->next_decoding = 0;
    fctx->next_finished = finished;
    /* return the size of the consumed packet if no error occurred */
    if (err >= 0)
        err = avpkt->size;
finish:
    async_lock(fctx);
    return err;
}

6、h264_decode_frame

以h264解碼器為例,位于libavcodec/h264dec.c,對(duì)應(yīng)的AVCodec如下:

AVCodec ff_h264_decoder = {
    .name                  = "h264",
    .long_name             = NULL_IF_CONFIG_SMALL("H.264/AVC/MPEG-4 AVC/MPEG-4 part10"),
    .type                  = AVMEDIA_TYPE_VIDEO,
    .id                    = AV_CODEC_ID_H264,
    .priv_data_size        = sizeof(H264Context),
    .init                  = h264_decode_init,
    .close                 = h264_decode_end,
    .decode                = h264_decode_frame,
    .capabilities          = AV_CODEC_CAP_DR1 |
                             AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SLICE_THREADS |
                             AV_CODEC_CAP_FRAME_THREADS,
    .flush                 = h264_decode_flush,
    .update_thread_context = ONLY_IF_THREADS_ENABLED(ff_h264_update_thread_context),
    .profiles              = NULL_IF_CONFIG_SMALL(ff_h264_profiles),
    .priv_class            = &h264_class,
};

此時(shí),?avctx->codec->decode函數(shù)指針指向的是h264_decode_frame。如果存在extradata就調(diào)用ff_h264_decode_extradata()函數(shù)解析,最關(guān)鍵是調(diào)用decode_nal_units()函數(shù)來(lái)解碼NAL單元。相關(guān)代碼如下:

static int h264_decode_frame(AVCodecContext *avctx, void *data,
                             int *got_frame, AVPacket *avpkt)
{
    ......

    ff_h264_unref_picture(h, &h->last_pic_for_ec);
    /* end of stream, output what is still in the buffers */
    if (buf_size == 0)
        return send_next_delayed_frame(h, pict, got_frame, 0);

    if (av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
        buffer_size_t side_size;
        uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
        ff_h264_decode_extradata(side, side_size,
                                 &h->ps, &h->is_avc, &h->nal_length_size,
                                 avctx->err_recognition, avctx);
    }
    if (h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC) {
		// 解析avcc對(duì)應(yīng)的extradata
        if (is_avcc_extradata(buf, buf_size))
            return ff_h264_decode_extradata(buf, buf_size,
                                            &h->ps, &h->is_avc, &h->nal_length_size,
                                            avctx->err_recognition, avctx);
    }
	// 解碼NAL單元
    buf_index = decode_nal_units(h, buf, buf_size);
    if (buf_index < 0)
        return AVERROR_INVALIDDATA;
    if (!h->cur_pic_ptr && h->nal_unit_type == H264_NAL_END_SEQUENCE) {
        av_assert0(buf_index <= buf_size);
        return send_next_delayed_frame(h, pict, got_frame, buf_index);
    }
    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) && (!h->cur_pic_ptr || !h->has_slice)) {
        if (avctx->skip_frame >= AVDISCARD_NONREF ||
            buf_size >= 4 && !memcmp("Q264", buf, 4))
            return buf_size;
        return AVERROR_INVALIDDATA;
    }
    if (!(avctx->flags2 & AV_CODEC_FLAG2_CHUNKS) ||
        (h->mb_y >= h->mb_height && h->mb_height)) {
        if ((ret = ff_h264_field_end(h, &h->slice_ctx[0], 0)) < 0)
            return ret;

        /* Wait for second field. */
        if (h->next_output_pic) {
            ret = finalize_frame(h, pict, h->next_output_pic, got_frame);
            if (ret < 0)
                return ret;
        }
    }

    ff_h264_unref_picture(h, &h->last_pic_for_ec);
    return get_consumed_bytes(buf_index, buf_size);
}

三、avcodec_decode_video2視頻解碼

由于avcodec_decode_video2()函數(shù)已經(jīng)過(guò)時(shí),所以內(nèi)部提供compat_decode()來(lái)兼容舊版本,具體代碼如下:

int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
                                              int *got_picture_ptr,
                                              const AVPacket *avpkt)
{
    return compat_decode(avctx, picture, got_picture_ptr, avpkt);
}

我們來(lái)看看compat_decode()函數(shù)源碼,其實(shí)內(nèi)部也是調(diào)用avcodec_send_packet()和avcodec_receive_frame()進(jìn)行解碼,具體如下:

static int compat_decode(AVCodecContext *avctx, AVFrame *frame,
                         int *got_frame, const AVPacket *pkt)
{
    AVCodecInternal *avci = avctx->internal;
    int ret = 0;
    *got_frame = 0;
	
    if (avci->draining_done && pkt && pkt->size != 0) {
        avcodec_flush_buffers(avctx);
    }
    if (avci->compat_decode_partial_size > 0 &&
        avci->compat_decode_partial_size != pkt->size) {
        ret = AVERROR(EINVAL);
        goto finish;
    }
    if (!avci->compat_decode_partial_size) {
		// 調(diào)用avcodec_send_packet發(fā)送packet
        ret = avcodec_send_packet(avctx, pkt);
        if (ret == AVERROR_EOF)
            ret = 0;
        else if (ret == AVERROR(EAGAIN)) {
            /* we fully drain all the output in each decode call, so this should not
             * ever happen */
            ret = AVERROR_BUG;
            goto finish;
        } else if (ret < 0)
            goto finish;
    }

    while (ret >= 0) {
		// 循環(huán)調(diào)用avcodec_receive_frame接收f(shuō)rame
        ret = avcodec_receive_frame(avctx, frame);
        if (ret < 0) {
            if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
                ret = 0;
            goto finish;
        }

        if (frame != avci->compat_decode_frame) {
            if (!avctx->refcounted_frames) {
                ret = unrefcount_frame(avci, frame);
                if (ret < 0)
                    goto finish;
            }

            *got_frame = 1;
            frame = avci->compat_decode_frame;
        } else {
            if (!avci->compat_decode_warned) {
                avci->compat_decode_warned = 1;
            }
        }

        if (avci->draining || (!avctx->codec->bsfs 
			&& avci->compat_decode_consumed < pkt->size)) {
            break;
		}
    }

finish:
    if (ret == 0) {
        /* if there are any bsfs then assume full packet is always consumed */
        if (avctx->codec->bsfs)
            ret = pkt->size;
        else
            ret = FFMIN(avci->compat_decode_consumed, pkt->size);
    }
    avci->compat_decode_consumed = 0;
    avci->compat_decode_partial_size = (ret >= 0) ? pkt->size - ret : 0;

    return ret;
}

四、avcodec_decode_audio4音頻解碼

和avcodec_decode_video2()函數(shù)一樣,avcodec_decode_audio4()函數(shù)已經(jīng)過(guò)時(shí),內(nèi)部也是提供compat_decode()來(lái)兼容舊版本,具體代碼如下:

int avcodec_decode_audio4(AVCodecContext *avctx,
                                              AVFrame *frame,
                                              int *got_frame_ptr,
                                              const AVPacket *avpkt)
{
    return compat_decode(avctx, frame, got_frame_ptr, avpkt);
}

至此,avcodec_send_packet()和avcodec_receive_frame()組成的解碼函數(shù)已經(jīng)分析完畢。

學(xué)習(xí)FFmpeg與代碼實(shí)踐,可參考:FFmpegAndroid文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-437490.html

到了這里,關(guān)于FFmpeg源碼分析:avcodec_send_packet()與avcodec_receive_frame()音視頻解碼的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • FFMPEG源碼之ffmpeg.c解析

    下面是對(duì)每個(gè)步驟的功能的詳細(xì)解釋: 初始化動(dòng)態(tài)加載。 調(diào)用init_dynload函數(shù),用于初始化動(dòng)態(tài)加載庫(kù)的相關(guān)資源,以便在需要時(shí)加載需要的庫(kù)。 注冊(cè)退出回調(diào)函數(shù)。 調(diào)用register_exit函數(shù),將ffmpeg_cleanup函數(shù)注冊(cè)為在程序退出時(shí)被調(diào)用的回調(diào)函數(shù)。 設(shè)置stderr的緩沖模式。 調(diào)用

    2024年02月15日
    瀏覽(24)
  • The last packet sent successfully to the server was 0 milliseconds ago.問(wèn)題分析

    英文描述 The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 中文描述: 上次成功發(fā)送到服務(wù)器的數(shù)據(jù)包是0毫秒前。驅(qū)動(dòng)程序尚未從服務(wù)器收到任何數(shù)據(jù)包。 檢查db鏈接地址,如果db無(wú)法連接,那么會(huì)出現(xiàn)這個(gè)錯(cuò)誤,問(wèn)題描述為

    2024年02月11日
    瀏覽(18)
  • 【MySQL技術(shù)專題】「問(wèn)題實(shí)戰(zhàn)系列」MySQL報(bào)錯(cuò)Got an error reading communication packets問(wèn)題分析指南

    【MySQL技術(shù)專題】「問(wèn)題實(shí)戰(zhàn)系列」MySQL報(bào)錯(cuò)Got an error reading communication packets問(wèn)題分析指南

    前因背景 當(dāng)系統(tǒng)服務(wù)的MySQL錯(cuò)誤日志中,發(fā)現(xiàn)大量以下類似信息:經(jīng)常收到客戶關(guān)于通信故障錯(cuò)誤的問(wèn)題—客戶面臨間歇性的”Got an error reading communication packet”錯(cuò)誤,這里分析這個(gè)錯(cuò)誤出現(xiàn)的原因,以及如何解決這個(gè)問(wèn)題。 官方解釋 下面看看官網(wǎng)怎么說(shuō): Aborted_connects:

    2024年02月07日
    瀏覽(20)
  • FFmpeg5.0源碼閱讀——FFmpeg大體框架

    FFmpeg5.0源碼閱讀——FFmpeg大體框架

    ?? 摘要 :前一段時(shí)間熟悉了下FFmpeg主流程源碼實(shí)現(xiàn),對(duì)FFmpeg的整體框架有了個(gè)大概的認(rèn)識(shí),因此在此做一個(gè)筆記,希望以比較容易理解的文字描述FFmpeg本身的結(jié)構(gòu),加深對(duì)FFmpeg的框架進(jìn)行梳理加深理解,如果文章中有紕漏或者錯(cuò)誤歡迎指出。本文描述了FFmpeg編解碼框架的

    2024年02月11日
    瀏覽(22)
  • FFmpeg開(kāi)發(fā)筆記(六)如何訪問(wèn)Github下載FFmpeg源碼

    FFmpeg開(kāi)發(fā)筆記(六)如何訪問(wèn)Github下載FFmpeg源碼

    ? 學(xué)習(xí)FFmpeg的時(shí)候,經(jīng)常要到GitHub下載各種開(kāi)源代碼,比如FFmpeg的源碼頁(yè)面位于https://github.com/FFmpeg/FFmpeg。然而國(guó)內(nèi)訪問(wèn)GitHub很不穩(wěn)定,經(jīng)常打不開(kāi)該網(wǎng)站,比如在命令行執(zhí)行下面的ping命令。 上面的ping結(jié)果如下所示,可見(jiàn)默認(rèn)解析的DNS地址連接超時(shí)。 現(xiàn)在GitHub的DNS請(qǐng)求超時(shí)

    2024年03月17日
    瀏覽(50)
  • FFmpeg學(xué)習(xí):FFmpeg4數(shù)據(jù)結(jié)構(gòu)分析

    FFmpeg學(xué)習(xí):FFmpeg4數(shù)據(jù)結(jié)構(gòu)分析

    FFMPEG中結(jié)構(gòu)體很多。最關(guān)鍵的結(jié)構(gòu)體可以分成以下幾類: 1、解協(xié)議(http,rtsp,rtmp,mms) AVIOContext,URLProtocol,URLContext主要存儲(chǔ)視音頻使用的協(xié)議的類型以及狀態(tài)。URLProtocol存儲(chǔ)輸入視音頻使用的封裝格式。每種協(xié)議都對(duì)應(yīng)一個(gè)URLProtocol結(jié)構(gòu)。(注意:FFMPEG中文件也被當(dāng)做一種協(xié)

    2024年02月05日
    瀏覽(20)
  • [FFmpeg] 源碼編譯

    git clone https://git.ffmpeg.org/ffmpeg.git git checkout -b 5.1 remotes/origin/release/5.1 ./configure --prefix=./OUT --enable-shared --disable-static make make install 默認(rèn)安裝路徑見(jiàn): /usr/local/bin /usr/local/include /usr/local/lib /usr/local/main/man1 /usr/local/main/man3 有 --prefix 參數(shù)的安裝路徑: [prefix]/bin [prefix]/include [prefix

    2024年02月10日
    瀏覽(18)
  • 源碼編譯FFmpeg4.3

    FreeSWITCH的mod_av模塊目前(1.10.11)暫不支持FFmpeg4.4(或者更高版本),但4.3就沒(méi)問(wèn)題 最近試了試源碼編譯FFmpeg4.3,記錄如下(系統(tǒng)centos7.9): git clone?GitHub - BtbN/FFmpeg-Builds 找到4.4.sh,改成這樣: GIT_BRANCH=\\\"release/4.3\\\" ./build.sh linux64 gpl 4.4 cd ffbuild/ffmpeg ./configure?--enable-shared make

    2024年02月01日
    瀏覽(22)
  • FFmpeg源碼走讀之內(nèi)存管理模型

    FFmpeg源碼走讀之內(nèi)存管理模型

    數(shù)據(jù)包管理過(guò)程中當(dāng)數(shù)據(jù)轉(zhuǎn)移到新的數(shù)據(jù)包時(shí)存在兩種操作一種是數(shù)據(jù)包之間相互獨(dú)立,當(dāng)新創(chuàng)建一份數(shù)據(jù)包時(shí),需要將原來(lái)的數(shù)據(jù)重新申請(qǐng)一個(gè)數(shù)據(jù)空間并且將數(shù)據(jù)拷貝到新的數(shù)據(jù)包中,具體過(guò)程如下圖所示。這種數(shù)據(jù)包的管理優(yōu)勢(shì)是在于數(shù)據(jù)之間相互獨(dú)立,不會(huì)存在數(shù)據(jù)

    2023年04月24日
    瀏覽(18)
  • FFmpeg5.0源碼閱讀——FFmpeg大體框架(以GIF轉(zhuǎn)碼為示例)

    FFmpeg5.0源碼閱讀——FFmpeg大體框架(以GIF轉(zhuǎn)碼為示例)

    ?? 摘要 :前一段時(shí)間熟悉了下FFmpeg主流程源碼實(shí)現(xiàn),對(duì)FFmpeg的整體框架有了個(gè)大概的認(rèn)識(shí),因此在此做一個(gè)筆記,希望以比較容易理解的文字描述FFmpeg本身的結(jié)構(gòu),加深對(duì)FFmpeg的框架進(jìn)行梳理加深理解,如果文章中有紕漏或者錯(cuò)誤歡迎指出。本文描述了FFmpeg編解碼框架的

    2024年02月10日
    瀏覽(23)

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包