一直在文档中找不到,接口设计的也不大好。不过终于在*上找到解决方案了。
原来在LIbVLC库实例化的时候就需要传递相关的参数。我的代码大致是这样实现:
const char * vlc_args[] =
{
"--sout="
}; if ((m_vlcInsatnce = libvlc_new(sizeof(vlc_args)/sizeof(vlc_args[]), vlc_args)) == NULL)
{
std::cerr << "Could not init VLC" << std::endl;
exit();
} //开始录制转换
QString sout = "#transcode{vcodec=mp4v,acodec=mpga,vb=800,ab=128,deinterlace}:duplicate{dst=file{dst=" + m_recordFile + "}}"; libvlc_vlm_add_broadcast(m_vlcInsatnce, media_name, m_url.toStdString().c_str(), sout.toStdString().c_str(), , NULL, true, true);
libvlc_vlm_play_media(m_vlcInsatnce, media_name); //这里可以加入一些时间,录制时间
//停止录制
libvlc_vlm_stop_media(m_vlcInsatnce, media_name);
libvlc_vlm_del_media(m_vlcInsatnce, media_name); libvlc_vlm_release(m_vlcInsatnce);
详情可以参考我的Github上一个媒体播放器的代码:
https://github.com/AlexiaChen/MediaPlayer
references:
http://*.com/questions/16515099/saving-a-stream-while-playing-it-using-libvlc
http://*.com/questions/26464138/how-to-stream-raw-data-from-memory-using-libvlc-and-visual-studio-2008?rq=1
http://blog.csdn.net/xuplus/article/details/34081989