Doesn't Handbrake cut frame accurately any more?

General questions or discussion about HandBrake, Video and/or audio transcoding, trends etc.
Post Reply
JPT357
New User
Posts: 1
Joined: Thu Apr 11, 2024 5:26 pm

Doesn't Handbrake cut frame accurately any more?

Post by JPT357 »

Hi

Description of problem or question:
I try compressing some MP4 videos from a Super8 digitiser.
Before compressing I cut them into pieces with Mkvtoolnix. This only cuts at key frames which is no wonder because it does not re-encode.
Then I open Handbrake and want to compress for example from frame 6 to 17. Result is from frame 0 to frame 12.
(similar problem happens without mkvtoolnix in between)

(I previously had a feeling there is something wrong because the end frame does not get loaded correctly from queue)

I believe in this handbrake version there is something about the frames screwed up.

Steps to reproduce the problem: see above
HandBrake version: 1.7.3 (x86_64) from flatpak
Operating system: Kubuntu 23.10, kernel 6.5.0-27-generic

HandBrake Activity Log ***required***

Code: Select all

Handbrake Version: 1.7.3 (2024021300)
[19:22:05] gtkgui: Modified Custom Preset: /General/H265 S23 GM
[19:22:05] Starting work at: Thu Apr 11 19:22:05 2024

[19:22:05] 1 job(s) to process
[19:22:05] CPU: Intel(R) Core(TM) i5-9600K CPU @ 3.70GHz
[19:22:05]  - Intel microarchitecture Kaby Lake
[19:22:05]  - logical processor count: 6
[19:22:05] Intel Quick Sync Video support: yes
[19:22:05] Intel Quick Sync Video integrated adapter with index 0 and renderD128
[19:22:05] Impl mfxhw64 library path: /app/extensions/IntelMediaSDK/lib/libmfxhw64.so.1.35
[19:22:05]  - Intel Media SDK hardware: API 1.35 (minimum: 1.3)
[19:22:05]  - H.264 encoder: yes
[19:22:05]     - preferred implementation: hardware (any) via ANY
[19:22:05]  - H.265 encoder: yes (8bit: yes, 10bit: yes)
[19:22:05]     - preferred implementation: hardware (any) via ANY
[19:22:05]  - AV1 encoder: no
[19:22:05] hb_scan: path=inputfilepath.mkv, title_index=1
Input #0, matroska,webm, from 'inputfilepath.mkv':
  Metadata:
    encoder         : libebml v1.4.4 + libmatroska v1.7.1
    creation_time   : 2024-04-11T17:15:06.000000Z
  Duration: 00:00:01.50, start: 0.000000, bitrate: 9587 kb/s
  Stream #0:0: Video: h264 (High), yuv420p(progressive), 1440x1080, SAR 1:1 DAR 4:3, 20 fps, 20 tbr, 1k tbn (default)
    Metadata:
      BPS             : 9554816
      DURATION        : 00:00:01.500000000
      NUMBER_OF_FRAMES: 30
      NUMBER_OF_BYTES : 1791528
      _STATISTICS_WRITING_APP: mkvmerge v78.0 ('Running') 64-bit
      _STATISTICS_WRITING_DATE_UTC: 2024-04-11 17:15:06
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[19:22:05] scan: decoding previews for title 1
[19:22:06] scan: 10 previews, 1440x1080, 20,000 fps, autocrop = 0/0/0/0, aspect 4:3, PAR 1:1, color profile: 1-1-1, chroma location: left
[19:22:06] scan: supported video decoders: avcodec qsv
[19:22:06] libhb: scan thread found 1 valid title(s)
[19:22:06] qsv: integrated qsv adapter with index 0 has been selected
[19:22:06] Starting Task: Encoding Pass
[19:22:06] job configuration:
[19:22:06]  * source
[19:22:06]    + inputfilepath.mkv
[19:22:06]    + title 1, frames 5 to 16
[19:22:06]    + container: matroska,webm
[19:22:06]    + data rate: 9587 kbps
[19:22:06]  * destination
[19:22:06]    + outputfilepath.mkv
[19:22:06]    + container: Matroska (libavformat)
[19:22:06]  * video track
[19:22:06]    + decoder: h264 8-bit (yuv420p)
[19:22:06]    + filters
[19:22:06]      + Framerate Shaper (mode=1)
[19:22:06]        + frame rate: 20,000 fps -> constant 20,000 fps
[19:22:06]      + Denoise (hqdn3d) (y-spatial=7:cb-spatial=7:cr-spatial=7:y-temporal=5:cb-temporal=5:cr-temporal=5)
[19:22:06]      + Crop and Scale (width=1312:height=914:crop-top=86:crop-bottom=80:crop-left=42:crop-right=86)
[19:22:06]        + source: 1440 * 1080, crop (86/80/42/86): 1312 * 914, scale: 1312 * 914
[19:22:06]    + Output geometry
[19:22:06]      + storage dimensions: 1312 x 914
[19:22:06]      + pixel aspect ratio: 1 : 1
[19:22:06]      + display dimensions: 1312 x 914
[19:22:06]    + encoder: H.265 (libx265)
[19:22:06]      + preset:  slow
[19:22:06]      + profile: auto
[19:22:06]      + level:   auto
[19:22:06]      + quality: 25,00 (RF)
[19:22:06]      + color profile: 1-1-1
[19:22:06]      + chroma location: left
[19:22:06] sync: expecting 12 video frames
x265 [info]: HEVC encoder version 3.5+1-f0c1022b6
x265 [info]: build info [Linux][GCC 13.2.0][64 bit] 8bit+10bit+12bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
x265 [info]: Main profile, Level-4 (Main tier)
x265 [info]: Thread pool created using 6 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 2 / wpp(15 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : star / 57 / 3 / 3
x265 [info]: Keyframe min / max / scenecut / bias  : 20 / 200 / 40 / 5,00 
x265 [info]: Lookahead / bframes / badapt        : 25 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 4 / on / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1,0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-25,0 / 0,60
x265 [info]: tools: rect limit-modes rd=4 psy-rd=2,00 rdoq=2 psy-rdoq=1,00
x265 [info]: tools: rskip mode=1 signhide tmvp strong-intra-smoothing lslices=4
x265 [info]: tools: deblock sao
[19:22:06] reader: done. 1 scr changes
[19:22:06] sync: first pts video is 0
[19:22:06] sync: reached video frame 12, exiting early
[19:22:08] work: average encoding speed for job is 0,000000 fps
[19:22:08] vfr: 12 frames output, 0 dropped and 0 duped for CFR/PFR
[19:22:08] vfr: lost time: 0 (0 frames)
[19:22:08] vfr: gained time: 0 (0 frames) (0 not accounted for)
[19:22:08] h264-decoder done: 30 frames, 0 decoder errors
[19:22:08] sync: got 12 frames, 12 expected
[19:22:08] sync: framerate min 20,000 fps, max 20,000 fps, avg 20,000 fps
x265 [info]: frame I:      2, Avg QP:26,22  kb/s: 2237,44 
x265 [info]: frame P:      3, Avg QP:27,03  kb/s: 6507,31 
x265 [info]: frame B:      7, Avg QP:29,00  kb/s: 4175,79 
x265 [info]: Weighted P-Frames: Y:0,0% UV:0,0%

encoded 12 frames in 1,90s (6,31 fps), 4435,61 kb/s, Avg QP:28,04
[19:22:08] mux: track 0, 12 frames, 332719 bytes, 4095,00 kbps, fifo 16
[19:22:08] Finished work at: Thu Apr 11 19:22:08 2024

[19:22:08] libhb: work result = 0

Code: Select all

$ medianfo
General
Format                                   : Matroska
Format version                           : Version 4
File size                                : 1.71 MiB
Duration                                 : 1 s 500 ms
Overall bit rate                         : 9 587 kb/s
Frame rate                               : 20.000 FPS
Encoded date                             : 2024-04-11 17:15:06 UTC
Writing application                      : mkvmerge v78.0 ('Running') 64-bit
Writing library                          : libebml v1.4.4 + libmatroska v1.7.1

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.1
Format settings                          : CABAC / 1 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 1 frame
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 1 s 500 ms
Bit rate                                 : 9 555 kb/s
Width                                    : 1 440 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 20.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.307
Stream size                              : 1.71 MiB (100%)
thank you for any help
User avatar
s55
HandBrake Team
Posts: 10409
Joined: Sun Dec 24, 2006 1:05 pm

Re: Doesn't Handbrake cut frame accurately any more?

Post by s55 »

HandBrake has never guaranteed frame accuracy when cutting so it'll be not in many cases. It's not really the write tool for the job if you need frame accurate cutting.
Rodeo314
Enlightened
Posts: 109
Joined: Wed Jan 17, 2024 3:44 am

Re: Doesn't Handbrake cut frame accurately any more?

Post by Rodeo314 »

Are you sure it's really encoding 0 to 12? I think the log message is just broken, printing the frame count rather than the end frame index (been like this for some time, too).

Are you able to share your 1.71 MiB test source?
Post Reply