0

I'm trying to parse a video with an mp4a audio track having 5.1 channels with libVLC but it always shows 2 as the number of channels


...

videoMedia = new Media(libVLC, new Uri(videoMediaFile));
videoMedia.ParsedChanged += OnVideoMediaParsedChanged;
videoMedia.Parse(MediaParseOptions.ParseNetwork);

...

private void OnVideoMediaParsedChanged(object sender, MediaParsedChangedEventArgs e)
        {
            
            foreach (var track in videoMedia.Tracks)
            {
                
                
                switch (track.TrackType)
                {
                    case TrackType.Audio:
                        Debug.WriteLine("Audio track");
                        Debug.WriteLine($"{nameof(track.Data.Audio.Channels)}: {track.Data.Audio.Channels}");
                        Debug.WriteLine($"{nameof(track.Data.Audio.Rate)}: {track.Data.Audio.Rate}");
                        Debug.WriteLine(FourCCConverter.FromFourCC(track.OriginalFourcc));

                        break;
                    case TrackType.Video:
                        Debug.WriteLine("Video track");
                        Debug.WriteLine($"{nameof(track.Data.Video.FrameRateNum)}: {track.Data.Video.FrameRateNum}");
                        Debug.WriteLine($"{nameof(track.Data.Video.FrameRateDen)}: {track.Data.Video.FrameRateDen}");
                        Debug.WriteLine($"{nameof(track.Data.Video.Height)}: {track.Data.Video.Height}");
                        Debug.WriteLine($"{nameof(track.Data.Video.Width)}: {track.Data.Video.Width}");
                        break;
                }
            }


            button1.Invoke(new Action(() =>
            {
                button1.Enabled = true;
            }));

        }


The output is:

Video track
FrameRateNum: 30000
FrameRateDen: 1001
Height: 1080
Width: 1920
Audio track
Channels: 2
Rate: 48000
mp4a

while in VLC I can see 3F2R/LFE as channels output under "codec info", so VLC is able to parse this file correctly. The same is true for other files, libVLC always shows 2 channels (may be correlated to me only having a stereo sound card?).

How do I get libVLC to give me 3F2R/LFE or something I can feed into a function like aout_FormatPrintChannels?

//edit: after about 1/3 of a second of playing the video (no matter local file or from network) I start getting the correct number (6). But that's really not good since I want to remap channels beforehand actually...

Martin Müller
  • 2,565
  • 21
  • 32
  • 1
    I had a similar problem. Some information is not correclty parsed until the video is started. In my case I gave up and acepted not having the right information. When the video actually starts then I ask for the information again. – MundoPeter Sep 18 '21 at 12:34
  • You are right... after about 1/3 of a second of playing the video (no matter local file or from network) I start getting the correct number (6). But that's really not good since I want to remap channels beforehand actually... – Martin Müller Sep 18 '21 at 17:37
  • can you share your file please? – mfkl Sep 20 '21 at 01:52

0 Answers0