Ref frames 4 or 5?

HandBrake for Windows support
Forum rules
An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.
Post Reply
Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Ref frames 4 or 5?

Post by Vsevolod »

Hello! Handbrake 1.3.1

When I set in the advanced settings: ref = 5: bframes = 5, then upon completion I get ref = 4. Why?
Windows 10

https://i.ibb.co/C0cMY7H/y80-W8j1btig.jpg
https://i.ibb.co/QCnP9RC/p6k1-TZ8vww-Q.jpg

User avatar
Rodeo
HandBrake Team
Posts: 12400
Joined: Tue Mar 03, 2009 8:55 pm

Re: Ref frames 4 or 5?

Post by Rodeo »

Encoder level and resolution. 1920x1080 at level 4.1 has a maximum of 4 refs, else the bitstream is invalid. At 1920x800 (which you would get for 2.40:1 content) you'll get 5 refs because the lower resolution allows for it.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Thank you very much for the answer! I am coding for Smart TV. Please tell me the most suitable CRF for most devices? I use 18 for the best quality.

User avatar
Rodeo
HandBrake Team
Posts: 12400
Joined: Tue Mar 03, 2009 8:55 pm

Re: Ref frames 4 or 5?

Post by Rodeo »

Only you can decide, really. Most people are content with 22 to 20, some people feel like they need to go as low as 17 or 16. You'd have to try a few test chapters and look at the output on your TV.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Thanks a lot! Is this correct when, with a single CRF of 18, the result is a different bit rate in each video?

User avatar
Rodeo
HandBrake Team
Posts: 12400
Joined: Tue Mar 03, 2009 8:55 pm

Re: Ref frames 4 or 5?

Post by Rodeo »

Yes.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Thanks again Rodeo! I have been looking for how to encode my author movie for Smart TV, Youtube and Vimeo! I think I found what I was looking for. I really like Handbrake!

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Hello again! I managed to watch my movie on Sony Smart TV. I created several versions with different RF values ​​(16, 18, 20, 22). With a value of 16 (it turned out 25.7 Mb / s) the best quality! It seems to me that raising higher than 35 Mb / s for FullHD makes no sense. Although, I could be wrong.

I noticed several problems after coding in HandBrake 1.3.1:

1) Sometimes I see artifacts (as if floating pixels) on the screen. Here's what it looks like:

https://youtu.be/GYxOZIjUonU

2) Sometimes flickering occurs between frames. Especially from night to day and vice versa. I disabled all filters in Handbrake. Interlace Detection - Off. Deinterlace - Off. I shot a progressive video. But maybe I still need to turn it on?

3) Sometimes the video seems to be accelerated, although the frame rate is 24fps.

General basic settings:
Format: Mp4
Align A / V Start - On
All filters: OFF
Video codec: H264 (x264)
CRF: 16, 18, 20 22
Framerate: Same as source (24ps)
Constant framerate
Encoder tune: film
Encoder profile: Very slow
Encoder level: 4.1
Advanced Options: ref = 5; (but for 1920x1080 = 4) bframes = 5

All these problems are absent when viewed on a computer (MPC, VLC, KMPlayer, GOM, Potplayer). Help solve the problems. Thanks!

mduell
Veteran User
Posts: 6933
Joined: Sat Apr 21, 2007 8:54 pm

Re: Ref frames 4 or 5?

Post by mduell »

An Activity Log is required for support requests. Please read How-to get an activity log? for details on how and why this should be provided.

User avatar
JohnAStebbins
HandBrake Team
Posts: 5535
Joined: Sat Feb 09, 2008 7:21 pm

Re: Ref frames 4 or 5?

Post by JohnAStebbins »

3) Sometimes the video seems to be accelerated, although the frame rate is 24fps.
Are you playing the video over the network, or does this occur when playing back from direct attached storage? Is the audio in sync when this happens? Does the audio sound higher pitched when this happens?

As mduell points out, we need to see a log to see exactly what settings you used and whether there were any errors during the encoding process.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Here is Activity log:

Code: Select all

HandBrake 1.3.1 (2020010400)
OS: Microsoft Windows NT 10.0.14393.0
CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
Ram: 32709 MB, 
GPU Information:
  NVIDIA GeForce GTX 770 - 25.21.14.1935
Screen: 1920x1080
Temp Dir: C:\Users\Vsevolod-PC\AppData\Local\Temp\
Install Dir: F:\Program Files\HandBrake
Data Dir: C:\Users\Vsevolod-PC\AppData\Roaming\HandBrake

-------------------------------------------


# Starting Encode ...

[07:12:00] base preset: Bluray x264 CRF 18 (Modified)
[19:12:00] hb_init: starting libhb thread
[19:12:00] Starting work at: Fri Mar 13 19:12:00 2020
[19:12:00] 1 job(s) to process
[19:12:00] json job:
{
  "Audio": {
    "AudioList": [],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [],
    "ChapterMarkers": false,
    "AlignAVStart": true,
    "File": "E:\\Renders\\Memory Zone 5TH20.m4v",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": false
    },
    "Mux": "mp4"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 12,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "1080",
          "width": "1920"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "1"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {},
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 1
    },
    "Title": 1,
    "Path": "I:\\Memory Zone\\Master\\DNxHD\\Memory Zone 5TH.mxf"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "x264",
    "Level": "4.1",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "ref=5:bframes=5",
    "Preset": "veryslow",
    "Profile": "high",
    "Quality": 20.0,
    "Tune": "film",
    "QSV": {
      "Decode": false,
      "AsyncDepth": 0
    }
  }
}
[19:12:00] CPU: Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz
[19:12:00]  - Intel microarchitecture Haswell
[19:12:00]  - logical processor count: 8
[19:12:00] Intel Quick Sync Video support: no
[19:12:00] hb_scan: path=I:\Memory Zone\Master\DNxHD\Memory Zone 5TH.mxf, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:323: failed opening UDF image I:\Memory Zone\Master\DNxHD\Memory Zone 5TH.mxf
src/libbluray/disc/disc.c:424: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:424: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2585: nav_get_title_list(I:\Memory Zone\Master\DNxHD\Memory Zone 5TH.mxf\) failed
[19:12:00] bd: not a bd - trying as a stream/file instead
libdvdnav: Using dvdnav version 6.0.1
libdvdread: Encrypted DVD support unavailable.
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread:DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.BUP failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: failed to read VIDEO_TS.IFO
[19:12:00] dvd: not a dvd - trying as a stream/file instead
Input #0, mxf, from 'I:\Memory Zone\Master\DNxHD\Memory Zone 5TH.mxf':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010100
    uid             : dad20c39-57b4-11ea-8f0b-7824af33727d
    generation_uid  : dad20c3a-57b4-11ea-8700-7824af33727d
    company_name    : Adobe Systems Incorporated
    product_name    : Premiere Pro
    product_version : 10.4.0
    application_platform: win32
    product_uid     : 0c3919fe-46e8-11e5-a151-feff819cdc9f
    modification_date: 2020-02-25T09:54:46.512000Z
    material_package_umid: 0x060A2B340101010501010D1113000000A3882002048905A081347824AF33727D
    timecode        : 00:00:00:00
  Duration: 00:06:47.92, start: 0.000000, bitrate: 179307 kb/s
    Stream #0:0: Video: dnxhd (DNXHD), yuv422p10le(bt709/unknown/unknown, progressive), 1920x1080, SAR 1:1 DAR 16:9, 24 fps, 24 tbr, 24 tbn, 24 tbc
    Metadata:
      file_package_umid: 0x060A2B34010101050101051213E36578A2882002048905A0380C7824AF33727D
      file_package_name: Source Package
      track_name      : Track 1
[19:12:00] scan: decoding previews for title 1
[19:12:01] scan: 10 previews, 1920x1080, 24.000 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1
[19:12:01] libhb: scan thread found 1 valid title(s)
[19:12:01] Starting Task: Encoding Pass
[19:12:01] Skipping crop/scale filter
[19:12:01] job configuration:
[19:12:01]  * source
[19:12:01]    + I:\Memory Zone\Master\DNxHD\Memory Zone 5TH.mxf
[19:12:01]    + title 1, chapter(s) 1 to 1
[19:12:01]    + container: mxf
[19:12:01]    + data rate: 179307 kbps
[19:12:01]  * destination
[19:12:01]    + E:\Renders\Memory Zone 5TH20.m4v
[19:12:01]    + container: MPEG-4 (libavformat)
[19:12:01]      + align initial A/V stream timestamps
[19:12:01]  * video track
[19:12:01]    + decoder: dnxhd
[19:12:01]    + filter
[19:12:01]      + Framerate Shaper (mode=1)
[19:12:01]        + frame rate: 24.000 fps -> constant 24.000 fps
[19:12:01]    + Output geometry
[19:12:01]      + storage dimensions: 1920 x 1080
[19:12:01]      + pixel aspect ratio: 1 : 1
[19:12:01]      + display dimensions: 1920 x 1080
[19:12:01]    + encoder: H.264 (libx264)
[19:12:01]      + preset:  veryslow
[19:12:01]      + tune:    film
[19:12:01]      + options: ref=5:bframes=5
[19:12:01]      + profile: high
[19:12:01]      + level:   4.1
[19:12:01]      + quality: 20.00 (RF)
[19:12:01]      + color profile: 1-1-1
[19:12:01] sync: expecting 9790 video frames
[19:12:01] encx264: min-keyint: 24, keyint: 240
[19:12:01] encx264: encoding at constant RF 20.000000
[19:12:01] encx264: unparsed options: ref=4:bframes=5:level=4.1:b-adapt=2:direct=auto:deblock=-1,-1:analyse=all:me=umh:merange=24:subme=10:trellis=2:psy-rd=1,0.15:vbv-bufsize=78125:vbv-maxrate=62500:rc-lookahead=60
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x264 [info]: profile High, level 4.1, 4:2:0, 8-bit
[19:12:01] sync: first pts video is 0
[19:12:01] sync: Chapter 1 at frame 1 time 0
[19:38:03] reader: done. 1 scr changes
[19:38:06] work: average encoding speed for job is 6.235195 fps
[19:38:07] vfr: 9790 frames output, 0 dropped and 0 duped for CFR/PFR
[19:38:07] vfr: lost time: 0 (0 frames)
[19:38:07] vfr: gained time: 0 (0 frames) (0 not accounted for)
[19:38:07] dnxhd-decoder done: 9790 frames, 0 decoder errors
[19:38:07] sync: got 9790 frames, 9790 expected
[19:38:07] sync: framerate min 24.000 fps, max 24.000 fps, avg 24.000 fps
x264 [info]: frame I:90    Avg QP:16.81  size:349255
x264 [info]: frame P:2567  Avg QP:21.19  size:145937
x264 [info]: frame B:7133  Avg QP:23.23  size: 76751
x264 [info]: consecutive B-frames:  5.3%  4.9%  8.8% 25.7% 24.2% 31.1%
x264 [info]: mb I  I16..4: 19.1% 60.1% 20.9%
x264 [info]: mb P  I16..4:  4.0% 21.2%  3.9%  P16..4: 30.9% 14.9%  9.6%  1.2%  0.3%    skip:14.0%
x264 [info]: mb B  I16..4:  0.2%  6.0%  1.2%  B16..8: 34.6% 10.7%  3.7%  direct:10.1%  skip:33.4%  L0:42.5% L1:39.3% BI:18.1%
x264 [info]: 8x8 transform intra:75.1% inter:59.6%
x264 [info]: direct mvs  spatial:99.7% temporal:0.3%
x264 [info]: coded y,uvDC,uvAC intra: 86.0% 54.9% 19.0% inter: 40.6% 18.5% 1.2%
x264 [info]: i16 v,h,dc,p: 41% 21% 11% 27%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  8% 10% 13%  9% 13% 10% 14%  9% 14%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  6% 13%  3%  8% 13% 10% 17% 10% 19%
x264 [info]: i8c dc,h,v,p: 37% 37% 14% 12%
x264 [info]: Weighted P-Frames: Y:15.5% UV:10.4%
x264 [info]: ref P L0: 52.7% 14.4% 20.4% 10.7%  1.7%  0.0%
x264 [info]: ref B L0: 85.3% 11.8%  2.9%
x264 [info]: ref B L1: 95.4%  4.6%
x264 [info]: kb/s:18700.29
[19:38:07] mux: track 0, 9790 frames, 953516304 bytes, 18698.31 kbps, fifo 1024
[19:38:07] Finished work at: Fri Mar 13 19:38:07 2020
[19:38:07] libhb: work result = 0

# Encode Completed ...

Are you playing the video over the network, or does this occur when playing back from direct attached storage? Is the audio in sync when this happens? Does the audio sound higher pitched when this happens?

As mduell points out, we need to see a log to see exactly what settings you used and whether there were any errors during the encoding process.
I turned on directly through the Seagate Portable 500gb external hard drive. The format is MKV. I created it in MKVToolnix. First, I did the encoding in HandBrake - then MKVToolnix - in the same place I added some audio tracks to my movie (ac3, eac3, dts hd ma, aac).

I did not notice that the sound is not synchronized. The only thing is there are floating pixels and flicker at the beginning of some frames. But on the PC, everything is fine. Maybe I need to enable deblocking and deinterlace?

I also noticed that downmix does not work on the 5.1 audio track. The clarity of the dialogue is lost, the music rises. Everything is very crumpled. When I switched to ac3 2.0, having previously done downmix with Halo Downmix in 2.0. then everything was fine. But this is not a problem with Handbrake. This is just for reference.

User avatar
JohnAStebbins
HandBrake Team
Posts: 5535
Joined: Sat Feb 09, 2008 7:21 pm

Re: Ref frames 4 or 5?

Post by JohnAStebbins »

If everything is fine on the PC, then it is likely a decode problem on the TV. It could be any number of things. Hardware decoders all have limitations and many have flaws.

Try playback of the file before adding audio. Make sure that the pixelation exists in HandBrake's output before making other changes.

If the pixelation is present in the unmodified HandBrake output file:

1. Try lowering the bitrate. There are a number of ways to do this. Raising RF is one.
2. Try reducing the h.264 features you are using. I.e. try *fewer* ref and bframes.

If lowering the bitrate solves the problem, then you'll want to learn how to use VBV settings to limit bitrate spikes while allowing lower RF values.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Thanks! I'll check it out soon! What about flicker? Should I enable default filters and deblocking? Or leave it all off?

In my film, there are also not high bitrate materials, as well as material from a mobile phone in h264, shot through a third-party application.

mduell
Veteran User
Posts: 6933
Joined: Sat Apr 21, 2007 8:54 pm

Re: Ref frames 4 or 5?

Post by mduell »

Something shot on a mobile phone is not film, don't use the film tune.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

mduell wrote:
Wed Mar 18, 2020 1:12 pm
Something shot on a mobile phone is not film, don't use the film tune.
Thanks! I shot on a third-party application at 24fps. The film also has 35mm quality grain. I need to preserve the grain and Handbrake should know that this is a film. I proceeded from this.

mduell
Veteran User
Posts: 6933
Joined: Sat Apr 21, 2007 8:54 pm

Re: Ref frames 4 or 5?

Post by mduell »

Use the encoder tune grain, not film, to efficiently preserve the grain effect.

Vsevolod
Posts: 9
Joined: Wed Mar 11, 2020 2:46 am

Re: Ref frames 4 or 5?

Post by Vsevolod »

Thanks! Where I read that the “Grain” setting not only preserves the grain, but also adds it. I don’t know how true this is. Therefore, I chose the "Film" setup.

And also I see that now with "Grain"
deblock = 1: -2: -2

And "Film" has deblock = 1: -1: -1

But in all other films I observe deblock = 1: -3: -3

mduell
Veteran User
Posts: 6933
Joined: Sat Apr 21, 2007 8:54 pm

Re: Ref frames 4 or 5?

Post by mduell »

It does not add grain, only preserves it in an efficient way to encode.

Post Reply