FFMPEG question for you Guru's out there.

Can someone explain the the final output of FFMPEG for me?

So, here’s the story, thinking about compressing some of my full bluray rips, I have been testing the presets for x256. basically here is my general command

ffmpeg -i “M:\MyFullBlurayRip (1998).mkv” -map 0 -c copy -c:v libx265 -preset medium -crf 15 “M:\MyFullBlurayRip (1998)(PRESET)(CRF15).mkv”

which copies all streams with the exception of the video, which it encodes with -crf 15 -preset medium

My Question is really two fold

-Question 1: What does the output really mean? I have comments in “blue” below, please tell me if I am off base

-This line is just identifies output size of file +plus overhead
video:7364543kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.086215%

Identifies the number of “I-Frames” (most detail, least compression)
x265 [info]: frame I: 1968, Avg QP:13.84 kb/s: 39603.48

The number of Predictive Frames ~7:1 compression ratio, but good detail
x265 [info]: frame P: 44609, Avg QP:16.14 kb/s: 16566.52

B-Frames, best compression, worst detail
in this one, and the P and I frames… what does AVG QP mean? is lower better?
x265 [info]: frame B: 132819, Avg QP:19.52 kb/s: 4738.69

huh? not sure what this is, but it seems identical in all my runs
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.5%

I understand this next line to be the number of consecutive B-frames in a set
9.3% the number of two consecutive NON B-Frames, meaning two non b-frames together
4.6% the number of times 1 B-Frame separates two NON B-Frames
20.7% the number of times 2 B-Frame separates two NON B-Frames
43.1% the number of times 2 B-Frame separates two NON B-Frames
x265 [info]: consecutive B-frames: 9.3% 4.6% 20.7% 22.3% 43.1%
final data
encoded 179396 frames in 11786.00s (15.22 fps), 8062.30 kb/s, Avg QP:18.62
(Added for additional info - RUN TIME = 3Hours 16 Minutes, final size =8.7 GB)

-Question 2: if the above is sort of right? does the following make sense? SEEMS like “very fast” is the way to go, right?

here are my runs with the presets on top

Medium
video:7364543kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.086215%
x265 [info]: frame I: 1968, Avg QP:13.84 kb/s: 39603.48
x265 [info]: frame P: 44609, Avg QP:16.14 kb/s: 16566.52
x265 [info]: frame B: 132819, Avg QP:19.52 kb/s: 4738.69
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.5%
x265 [info]: consecutive B-frames: 9.3% 4.6% 20.7% 22.3% 43.1% lowest % of B-Frames = better quality?
encoded 179396 frames in 11786.00s (15.22 fps), 8062.30 kb/s, Avg QP:18.62
(Added for additional info - RUN TIME = 3Hours 16 Minutes, final size =8.7 GB)

Fast
video:6317377kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.097239%
x265 [info]: frame I: 2049, Avg QP:14.05 kb/s: 38388.04
x265 [info]: frame P: 36202, Avg QP:16.02 kb/s: 15914.68
x265 [info]: frame B: 141145, Avg QP:19.55 kb/s: 4150.82 but over all count of B-Frames not to different than Medium
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.6%
x265 [info]: consecutive B-frames: 6.1% 1.0% 1.2% 1.2% 90.5% greater % of 5 consecutive B-Frames
encoded 179396 frames in 6876.67s (26.09 fps), 6915.81 kb/s, Avg QP:18.78
(Added for additional info - RUN TIME = 1 Hour 54.37 Minutes, final size =7.71 GB)

faster
video:6253342kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.097989%
x265 [info]: frame I: 2049, Avg QP:14.05 kb/s: 38388.04
x265 [info]: frame P: 36202, Avg QP:16.04 kb/s: 15871.44
x265 [info]: frame B: 141145, Avg QP:19.64 kb/s: 4072.81 I P and B Frames are identical to Fast
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.6%
x265 [info]: consecutive B-frames: 6.1% 1.0% 1.2% 1.2% 90.5% 90.5% unchanged
encoded 179396 frames in 6066.13s (29.57 fps), 6845.70 kb/s, Avg QP:18.85 what is this AVG QP?
(Added for additional info - RUN TIME = 1 Hour 41.06 Minutes, final size =7.65 GB)

very fast
video:6199862kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.098622%
x265 [info]: frame I: 2049, Avg QP:14.08 kb/s: 38238.08
x265 [info]: frame P: 36202, Avg QP:16.04 kb/s: 15875.10
x265 [info]: frame B: 141145, Avg QP:19.71 kb/s: 3999.62 I P and B Frames are identical to Fast and Faster
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.6%
x265 [info]: consecutive B-frames: 6.1% 1.0% 1.2% 1.2% 90.5% 90.5% unchanged
encoded 179396 frames in 5736.64s (31.27 fps), 6787.15 kb/s, Avg QP:18.91mostly unchanged
(Added for additional info - RUN TIME = 1 Hour 35.36 Minutes, final size =7.6 GB) mostly unchanged

Super Fast - Visual quality is noticeably down
video:3302839kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.153550%
x265 [info]: frame I: 2068, Avg QP:17.75 kb/s: 24223.52 iFrames QP up and # frames up?
x265 [info]: frame P: 45058, Avg QP:18.97 kb/s: 8388.16 pFrames QP up
x265 [info]: frame B: 132270, Avg QP:22.21 kb/s: 1667.27 bFrames QP up
x265 [info]: consecutive B-frames: 5.2% 1.3% 1.2% 92.3% Significant increase
encoded 179396 frames in 3355.45s (53.46 fps), 3615.34 kb/s, Avg QP:21.35 Significant increase
(Added for additional info - RUN TIME = 55.55 Minutes, final size =4.87 GB)

UltraFast - Visual quality is noticeably down
video:2796722kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.169619%
x265 [info]: frame I: 718, Avg QP:18.10 kb/s: 19905.33 iFrames way down
x265 [info]: frame P: 45180, Avg QP:19.68 kb/s: 6856.34 pFrames QP up
x265 [info]: frame B: 133498, Avg QP:22.33 kb/s: 1686.24 bFrames QP up
x265 [info]: consecutive B-frames: 1.5% 1.6% 1.5% 95.4%
encoded 179396 frames in 2475.00s (72.48 fps), 3061.22 kb/s, Avg QP:21.65
(Added for additional info - RUN TIME = 41.15 Minutes, final size =4.37 GB)

Anyway, what data am I looking for here that will tell me if its

To understand what it’s telling you is best found in the ffmpeg documentation itself. I am not pushing you off in any way.

http://ffmpeg.org/documentation.html

What you want to know is the ‘what/how/why’ things are reporting what they are and then (when you need to read much deeper than 10 pages of thread dialog here could cover) are the actual command opens and their impact. It is a log of trial and error to learn.

Conversely, HandBrake affords you the same level of control with a GUI interface.

Sure sure, RTFM, but, The questions i asked are not in there, checked already.

We can’t teach you everything about ffmpeg. There isn’t enough time or resources here. We are volunteers. I urge you to join a forum where others can provide you with their experiences.

Sure, been looking around, that’s where I got the information i have already, but there seems to be decidedly little out there in terms of x265 compression forums…

no problem though, thought someone around these parts might know

X265 usage is not wide spread enough (yet). Even PMS has difficulty with 10 bit H.265. If PMS has trouble, that should tell you the state of the technology.

I’d try the doom9 forums. People there know have discussions that are WAY over my head about this kind of stuff.

@wesman said:
ffmpeg -i “M:\MyFullBlurayRip (1998).mkv” -map 0 -c copy -c:v libx265 -preset medium -crf 15 “M:\MyFullBlurayRip (1998)(PRESET)(CRF15).mkv”

Actually, your syntax it a little off here. Where possible, to pass arguments on to x265, you should use the -x265-params switch. Also, for ease of use, try not to use shorthand like -c:v

So your command should look something like this:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 <outputfile>

Add a couple more switches:

  • -pix_fmt yuv420p for compatability
  • -movflags faststart for moving data to the beginning of the file ready for streaming
  • -flags +global_header ensure global headers for your container
  • vbv-maxrate=10000 limit bitrate to 10Mbps
  • vbv-bufsize=20000 set buffer to 20Mb

The result should be something like:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 -pix_fmt yuv420p -movflags faststart -flags +global_header <outputfile>

This is not definitive, only an example. Ideally, where possible you should map your audio as well using -acodec etc.

@wesman said:
in this one, and the P and I frames… what does AVG QP mean? is lower better?
x265 [info]: frame B: 132819, Avg QP:19.52 kb/s: 4738.69

qp_avg is internal to the C code of the x265 library. There’s not much known about it in general use, perhaps ask a developer.

@wesman said:
Question 2: SEEMS like “very fast” is the way to go, right?

This is kind of a bad question. It’s a subjective answer. Honestly, if you want the best possible compression, then use the veryslow preset. The problem is that it will take forever to encode, and the difference in results will be negligible. You will get a slightly smaller file.

The preset, has nothing to do with the output quality, only the compression algorithms that are used to compress the file. The lower the preset (slow/veryslow etc), then the longer it takes to compress, as it uses more complex methods. The result is a marginally more compressed file.

Using a preset lower than medium is kinda overkill. I use veryslow, but even I know it’s not really worth it. I’m just bored.

@ChuckPa has a good point. This is probably not the place to be asking. What you’re looking for is very detailed information about a program that is not made by Plex, in a forum about Plex, to people who use Plex.

Dumping a lot of statistics from a program that is not part of Plex, in a forum about Plex, is probably not a good thing. The guys over at Superuser, or Doom9 would be able to answer your questions much more thoroughly.

Good luck buddy :slight_smile:

@ntrevena said:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 -pix_fmt yuv420p -movflags faststart -flags +global_header <outputfile>

So, you don’t use a preset at all? just the vbv?

@wesman said:

@ntrevena said:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 -pix_fmt yuv420p -movflags faststart -flags +global_header <outputfile>

So, you don’t use a preset at all? just the vbv?

If you don’t specify a preset, the default is medium.

:slight_smile:

@ntrevena said:

If you don’t specify a preset, the default is medium.

:slight_smile:

Of course, forgot that for a moment!

@wesman said:

@ntrevena said:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 -pix_fmt yuv420p -movflags faststart -flags +global_header <outputfile>

but why manually specify the vbv info? why not use the defaults?

@wesman said:

@ntrevena said:

If you don’t specify a preset, the default is medium.

:slight_smile:

Of course, forgot that for a moment!

@wesman said:

@ntrevena said:

ffmpeg -i <inputfile> -vcodec libx265 -x265-params vbv-maxrate=10000:vbv-bufsize=20000:crf=15 -pix_fmt yuv420p -movflags faststart -flags +global_header <outputfile>

but why manually specify the vbv info? why not use the defaults?

In case you have bandwidth issues, like streaming from an external server. It’s just allowing you more control. You can increase or decrease it based on your requirements.

I have a maximum download speed of about 2.4MBps, so have to be wary of bitrate.

I can’t put a 200Mbps file on a server somewhere, and expect it to be able to stream to my PC without a ton of buffering.

Just more ways to change your output. :slight_smile:

Also, if you don’t have bandwidth limitations, then you could easily use ultrafast as your preset.

No need to bother with compression if you have no space or bandwidth concerns :))

interestingly, if you look at the output of the runs I did above, ultrafast actually produced the smallest file. perhaps that not too surprising, considering its:

according to the FFMPAG Page, "A preset is a collection of options that will provide a certain encoding speed to compression ratio. A slower preset will provide better compression (compression is quality per filesize).

however, looking at the outputs, and files, i get the best results (bang for the buck with veryfast)… after reading this page, i did my own little experiment, compressing full videos to see what my output was. (that’s what I listed above)

@wesman said:
Medium and CRF 15
video:7364543kB audio:1787463kB subtitle:18797kB other streams:0kB global headers:1kB muxing overhead: 0.086215%
x265 [info]: frame I: 1968, Avg QP:13.84 kb/s: 39603.48
x265 [info]: frame P: 44609, Avg QP:16.14 kb/s: 16566.52
x265 [info]: frame B: 132819, Avg QP:19.52 kb/s: 4738.69
x265 [info]: Weighted P-Frames: Y:3.7% UV:2.5%
x265 [info]: consecutive B-frames: 9.3% 4.6% 20.7% 22.3% 43.1% lowest % of B-Frames = better quality?
encoded 179396 frames in 11786.00s (15.22 fps), 8062.30 kb/s, Avg QP:18.62
(Added for additional info - RUN TIME = 3Hours 16 Minutes, final size =8.7 GB)

For those who are interested, the answers are as follows.

x265 [info]: frame I: 1968, Avg QP:13.84 kb/s: 39603.48

The Avg QP is the average CRF value the algorithm used to process those frames
The same is true for the P and B Frames, you can see they are increased for those, for those frames quality does not subjectively decrease when there is a lot of motion (for example) therefore a higher QP is used to give you the same quality at greater compression.

I was right on the rest.