Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Video 使用VLC将摄像机中的视频流写入文件_Video_Vlc_Video Encoding_Libvlc - Fatal编程技术网

Video 使用VLC将摄像机中的视频流写入文件

Video 使用VLC将摄像机中的视频流写入文件,video,vlc,video-encoding,libvlc,Video,Vlc,Video Encoding,Libvlc,我每晚都在使用VLC包装器VLC.DotNet、libvlc 3.0.3或3.0.4,我尝试以下示例: static void Main(string[] args) { var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); // Default installation path of VideoLAN.LibVLC.Windows

我每晚都在使用VLC包装器VLC.DotNet、libvlc 3.0.3或3.0.4,我尝试以下示例:

 static void Main(string[] args)
    {
        var currentDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
        // Default installation path of VideoLAN.LibVLC.Windows
        var libDirectory =
            new DirectoryInfo(Path.Combine(currentDirectory, "libvlc", IntPtr.Size == 4 ? "win-x86" : "win-x64"));

        var destination = Path.Combine(currentDirectory, "record.mp4");

        using (var mediaPlayer = new Vlc.DotNet.Core.VlcMediaPlayer(libDirectory))
        {

            var mediaOptions = new[]
            {
                ":sout=file{dst=" + destination + "}",
                ":sout-keep"
            };

            mediaPlayer.SetMedia(new Uri("rtsp://192.168.x.xxx/ch1.h264"),
                mediaOptions);

            mediaPlayer.Play();

            Console.WriteLine($"Recording in {destination}");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
        }
    }
一切都很好,我在文件夹中看到录制的文件,但当我更改媒体选项格式时,文件无法录制。。。 F.E:

日志截图:

我需要将摄像头中的流式视频编码为带有mp3或AAC音频的H.264 mp4视频文件。
如果有人能帮我举个例子,那就太好了。

我将媒体选项更改为:

var lowQualityMediaOptions = new[]
        {
            ":sout=#transcode{vcodec=h264,width=640,height=480,canvas-width=640,canvas-height=480,fps=4}:std{access=file,mux=ts,dst=" + lowQualityDestination + "}",
            ":sout-all"
        };
一切都很好。

对不起,我迟到了。 我也面临同样的问题,经过长时间的研究,似乎VLC子命令是通过使用来工作的,所以我这样解决了这个问题:

vlcControl1.SetMedia(new Uri(YourUrl), new string[] { ":sout=#duplicate{dst='transcode{vcodec=h264,width=640,height=480,fps=20}:std{access=file,mux=ts,dst=YourDestinationPath}',dst=display}" });
之后,我可以在录制时预览流视频

请参阅此处的文档:

问候

vlcControl1.SetMedia(new Uri(YourUrl), new string[] { ":sout=#duplicate{dst='transcode{vcodec=h264,width=640,height=480,fps=20}:std{access=file,mux=ts,dst=YourDestinationPath}',dst=display}" });