<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                [TOC] ### 抽取音視頻數據的步驟 ***** 從一個多媒體文件中抽取音頻數據 1.av_init_packet() -------- 初始化一個數據包結構體 --從多媒體文件中讀取的每一個數據包都可以房在這個初始化的結構體里 2.av_find_best_stream() 在多媒體文件中找到最好的一路流 3.av_read_frame() / av_packet_unref(); 將流里的數據包進行相應的處理。寫入一個文件里 unref 將包釋放掉 ### 示例代碼 ***** ``` extern "C" { #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libswscale/swscale.h" #include "libavdevice/avdevice.h" #include "libavutil/time.h" }; #include <stddef.h> #include <stdint.h> #include <tchar.h> #include <stdio.h> int main() { int ret; //返回值 調用成功與否 char *src = NULL; char* dst = NULL; //定義一個上下文 AVFormatContext* fmt_ctx = NULL; AVPacket pkt; av_log_set_level(AV_LOG_INFO); av_register_all(); //注冊所有的編解碼器 //1.read two params from console src = "./test.mp4"; dst = "./test44.mp4"; if (!src || !dst) { av_log(NULL, AV_LOG_ERROR, "Cant open file"); goto __fatl; } //打開一個多媒體文件 ret = avformat_open_input(&fmt_ctx,src, NULL, NULL); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, "cant open file"); goto __fatl; } FILE* dst_fd = fopen(dst, "wb"); if (!dst_fd) { av_log(NULL, AV_LOG_ERROR, "Cant open out file!\n"); avformat_close_input(&fmt_ctx); goto __fatl; } av_dump_format(fmt_ctx, 0, src, 0);//最后一個1代表輸出 0代表輸入 //2.get stream ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_AUDIO, -1, -1, NULL, 0); //拿到的是流的index值 if (ret < 0) { av_log(NULL,AV_LOG_ERROR, "Cant find the best stream !\n"); avformat_close_input(&fmt_ctx); fclose(dst_fd); goto __fatl; } int audio_index = ret; int len ; av_init_packet(&pkt); // 初始化包 //3.write audio data to aac file. while(av_read_frame(fmt_ctx, &pkt) >= 0) { if (pkt.stream_index == audio_index) { char adts_header_buf[7]; //adts_header(); len = fwrite(pkt.data, 1, pkt.size, dst_fd); if (len != pkt.size) { av_log(NULL, AV_LOG_WARNING, "warning, length of data not equal size of pkt!\n"); goto __fatl; } } av_packet_unref(&pkt); // 釋放包 } avformat_close_input(&fmt_ctx); //關閉輸出文件 if (dst_fd) { fclose(dst_fd); } avformat_close_input(&fmt_ctx); __fatl: system("pause"); return 0; }
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看