使用VLC点网库在单击按钮时开始记录流 [英] start recording stream on button click with VLC dot net library

查看:78
本文介绍了使用VLC点网库在单击按钮时开始记录流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个win表单应用程序,可以从ip摄像机流式传输视频...
i使用已经可用的lib。
lib网站
VideoLan DotNet for WinForm,WPF和; Silverlight 5

i have got a win form application that stream video from a ip camera... i use a lib that is already avaliable.. lib site VideoLan DotNet for WinForm, WPF & Silverlight 5

为了播放视频我这样做:

in order to stram the video i do this:

string path = "rtsp://****:****@192.168.5.223/profile2/media.smp";
LocationMedia media = new LocationMedia(path);
vlcControl1.Media = media;
vlcControl1.Play();

我现在想要的是通过单击按钮将流保存到文件中,我的意思是,视频正在播放,然后按按钮录制视频...

what i want now is to save the stream to a file on a button click, i mean , the video is playing, and then i press the button to record the video...

我该怎么办?

开始播放视频时,我可以保存此文件。

when starting the video i can do this to save..

 string path = ....
 LocationMedia media = new LocationMedia(path);        media.AddOption(":sout=#transcode{vcodec=theo,vb=800,scale=1,acodec=flac,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ogg,dst=C:\\Users\\hsilva\\Desktop\\123.mp4}");
 vlcControl1.Media = media;
 vlcControl1.Play();

所以如果视频已经在播放,如何添加选项...

so how can i add option if the video is already playing...

推荐答案

请参见: https://mykb.cipindanci.com/archive/SuperKB/4164/
用于RTSP实时流式传输,只需执行以下操作:

see there: https://mykb.cipindanci.com/archive/SuperKB/4164/ for RTSP live streaming, just do it like below:

IntPtr p_md = LibVlcAPI.libvlc_media_player_get_media(this.libvlc_media_player_);
LibVlcAPI.libvlc_media_add_option(p_md, pMrl);
LibVlcAPI.libvlc_media_player_set_media(libvlc_media_player_, p_md);
LibVlcAPI.libvlc_media_player_play(libvlc_media_player_);

,并在下面致电以停止记录:

and call below to stop recording:

IntPtr p_md = LibVlcAPI.libvlc_media_player_get_media(this.libvlc_media_player_);
LibVlcAPI.libvlc_media_player_set_media(libvlc_media_player_, p_md);
LibVlcAPI.libvlc_media_player_play(libvlc_media_player_);

该链接演示了两个功能:

also that link demo two function:

LibVlcAPI.libvlc_media_player_recorder_start(this.libvlc_media_player_, pMrl);
IntPtr pMrl = IntPtr.Zero;
byte[] bytes = Encoding.UTF8.GetBytes(FILE_PATH);
pMrl = Marshal.AllocHGlobal(bytes.Length + 1);
Marshal.Copy(bytes, 0, pMrl, bytes.Length);
Marshal.WriteByte(pMrl, bytes.Length, 0);
return LibVlcAPI.libvlc_media_player_recorder_start(this.libvlc_media_player_, pMrl);

停止记录:

return LibVlcAPI.libvlc_media_player_recorder_stop(this.libvlc_media_player_);

libvlc_media_player_recorder_stop& libvlc_media_player_recorder_start仅在VLC x86库中可用,不适用于x64 dll。

libvlc_media_player_recorder_stop & libvlc_media_player_recorder_start only available in VLC x86 libs, not avaiable for x64 dlls.

但是对于文件播放,您必须像BitMask777那样执行。

but for file playing, you had to do it like BitMask777.

这篇关于使用VLC点网库在单击按钮时开始记录流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆