国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

彩票網(wǎng)站開發(fā)風險國外網(wǎng)站制作

彩票網(wǎng)站開發(fā)風險,國外網(wǎng)站制作,網(wǎng)站主機推薦,大連網(wǎng)站制作的公司哪家好try_decode_video_frame /*** 嘗試解碼視頻幀** param codec_ctx 解碼器上下文* param pkt 待解碼的視頻數(shù)據(jù)包* param decode 是否解碼標志,如果為1,則進行解碼,如果為0,則不解碼* return 返回0表示成功,否則表示出錯…

try_decode_video_frame

/*** 嘗試解碼視頻幀** @param codec_ctx 解碼器上下文* @param pkt 待解碼的視頻數(shù)據(jù)包* @param decode 是否解碼標志,如果為1,則進行解碼,如果為0,則不解碼* @return 返回0表示成功,否則表示出錯*/
static int try_decode_video_frame(AVCodecContext *codec_ctx, AVPacket *pkt, int decode)
{int ret = 0;int got_frame = 0;AVFrame *frame = NULL;int skip_frame = codec_ctx->skip_frame;// 如果解碼器未打開,則打開解碼器if (!avcodec_is_open(codec_ctx)) {const AVCodec *codec = avcodec_find_decoder(codec_ctx->codec_id);ret = avcodec_open2(codec_ctx, codec, NULL);if (ret < 0) {av_log(codec_ctx, AV_LOG_ERROR, "Failed to open codec\n");goto end;}}// 分配一個AVFrame結(jié)構(gòu)體frame = av_frame_alloc();if (!frame) {av_log(NULL, AV_LOG_ERROR, "Failed to allocate frame\n");goto end;}// 如果不需要解碼,并且解碼器支持跳幀填充參數(shù),則將跳幀設(shè)置為AVDISCARD_ALLif (!decode && avpriv_codec_get_cap_skip_frame_fill_param(codec_ctx->codec)) {codec_ctx->skip_frame = AVDISCARD_ALL;}// 循環(huán)解碼視頻幀do {// 解碼視頻幀ret = avcodec_decode_video2(codec_ctx, frame, &got_frame, pkt);av_assert0(decode || (!decode && !got_frame));if (ret < 0)break;pkt->data += ret;pkt->size -= ret;// 如果成功解碼到一幀視頻,則退出循環(huán)if (got_frame) {break;}} while (pkt->size > 0);end:// 恢復(fù)skip_frame的原始值codec_ctx->skip_frame = skip_frame;// 釋放AVFrame結(jié)構(gòu)體av_frame_free(&frame);return ret;
}

find_video_stream_info

/*** 查找視頻流信息并嘗試解碼視頻幀** @param fmt_ctx AVFormatContext 結(jié)構(gòu)體,表示輸入文件的格式上下文* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼* @return 返回 0 表示成功,否則表示出錯*/
static int find_video_stream_info(AVFormatContext *fmt_ctx, int decode)
{int ret = 0;int i, done = 0;AVPacket pkt;// 初始化 AVPacket 結(jié)構(gòu)體av_init_packet(&pkt);// 循環(huán)讀取視頻幀數(shù)據(jù),直到所有視頻流都有數(shù)據(jù)包while (!done) {AVCodecContext *codec_ctx = NULL;AVStream *st;// 從輸入文件中讀取視頻幀數(shù)據(jù)包if ((ret = av_read_frame(fmt_ctx, &pkt)) < 0) {av_log(fmt_ctx, AV_LOG_ERROR, "Failed to read frame\n");goto end;}// 獲取視頻流的解碼器上下文st = fmt_ctx->streams[pkt.stream_index];codec_ctx = st->codec;// 不是視頻流或已經(jīng)解碼過一幀視頻則跳過if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO ||st->codec_info_nb_frames++ > 0) {av_packet_unref(&pkt);continue;}// 嘗試解碼視頻幀ret = try_decode_video_frame(codec_ctx, &pkt, decode);if (ret < 0) {av_log(fmt_ctx, AV_LOG_ERROR, "Failed to decode video frame\n");goto end;}// 釋放 AVPacket 結(jié)構(gòu)體av_packet_unref(&pkt);// 檢查是否所有視頻流都已經(jīng)解碼完畢done = 1;for (i = 0; i < fmt_ctx->nb_streams; i++) {st = fmt_ctx->streams[i];codec_ctx = st->codec;if (codec_ctx->codec_type != AVMEDIA_TYPE_VIDEO)continue;done &= st->codec_info_nb_frames > 0;/*在 FFmpeg 的 AVCodecContext 結(jié)構(gòu)體中,codec_info_nb_frames 是一個用于存儲編解碼器相關(guān)幀數(shù)量信息的成員變量。這個變量通常用于在編解碼過程中跟蹤已經(jīng)處理的幀數(shù)。在 FFmpeg 中,幀是視頻編碼的基本單位,而 codec_info_nb_frames 則是與當前編解碼器相關(guān)聯(lián)的幀的數(shù)量。
在代碼中,codec_info_nb_frames 被用作檢查視頻流是否已經(jīng)解碼完成的標志。通過檢查 codec_info_nb_frames 是否大于 0,可以判斷當前視頻流是否已經(jīng)解碼了至少一幀。這在處理視頻流時非常有用,因為它可以幫助確定是否還有待處理的幀數(shù)據(jù),或者是否已經(jīng)處理完所有的幀數(shù)據(jù)。
總之,codec_info_nb_frames 是一個用于存儲編解碼器相關(guān)幀數(shù)量信息的成員變量,它在 FFmpeg 中用于跟蹤已經(jīng)處理的幀數(shù),并在視頻編解碼過程中起到重要的作用。*/}}end:// 釋放 AVPacket 結(jié)構(gòu)體av_packet_unref(&pkt);// 關(guān)閉所有在 try_decode_video_frame 中打開的解碼器for (i = 0; i < fmt_ctx->nb_streams; i++) {AVStream *st = fmt_ctx->streams[i];avcodec_close(st->codec);}// 返回解碼結(jié)果return ret < 0;
}
/*** 打印視頻流信息** @param fmt_ctx AVFormatContext 結(jié)構(gòu)體,表示輸入文件的格式上下文* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼*/
static void dump_video_streams(const AVFormatContext *fmt_ctx, int decode)
{int i;// 遍歷所有視頻流for (i = 0; i < fmt_ctx->nb_streams; i++) {const AVOption *opt = NULL;const AVStream *st = fmt_ctx->streams[i];AVCodecContext *codec_ctx = st->codec;// 打印視頻流的序號和解碼標志printf("stream=%d, decode=%d\n", i, decode);// 遍歷視頻流的所有選項while (opt = av_opt_next(codec_ctx, opt)) {uint8_t *str;// 跳過常量選項if (opt->type == AV_OPT_TYPE_CONST)continue;// 跳過幀數(shù)選項if (!strcmp(opt->name, "frame_number"))continue;// 獲取選項的值并打印if (av_opt_get(codec_ctx, opt->name, 0, &str) >= 0) {printf("    %s=%s\n", opt->name, str);av_free(str);}}}
}
/*** 打開輸入文件并嘗試解碼視頻流信息** @param fmt_ctx AVFormatContext 結(jié)構(gòu)體指針的指針,用于存儲打開的輸入文件的格式上下文* @param filename 輸入文件名* @param decode 是否解碼標志,如果為 1,則進行解碼,如果為 0,則不解碼* @return 返回 0 表示成功,否則表示出錯*/
static int open_and_probe_video_streams(AVFormatContext **fmt_ctx, const char *filename, int decode)
{int ret = 0;// 打開輸入文件并讀取格式ret = avformat_open_input(fmt_ctx, filename, NULL, NULL);if (ret < 0) {av_log(NULL, AV_LOG_ERROR, "Failed to open input '%s'", filename);goto end;}// 獲取視頻流信息并嘗試解碼ret = find_video_stream_info(*fmt_ctx, decode);if (ret < 0) {goto end;}// 打印視頻流信息dump_video_streams(*fmt_ctx, decode);end:return ret;
}
/*** 檢查兩個格式上下文中的視頻流是否相同** @param fmt_ctx1 第一個輸入文件的格式上下文* @param fmt_ctx2 第二個輸入文件的格式上下文* @return 返回 0 表示視頻流相同,否則表示不同*/
static int check_video_streams(const AVFormatContext *fmt_ctx1, const AVFormatContext *fmt_ctx2)
{int i;int ret = 0;// 斷言兩個格式上下文中的視頻流數(shù)量相同av_assert0(fmt_ctx1->nb_streams == fmt_ctx2->nb_streams);// 遍歷每個視頻流for (i = 0; i < fmt_ctx1->nb_streams; i++) {const AVOption *opt = NULL;const AVStream *st1 = fmt_ctx1->streams[i];const AVStream *st2 = fmt_ctx2->streams[i];AVCodecContext *codec_ctx1 = st1->codec;AVCodecContext *codec_ctx2 = st2->codec;// 如果當前流不是視頻流,則跳過if (codec_ctx1->codec_type != AVMEDIA_TYPE_VIDEO)continue;// 遍歷視頻流的所有選項while (opt = av_opt_next(codec_ctx1, opt)) {uint8_t *str1 = NULL, *str2 = NULL;// 跳過常量選項if (opt->type == AV_OPT_TYPE_CONST)continue;// 跳過幀數(shù)選項if (!strcmp(opt->name, "frame_number"))continue;// 獲取第一個格式上下文中選項的值av_assert0(av_opt_get(codec_ctx1, opt->name, 0, &str1) >= 0);// 獲取第二個格式上下文中選項的值av_assert0(av_opt_get(codec_ctx2, opt->name, 0, &str2) >= 0);// 比較兩個值是否相同,如果不同則打印錯誤信息if (strcmp(str1, str2)) {av_log(NULL, AV_LOG_ERROR, "Field %s differs: %s %s", opt->name, str1, str2);ret = AVERROR(EINVAL);  // 設(shè)置返回值表示不同}// 釋放內(nèi)存av_free(str1);av_free(str2);}}// 返回比較結(jié)果return ret;
}
http://aloenet.com.cn/news/45329.html

相關(guān)文章:

  • 新疆所有的網(wǎng)站百度知道客服
  • 一些網(wǎng)站是用什么顏色做的怎么申請建立網(wǎng)站
  • 網(wǎng)站開發(fā)設(shè)計實訓 報告蘇州seo關(guān)鍵詞優(yōu)化方法
  • 鹽城有沒有做網(wǎng)站嗎湖南專業(yè)的關(guān)鍵詞優(yōu)化
  • 鎮(zhèn)江網(wǎng)站制作優(yōu)化老哥們給個關(guān)鍵詞
  • 怎樣做化妝品公司網(wǎng)站百度產(chǎn)品大全首頁
  • it運維工程師證書湖北seo
  • htm網(wǎng)站模板上海公司網(wǎng)站seo
  • 誰教我做啊誰會做網(wǎng)站啊整站排名服務(wù)
  • wordpress 查看訪客站長工具seo綜合查詢源碼
  • 百度云盤做網(wǎng)站空間百度上怎么打廣告宣傳
  • 紹興市中等專業(yè)學校網(wǎng)站軟文外鏈代發(fā)
  • 開發(fā)企業(yè)門戶網(wǎng)站友情鏈接賺錢
  • 中組部兩學一做網(wǎng)站如何建網(wǎng)站教程
  • 安徽 網(wǎng)站制作線上推廣平臺
  • jsp網(wǎng)站建設(shè)期末作業(yè)廣州疫情最新情況
  • 網(wǎng)站建設(shè)5000費用運營網(wǎng)站
  • 長春網(wǎng)站建設(shè) 信賴吉網(wǎng)傳媒什么是競價推廣
  • wordpress自定義主頁廣告優(yōu)化師發(fā)展前景
  • 網(wǎng)站做指向是什么意思合肥做網(wǎng)站哪家好
  • 做中學網(wǎng)站企業(yè)宣傳冊
  • 買的網(wǎng)站模板怎么做成都seo學徒
  • 網(wǎng)站建設(shè)和管理河南百度推廣代理商
  • 廣州視頻網(wǎng)站建站公司知識營銷
  • wordpress小程序教程免費網(wǎng)站seo
  • 怎么樣建立一個網(wǎng)站百度一下 你就知道首頁官網(wǎng)
  • 便宜做網(wǎng)站的公司靠譜嗎國家免費職業(yè)技能培訓官網(wǎng)
  • 怎么做網(wǎng)站賺錢的動漫網(wǎng)站b站推廣網(wǎng)站2023
  • 如何讓廣域網(wǎng)訪問利用公網(wǎng)ip和本地服務(wù)器建設(shè)的網(wǎng)站營銷app
  • 網(wǎng)站角色管理系統(tǒng)旅游seo整站優(yōu)化