VLC secrets: Logging and how it helps with bad files


Updated: January 12, 2013

There's a popular saying, almost an axiom, but one that is definitely provable within the limits of this universe, that if there's a file that cannot be played in VLC, it is not meant to be played. Audio or video, VLC eats them all, no matter what encoding, what format, no matter if it's a preview file downloaded in eMule or an online stream.

But what happens when VLC does not play a file? In that case, you will be left wondering what may have gone wrong, because VLC will merely shows its traffic cone logo on a black background and refuse to play. That's all. No fancy messages, no fanfare, and no Sherlock Holmes clues for you. Let's unravel a secret, shall we? Today, you will learn how to make your file playing skills that much better, in VLC.

Teaser

Logging level & debug console

Most people never burrow too deeply into the VLC interface, but the thing is, you will find a lot of useful stuff there. Among other things, if you go into the Preferences menu and toggle on the All (Advanced) button, all of the features will be revealed. The third one from the top is Logging, where you can set the name of the file where you want log messages to be written to, as well as specify the debug level.

Set logging

You can crank the numbers up for more details, as much as you please, all the way to 255, but most people will actually struggle with too much information, so it's better to start simple.

The simple way

In version 2.X of VLC, there's a simple way of getting things done. Under Tools > Messages, you can change the verbosity level, as well as point to the relevant log file. The verbosity levels are: 0 for errors, 1 for warnings, 2 for debug. This should be sufficient for most people to get going.

Error level

Debug level

Warning!

Do not look into the messages unless you have a problem, because sometimes perfectly playable files will have bad frames, junk, decoding glitches, and a whole lot of other little bugs. You might accidentally overflow your brain with useless information. For example, from my Moron.avi video:

False positives

That looks crazy. You don't want that.

Real life example

All right now, you can try to play your un-playing file, to see what gives. Once you finish clicking on the Play button in vain, open the log file and examine the contents. You will see a whole lot of stuff, and most of it completely innocent.

File does not play

Sample log file content

Is there a simple way of filtering junk? No, not really. There's no magic, but sometimes, you just might find the bits and pieces of information that may help you find the root of the problem. For example, I purposefully took a sane video file and messed up the header by opening it in a text editor and making some changes to the bytes. As expected, the file no longer plays, but when we launch it in VLC and examine the messages, we can see the end result:

Debug messages

Your next step would be to take suspicious-looking entries, like that last there, reading no stream_filter module matching "any" could be loaded, and then do some online Web search. Most of the time, you will be bombarded by useless information, but some might help. Still, do not despair and make sure to work slowly through the available flood of data.

But there's more. Let's examine what else is there in the log:

ps warning: this does not look like an MPEG PS stream, continuing anyway
ps warning: garbage at input, trying to resync...
ps warning: found sync code
ps warning: garbage at input, trying to resync...

Seems pretty self-explanatory, no? And there's this too - I want you to pay attention to the the list 'aaa' field below. It is important, and we will see what it signifies here in just a few moments.

main debug: looking for demux module: 55 candidates
avi debug: <list 'AVI '>
avi debug: <list ' aaa'>
avi warning: unknown chunk (not loaded)
avi debug: </list ' aaa'>
avi warning: unknown chunk (not loaded)
avi debug: </list 'AVI '>
avi warning: unknown chunk (not loaded)
avi debug: * LIST-root size:3338746 pos:0
avi debug:      + RIFF-AVI  size:3338744 pos:0
avi debug:      |    + LIST- aaa size:326 pos:12
avi debug:      |    |    +      size:849936385 pos:24
avi debug:      |    +      size:849936385 pos:24
avi debug:      +      size:849936385 pos:24
avi error: avi module discarded (invalid file)

On the bright side, not all errors will be this cryptic. Sometimes, the file will lack an audio stream or have an out-of-sync voice or bad frames. These discrepancies will most likely show in the log as warnings. Remember the earlier rule - if it works, let it be!

Small errors

However, if you want to explore the problem rather than discard the media file, then you will begin your research here. It won't be simple, but the best you can do is compare a good and a bad file, similar to what we did in the super debug tutorial, and look for differences.

Good file header

Bad file header

So, if we compare a good and a bad file, you will notice the differences in the headers. A healthy file has hdrlavih8, while a bad one has junk aaa written there. Remember the earlier log example. This is it! Of course, I know what change I have done and how to easily remedy it, but you might be facing a bad index, bad time stamps, invalid codecs, or other info that might be easily fixed. Somewhat like mending JPEG files in my Linux data recovery tutorial, if you're inclined to hack. Well, if you have precious, emotionally valuable music and video files that you must not lose, then you will probably attempt to fix files manually.

And some reading on just this topic:

Broken AVI file without header or index

Steps to repairs files with missing headers

Ano'er example

Now that we're past fortissimo piano of this article, let's examine another example. Here we have a file with an unknown format. It simply does not play, the reason being VLC cannot choose the correct decoder. Again, visibly, nothing happens, but the log tells us what we need to know. In most cases, you give up and this point and have a coffee break.

More broken

Please note that the string garbage at input shows here in both cases, so we're starting to pick a useful pattern. This should be your first pointer into resolving playback mystery. It also means you will most likely never succeed in getting these files to play without some serious byte-by-byte hacking. Not recommended, but then you might have a dry weekend full of pleasurable torture ahead of you.

And finally, sometimes, it will be really, really simple, because VLC may also tell you that it has encountered a problem, without burrowing into the messages console or enabling the debugging. You will actually know what is happening:

Broken index

Conclusion

Did I provide you with a silver bullet for your media? Absolutely not. Did I provide you with useful information on how to approach problems with media files in VLC? Absolutely. This short tutorial teaches you two different ways of configuring logging in VLC, both on Windows and Linux. It explains the nuances between errors, warnings and messages, shows how to differentiate between bogus and real problems, how to look for solutions, how to compare good and bad video files down to byte level, and resolving some of those seemingly impossible issues with unplayable files.

Well, I hope you find this article useful. Moreover, I hope you understand the power and flexibility of VLC a little more. So much hides under that simple, unassuming skin, it's easy to forget the awesome capabilities the program has. There you go, a VLC secret unraveled. And finally, bottom line, no matter your ability to debug media playback, most of the time, if it does not play, perhaps it was never meant to.

Cheers.

RSS Feed icon

del.icio.us del.icio.us stumbleupon stumble digg digg reddit reddit slashdot slashdot



Advertise!

Would you like to advertise your product/site on Dedoimedo?

Read more

Donate to Dedoimedo!

Do you want to
help me take early retirement? How about donating
some dinero to
Dedoimedo?

Read more

Donate