【问题标题】:Write video stream from camera into file using VLC使用 VLC 将视频流从相机写入文件
【发布时间】:2020-08-13 01:50:23
【问题描述】:

我每晚都在使用 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:

 var mediaOptions = new[]
        {
            ":sout=#transcode{vcodec=h264}:std{access=file,mux=ffmpeg{mux=flv}),file{dst=" + destination + "}",
            ":sout-keep"
        };

日志截图:

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

【问题讨论】:

    标签: video vlc video-encoding libvlc


    【解决方案1】:

    对不起,我来晚了。 我遇到了同样的问题,经过长时间的研究,似乎 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}" });
    

    之后,我可以在录制的同时预览流视频。

    在此处查看文档:https://wiki.videolan.org/Documentation:Modules/display/

    问候。

    【讨论】:

      【解决方案2】:

      我将媒体选项更改为:

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

      一切正常。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-02-19
        • 1970-01-01
        • 2015-03-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多