调用LIBVLC播放串流只有声音没有图像

chzuping 2012-12-25 01:20:14
前提:
1.使用vlc打开 test.mp4可以播放。
2.使用我的MFC窗口程序打开test.mp4也可以播放。

1.首先使用以下命令产生串流:
C:\Program Files\VideoLAN\VLC>vlc.exe test.mp4 -vvv --loop --sout "#rtp{sdp=rts
p://127.0.0.1:10086/stream}"

2.使用vlc打开rtsp://127.0.0.1:10086/stream可以播放
3.在MFC窗口程序中使用以下代码播放,可是只有声音没有图像:

pMedia_ = libvlc_media_new_path(pVLCInstance_, "rtsp://127.0.0.1:10086/stream");
pMediaPlayer_ = libvlc_media_player_new_from_media (pMedia_);
libvlc_media_player_set_hwnd (pMediaPlayer_, hwnd);
libvlc_media_player_play (pMediaPlayer_);


怎么回事呢?请各位指点!
...全文
1219 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
//创建初始化播放器资源 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] extern public static IntPtr libvlc_new(int argc, IntPtr argv); //创建播放器实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_new(IntPtr libvlc_instance); // 释放libvlc实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_release(IntPtr libvlc_instance); //获取库版本信息 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern String libvlc_get_version(); // 从视频来源(例如Url)构建一个libvlc_meida RTSP [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_location(IntPtr libvlc_instance, IntPtr path); // 从本地文件路径构建一个libvlc_media rtsp串流不适合调用此接口 // [MarshalAs(UnmanagedType.LPStr)] string path [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_path(IntPtr libvlc_instance, IntPtr path); /// /// 影片长度 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_get_length(IntPtr libvlc_media_player); //释放对象 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_release(IntPtr libvlc_media_inst); // 将视频(libvlc_media)绑定到播放器上 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_set_media(IntPtr libvlc_media_player, IntPtr libvlc_media); //创建(libvlc_media)播放窗口 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] publ
//创建初始化播放器资源 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] extern public static IntPtr libvlc_new(int argc, IntPtr argv); //创建播放器实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_new(IntPtr libvlc_instance); // 释放libvlc实例 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_release(IntPtr libvlc_instance); //获取库版本信息 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern String libvlc_get_version(); // 从视频来源(例如Url)构建一个libvlc_meida RTSP [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_location(IntPtr libvlc_instance, IntPtr path); // 从本地文件路径构建一个libvlc_media rtsp串流不适合调用此接口 // [MarshalAs(UnmanagedType.LPStr)] string path [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_new_path(IntPtr libvlc_instance, IntPtr path); /// /// 影片长度 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern IntPtr libvlc_media_player_get_length(IntPtr libvlc_media_player); //释放对象 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_release(IntPtr libvlc_media_inst); // 将视频(libvlc_media)绑定到播放器上 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_set_media(IntPtr libvlc_media_player, IntPtr libvlc_media); //创建(libvlc_media)播放窗口 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_new_from_media(IntPtr libvlc_media_player); // 设置图像输出的窗口 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_set_hwnd(IntPtr libvlc_mediaplayer, Int32 drawable); //播放 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_play(IntPtr libvlc_mediaplayer); //暂停 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_pause(IntPtr libvlc_mediaplayer); //停止 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_stop(IntPtr libvlc_mediaplayer); // 解析视频资源的媒体信息(如时长等) [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_parse(IntPtr libvlc_media); // 返回视频的时长(必须先调用libvlc_media_parse之后,该函数才会生效) [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern Int64 libvlc_media_get_duration(IntPtr libvlc_media); // 当前播放的时间 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern Int64 libvlc_media_player_get_time(IntPtr libvlc_mediaplayer); // 设置播放位置(拖动) [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_set_time(IntPtr libvlc_mediaplayer, Int64 time); /// /// 抓图 /// /// /// 经典0 /// 完整路径,文件名英文或下划线开头 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern int libvlc_video_take_snapshot(IntPtr libvlc_mediaplayer, uint num, IntPtr filePath, uint i_width, uint i_height); //media player release [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_media_player_release(IntPtr libvlc_mediaplayer); // 获取音量 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern int libvlc_audio_get_volume(IntPtr libvlc_media_player); //设置音量 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_audio_set_volume(IntPtr libvlc_media_player, int volume); // 设置全屏 [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern void libvlc_set_fullscreen(IntPtr libvlc_media_player, int isFullScreen); /// ///判断是否可以录像 /// /// /// //Can the media player record the current media? [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern bool libvlc_media_player_is_recordable(IntPtr libvlc_media_player); /// ///判断是否在录像 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern bool libvlc_media_player_is_recording(IntPtr libvlc_media_player); /// /// 录像开始 /// /// /// 保存路径+文件名(d:\\record (将在D盘根目录保存为record.mp4)) /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern int libvlc_media_player_record_start(IntPtr libvlc_media_player, IntPtr psz_PathFilename); /// /// 录像停止 /// /// /// [DllImport("libvlc", CallingConvention = CallingConvention.Cdecl)] public static extern int libvlc_media_player_record_stop(IntPtr libvlc_media_player);

2,542

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧