Reputation: 358
I'm using VLC wrapper VLC.DotNet, libvlc 3.0.3 or 3.0.4 nightly and I try example:
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();
}
}
Everything works great I see recorded file in folder, but when I change media options format, file not recording... F.E:
var mediaOptions = new[]
{
":sout=#transcode{vcodec=h264}:std{access=file,mux=ffmpeg{mux=flv}),file{dst=" + destination + "}",
":sout-keep"
};
I need to encode streaming video from camera into H.264 mp4 video file with mp3 or AAC audio. It would be great if anyone help me with this example.
Upvotes: 0
Views: 1001
Reputation: 11
Sorry, I'm very late. I was facing the same issue, after a long long research, it seems VLC subcommands work by using '', so I resolved this issue like this:
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}" });
After that, I could preview stream video while recording.
See the documentation here: https://wiki.videolan.org/Documentation:Modules/display/
Regards.
Upvotes: 1
Reputation: 358
I changed my media options to:
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"
};
And everything works good.
Upvotes: 0