使用VLC将来自相机的视频流写入文件
Write video stream from camera into file using VLC
我每晚都在使用 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 视频文件。
如果有人能帮我解决这个例子,那就太好了。
我将媒体选项更改为:
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}" });
之后,我可以在录制时预览流视频。
在此处查看文档:https://wiki.videolan.org/Documentation:Modules/display/
此致。
我每晚都在使用 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 视频文件。 如果有人能帮我解决这个例子,那就太好了。
我将媒体选项更改为:
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}" });
之后,我可以在录制时预览流视频。
在此处查看文档:https://wiki.videolan.org/Documentation:Modules/display/
此致。