FFmpeg4.0笔记:采集系统声音

醉酒当歌 提交于 2020-04-08 06:08:14

Github

https://github.com/gongluck/FFmpeg4.0-study/tree/master/Cff

// 采集系统声音
void test_systemsound()
{
    bool ret = false;
    std::string err;
    CDemux demux;
    CDecode decode;

    ret = demux.device_register_all(err);
    TESTCHECKRET(ret);
    ret = demux.set_input_format("dshow", err); //采集声卡
    TESTCHECKRET(ret);
    ret = demux.set_dic_opt("framerate", "15", err);
    TESTCHECKRET(ret);
    ret = demux.set_demux_callback(DemuxSystemSoundCB, &decode, err);
    TESTCHECKRET(ret);
    ret = demux.set_demux_status_callback(DemuxStatusCB, &demux, err);
    TESTCHECKRET(ret);
    ret = demux.set_input("audio=virtual-audio-capturer", err);
    TESTCHECKRET(ret);
    ret = demux.openinput(err);
    TESTCHECKRET(ret);

    g_vindex = demux.get_steam_index(AVMEDIA_TYPE_VIDEO, err);
    std::cout << err << std::endl;
    g_aindex = demux.get_steam_index(AVMEDIA_TYPE_AUDIO, err);
    std::cout << err << std::endl;

    ret = decode.set_dec_callback(DecAudioFrameCB, &decode, err);
    TESTCHECKRET(ret);
    ret = decode.copy_param(demux.get_steam_par(g_aindex, err), err);
    TESTCHECKRET(ret);
    ret = decode.codec_open(err);
    TESTCHECKRET(ret);

    ret = demux.begindemux(err);
    TESTCHECKRET(ret);

    std::cout << "input to stop demuxing." << std::endl;
    std::cin.get();

    ret = demux.stopdemux(err);
    TESTCHECKRET(ret);
}
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!