How to get CRF info of a video file?

4

I found this answer at StackOverflow

ffprobe -show_streams -i "file.mp4"

but as you can confirm in the comments it doesn't show the CRF value

With which tool I can get some information like GOP size?! Value for CRF and etc?!

How to find the CRF value of a video file (h264)?

Clacers

Posted 2017-11-02T16:01:42.453

Reputation: 253

Answers

6

CRF is a rate control method used by certain encoders, such as x264 and x265. They also happen to write encoding parameters into the bitstream itself. It's not part of the container metadata, so ffprobe won't show it. And it won't be present in H264/5 streams generated by other encoders.

At a higher loglevel, the H.264 decoder does display it. So, you can use

ffmpeg -i "in.mp4" -an -vframes 1 -f null - -v 48 2>&1 | grep -oE "crf=[0-9\.]+"

The HEVC decoder does not show the data. Mediainfo should show it for both codecs in detailed view.

Gyan

Posted 2017-11-02T16:01:42.453

Reputation: 21 016

Thanks for the help! 1. It says the command "grep" is invalid. 2. I can't find "CRF" or "Constant Rate Factor" within MediaInfo even if I use the search function of notepad after exporting the data to a .txt. – Clacers – 2017-11-02T17:12:55.887

Get grep from https://github.com/bmatzelle/gow/wiki. If mediainfo doesn't show it in full view, it's not there.

– Gyan – 2017-11-02T17:26:14.590

Installed, rebooted. Command is accepted but no reaction, so there's no info, I guess. Is there any way to recalculate the CRF? – Clacers – 2017-11-02T17:34:10.483

@Yethat When you run it without grep, do you see that info? If there is no CRF, it might not even have been encoded with a particular CRF value. CRF is specific to certain encoders; not all of them support it. You cannot reliably reconstruct the rate control method or encoding parameters from the bitstream, let alone the metadata. – slhck – 2017-11-02T17:42:49.387

Yes, without grep it shows the info but still without CRF. Thanks. – Clacers – 2017-11-02T18:24:37.673

@Clacers I just had the same problem and I noticed that when MediaInfo is set to "Tree", the "Encoding settings" line is cut short. The crf value is further to the right, so you have to switch the view to "Text" to be able to scroll far enough. – AndreKR – 2018-03-31T02:57:34.297