Skip to content

Formt String is not working when recording with sout

Summary

I'm not able to use forma string in the sout dest file name

Minimal project and steps to reproduce

        // Load native libvlc library
        Core.Initialize();

        using (var libvlc = new LibVLC())
        using (var mediaPlayer = new MediaPlayer(libvlc))
        {
            libvlc.SetLogFile("logs.txt");
            // Redirect log output to the console
            //libvlc.Log += (sender, e) => Console.WriteLine($"[{e.Level}] {e.Module}:{e.Message}");

            // Create new media with HLS link
            var media = new Media(libvlc, "https://www.radiantmediaplayer.com/media/bbb-360p.mp4", FromType.FromLocation);

            // Define stream output options. 
            // In this case stream to a file with the given path and play locally the stream while streaming it.
            //  media.AddOption(":sout=#transcode{vcodec=h264,acodec=mpga,scale=1}:file{dst=\"" + destination + "\"}"); 
            media.AddOption(":sout=#transcode{vcodec=h264,acodec=mpga,scale=1}:file{dst=\"record-%Y-%m-%d.mp4\"}");
            media.AddOption(":sout-file-format");
            media.AddOption(":sout-keep");
            media.AddOption(":no-sout-display");
            media.AddOption(":run-time=2");

            // Start recording
            mediaPlayer.Play(media);

            Console.WriteLine($"Recording in {destination}");
            Console.WriteLine("Press any key to exit");
            Console.ReadKey();
            libvlc.CloseLogFile();
        }

    }

What is the current bug behavior?

The file is recorded with this filename record-%Y-%m-%d.mp4

What is the expected correct behavior?

The file is recorded with this filename record-2019-08-10.mp4

Relevant logs and/or screenshots

[Debug] main:VLC media player - 3.0.7.1 Vetinari [Debug] main:Copyright © 1996-2019 the VideoLAN team [Debug] main:revision 3.0.7.1-0-gf3940db4af [Debug] main:configured with ../extras/package/win32/../../../configure '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-dvdread' '--enable-shout' '--enable-goom' '--enable-caca' '--enable-qt' '--enable-skins2' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=x86_64-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' 'host_alias=x86_64-w64-mingw32' 'PKG_CONFIG_LIBDIR=/home/jenkins/workspace/vlc-release/windows/vlc-release-win32-x64/contrib/x86_64-w64-mingw32/lib/pkgconfig' [Debug] main:Creating an input for 'bbb-360p.mp4' [Debug] main:using sout chain=transcode{vcodec=h264,acodec=mpga,scale=1}:file{dst="record-%Y-%m-%d.mp4"}' [Debug] main:stream=file' [Debug] main:looking for sout stream module matching "file": zd candidates [Debug] main:set config option: sout-standard-dst to record-%Y-%m-%d.mp4 [Debug] main:looking for sout access module matching "file": zd candidates [Debug] file:file access output opened (record-%Y-%m-%d.mp4) [Debug] main:using sout access module "file" [Debug] mp4:Mp4 muxer opened [Debug] main:using sout mux module "mp4" [Debug] stream_out_standard:using file/mp4://record-%Y-%m-%d.mp4' [Debug] main:stream=transcode' [Debug] main:looking for sout stream module matching "transcode": zd candidates [Debug] main:looking for sout mux module matching "mp4": zd candidates [Debug] main:set config option: sout-transcode-acodec to mpga [Debug] main:set config option: sout-transcode-scale to 1

Environment

  • OS: Windows
  • Version 10
  • Device: PC
  • LibVLC version and architecture 3.0.7.1, x64
  • LibVLCSharp version 3.1.1 .Net Core

Possible fixes

--

Edited by Sergio Capozzi
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information