请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

正在回答 回答被采纳积分+3

1回答

李超 2024-03-14 15:28:14

应该是采集到数据你一直不取走,导致底层驱动的缓冲区满了

0 回复 有任何疑惑可以回复我~
  • 提问者 慕妹4365742 #1
    #include <stdio.h>
    #include <iostream>
    extern "C" {
    #include <libavutil/avutil.h>
    #include <libavdevice/avdevice.h>
    #include <libavformat/avformat.h>
    #include <libavcodec/avcodec.h>
    
    }
    #include <Windows.h>
    int main() {
        AVFormatContext* fmt_ctx = nullptr;
        const char* devicename = "audio=@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\\wave_{45047AF6-023E-47A2-A5CA-0308DA9AAAE3}";
        avdevice_register_all();
        const AVInputFormat* iformat = av_find_input_format("dshow");
        AVDictionary* options = nullptr;
        int ret = avformat_open_input(&fmt_ctx, devicename, iformat, &options);
        char errors[2024];
        if (ret < 0) {
            av_strerror(ret, errors, 1024);
        }
    
        FILE *outfile = fopen("D:\videoStudy\tryFile\try.pcm", "wb+");
    
        AVPacket pkt;
        int count = 0;
        while ((ret = av_read_frame(fmt_ctx, &pkt)) == 0 && count ++ < 400) {
            ret = av_read_frame(fmt_ctx, &pkt);
            fwrite(pkt.data, pkt.size, 1, outfile);
            fflush(outfile);
            av_packet_unref(&pkt);
        }
        
        fclose(outfile);
        avformat_close_input(&fmt_ctx);
        return 0;
    }
    我是这样写的,应该取走了吧,太长了,去掉avlog了
    回复 有任何疑惑可以回复我~ 2024-03-14 15:52:58
  • 提问者 慕妹4365742 #2
    太长了,把无关的avlog去掉了
    回复 有任何疑惑可以回复我~ 2024-03-14 15:53:28
  • 提问者 慕妹4365742 #3
    太长了,把无关的avlog去掉了
    回复 有任何疑惑可以回复我~ 2024-03-14 15:54:11
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号