Ffmpeg and its associated tools emits color codes only when it detects that stderr goes to a terminal that supports color codes. Although this can be overridden by an environment variable, parsing arcane escape codes is not recommended.
Instead, according to the FFMpeg documentation, you may prefix the log level as a string to the output, by using a flag in the -loglevel
parameter. There are several documented flags, and the applicable one is level
.
So if you had a log level set with -loglevel info
, you can change this to -loglevel level+info
. If you didn't have a log level at all, you can use -loglevel +level
.
Now the output log messages will be prefixed with [error]
when the level is error. This works in all ffmpeg tools, including ffplay
.