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

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);
}

你可能感兴趣的:(FFmpeg4.0笔记:采集系统声音)