0

Im run FFplay process in my JAVA application and read his logs with BufferedReader. I want to parse the logs to determine errors. So I want to read the color for each line. red for errors.. bufferedReader.readline() return the content, no any color code.

Please advise.

4

1 回答 1

0

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.

于 2020-05-12T09:56:01.780 回答