使用VLC将视频流从摄像机写入文件

问题描述 投票:0回答:1

我每晚都在使用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"
        };

记录截图:enter image description here

我需要将来自摄像机的流视频编码为带有mp3或AAC音频的H.264 mp4视频文件。如果有人帮助我这个例子会很棒。

video vlc video-encoding libvlc
1个回答
0
投票

我将媒体选项更改为:

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

一切都很好。

© www.soinside.com 2019 - 2024. All rights reserved.