Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 2nd March 2019, 00:33   #1  |  Link
Digeridoo
Registered User
 
Join Date: Feb 2019
Posts: 3
Need help to compress action cam footage with constant fast motion

Hi. I need help with compression of action cam footage with riding a bicycle. It was shooted at ultra-wide angle with a lot of grass and road grain. 95% of footage is constant fast motion.

Source: MP4 1080p@50 High@4.2 VBR at 47 Mbit/s, without B frames.
Target: The same as source + quality as close to the source as possible with the same bitrate (+-5%).

I have made some tests exporting video from Adobe Premiere:
1. Using ffmpeg and x264 with CRF 22 and default settings gives me avg bitrate 47 Mbit/s, which is the same as source. Probably, there is no visual loose of the quality when watching a video. However, in comparison on frame by frame, some details has been changed (a lot of single pixels or small areas/blocks). Encoding using CRF 17-18 does not have visible changes on frames, but avg bitrate raised up to 75 Mbit/s, which is more than 50% higher than the source.
3. Using slower presets increases the avg bitrate in comparison to the default (medium) preset.
4. Using tune film increases bitrate up to 1%, while using tune grain - up to 50%.
5. Encoder does not use more then 4-5 consecutive B frames and more than 4-5 ref frames. Usually, 85- 95% of ref frames used only by first two positions.
6. Using CRF 19 without B frames gives me bitrate about 49 Mbit/s, which is close to the source/target.

As a summary of a lot of different tests (some of them here - http://grabilla.com/09301-8095f7a6-2...39f5935a59.png)
1. Best match is: crf=19 / tune=film / bframes=0 / ref=4 / rc-lookahead=50 / me=umh / merange=24 / subme=9
2. Disabling B frames allows me to lower CRF from 22 to 19 and get better avg QP for I/P frames within target avg bitrate.

With Adobe Premiere and used exporter, I am limited to use some features like: CRF and 2 pass, output of SSIM/PSNR metrics in log file. So, I can compare results only visually in motion (useless at high bitrate) or frame by frame (useless at some point - I can’t encode with 2 pass) or by statistics in log file like Avg QP of frames.

As a newbe not only for x264, but also for encoding in general, I have a lot of questions to ensure that I am on the right way.
1. Disabling B frames is a common practice to preserve the quality (visually lossless)? What would you suggest in my case?
2. With which other options/values/combinations I can play to rich, probably, better results of quality or compression? Should I try trellis=2, --no-dct-decimate, --no-fast-pskip? Would it be useful for CRF one pass encode?
3. Should I exclude b8x8 from partitions? Or there is no correlations and b8x8 can be used/useful without B frames?
4. Which GOP structure will be more suitable for video without B frames and with constant fast motion? Fixed or Adaptive (with scene detection), long (5-10+ sec) or short (1-2 sec)?
5. For cross fades I usually use "Cross Dissolve transition" effect. Sometimes, scene detection do not recognize such cross fades as scene change and do not insert IDR/I frame - http://grabilla.com/09301-6827e343-7...68de23a2a4.png. Is it OK?
6. CRF 19 gives me avg QP 23 and 25,8 for I and P frames respectively. Is that more or less normal values? As I understand bigger values means worse quality and compression (hard to compress). Which other metrics from ffmpeg’s statistics in log can be useful to compare the quality/compression?
7. Using VBV is a good practice or it should be avoided until there is strong reason to use it?
Digeridoo is offline   Reply With Quote
Old 4th March 2019, 14:40   #2  |  Link
excellentswordfight
Lost my old account :(
 
Join Date: Jul 2017
Posts: 325
First of all, if you wanna compare the quality between different settings and already have a bitrate target dont use CRF. Use 2pass with an target bitrate and do visuall comparisons, looking at avg QP might not tell the whole picture. When you are happy with the settings then start using crf do dail in a value were you are either happy with the quality or hit your target bitrate.

Imo most of the time x264 does a a fair job of handling b-frame and I-frame placement to achive the best overall quality, so I would at least use "normal" settings for those so you have a baseline to comare against (maybe something like --keyint 500 --min-keyint 50 -rc-lookahead 50 -ref 4 -bframes 4 for 50p material). Using preset slower and trying tune film on and off is a good start to get a baseline that you can compare against.

Last edited by excellentswordfight; 4th March 2019 at 14:43.
excellentswordfight is offline   Reply With Quote
Old 4th March 2019, 20:42   #3  |  Link
Digeridoo
Registered User
 
Join Date: Feb 2019
Posts: 3
In general I agree. However, at high bitrate this particular source compressed better without B frames and all metrics said that it is true.

Encode at CRF 21 with B frames (51,7 Mbit/s):
Code:
frame=205 QP=29.77 NAL=0 Slice:B Poc:408 I:1004 P:4458 SKIP:1630 size=115146 bytes
frame=206 QP=29.83 NAL=0 Slice:B Poc:410 I:1260 P:3791 SKIP:1705 size=152728 bytes
frame=207 QP=27.21 NAL=2 Slice:P Poc:422 I:4511 P:3291 SKIP:358  size=231672 bytes
frame=212 QP=27.19 NAL=2 Slice:P Poc:430 I:4269 P:3508 SKIP:383  size=231538 bytes
Encode at CRF 19 without B frames (49,7 Mbit/s):
Code:
frame=205 QP=26.00 NAL=2 Slice:P Poc:410 I:1630 P:5691 SKIP:839  size=131717 bytes
frame=206 QP=26.02 NAL=2 Slice:P Poc:412 I:1635 P:5614 SKIP:911  size=131904 bytes
frame=207 QP=26.05 NAL=2 Slice:P Poc:414 I:1665 P:5703 SKIP:792  size=131234 bytes
frame=212 QP=25.65 NAL=2 Slice:P Poc:424 I:1909 P:5184 SKIP:1067 size=126652 bytes
P frames of encode without B frames have lower QP and size, they use less macroblocks of type I, but more of type P. Even P frame, sometimes, less in size then B frame Comparing frame by frame (P-B, P-P) using imagemagick best SSIM/PSNR (visually too) on frames of encode without B frames in spite of smaller size of frames. B frames encode spent bits for whatever, but not for quality. Maybe it can’t find direction of motion (too noisy/grainy/fast), or I used improper settings or some magic… Or simply I am wrong on reading and understanding metrics.

So I need advise on how encode in general and without B frames properly (questions 2,3,4,5,7 above).

And again:
1. I am limited with some options by used exporter in Adobe Premiere. It don’t allow me to use CRF + 2 pass. However, I can try to encode sample file using ffmpeg directly, without Premiere. I will try it to compare different setting. But final encode must be in Adobe Premiere.
2. Compression is not my goal. My goal is preserve quality/details as much as possible, but at reasonable bitrate, which should be around bitrate of the source.
Digeridoo is offline   Reply With Quote
Old 18th March 2019, 11:52   #4  |  Link
Digeridoo
Registered User
 
Join Date: Feb 2019
Posts: 3
Please close the thread. I have found the answers.
Digeridoo is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:09.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.