Framerate conversion: Why same length when 25fps to 23,976fps

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
Micky
Posts: 14
Joined: Wed Mar 09, 2022 10:36 am

Framerate conversion: Why same length when 25fps to 23,976fps

Post by Micky »

Description of problem or question:
The encoded video has same playing time as source file even though constant framerate was chosen, frames being dropped

I was experimenting with a videofile to convert it to 23,976 fps to get that longer version to check timing with a subtitle problem, I couldn't solve in Subtitle app, without manually adjusting the whole thing. [Just experimenting, this way is not recommended when doing subtitle work!]

Handbrake puts out the video in same length even though log says it was converted to 23,976 fps.

I added a DeInterlace filter with default settings.
Encoder is H.265 NVEnc CQ23 and tried x265 CQ23 with same result

Original Playing time: 1:34:52
Converted Playing time: 1:34:52

Source:
Constant 25 fps
Interlaced
Video: HEVC
Sound: AC-3 (2 Tracks)
Resolution: 1002x446

Steps to reproduce the problem (If Applicable):
Take an interlaced video with constant framerate, preferably encoded in H265 already like mine and two ac3 audio tracks and encode it to 23,976 constant frame rate, no resolution change, but DeInterlace filter on.

Question is: Why is Handbrake dropping frames when constant quality is being set? Is it a bug or did I miss something to set?

HandBrake version (e.g., 1.0.0):
HandBrake 1.5.1 (2022011000)

Operating system and version (e.g., Ubuntu 16.04 LTS, macOS 10.13 High Sierra, Windows 10 Creators Update):
Windows 11 Home Version 10.0.22621 Build 22621

HandBrake Activity Log ***required*** (see How-to get an activity log)

Code: Select all

HandBrake 1.5.1 (2022011000)
OS: Microsoft Windows NT 10.0.22621.0
CPU: AMD Ryzen 9 5900X 12-Core Processor            
Ram: 65457 MB, 
GPU Information:
  NVIDIA GeForce RTX 3080 - 31.0.15.1694
Screen: 4096x1152
Temp Dir: C:\Users\myuser\AppData\Local\Temp\
Install Dir: C:\Program Files\HandBrake\
Data Dir: C:\Users\myuser\AppData\Roaming\HandBrake

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

 # Starting Encode ...

[14:08:34] base preset: To 23,976fps NVEnc-CQ23
[14:08:34] Remote Process started with Process ID: 14436 using port: 8037. Max Allowed Instances: 3
[14:08:34] Worker: Starting HandBrake Engine ...
[14:08:34] Worker: Starting Web Server on port 8037 ...
[14:08:34] Worker: Disconnected worker monitoring enabled!
[14:08:34] Compile-time hardening features are enabled
[14:08:34] hb_init: starting libhb thread
[14:08:34] Starting work at: Mon Dec 19 14:08:34 2022
[14:08:34] 1 job(s) to process
[14:08:34] json job:
{
  "Audio": {
    "AudioList": [
      {
        "Bitrate": 192,
        "DRC": 0,
        "Encoder": "av_aac",
        "Gain": 0,
        "Mixdown": 4,
        "NormalizeMixLevel": false,
        "Samplerate": 0,
        "Name": "Stereo",
        "Track": 0,
        "DitherMethod": 0
      },
      {
        "Bitrate": 192,
        "DRC": 0,
        "Encoder": "av_aac",
        "Gain": 0,
        "Mixdown": 4,
        "NormalizeMixLevel": false,
        "Samplerate": 0,
        "Name": "Stereo",
        "Track": 1,
        "DitherMethod": 0
      }
    ],
    "CopyMask": [
      "copy:aac",
      "copy:ac3",
      "copy:dtshd",
      "copy:dts",
      "copy:eac3",
      "copy:flac",
      "copy:mp3",
      "copy:truehd",
      "copy:mp2"
    ],
    "FallbackEncoder": "ac3"
  },
  "Destination": {
    "ChapterList": [
      {
        "Name": "Chapter 1"
      },
      {
        "Name": "Chapter 2"
      },
      {
        "Name": "Chapter 3"
      },
      {
        "Name": "Chapter 4"
      },
      {
        "Name": "Chapter 5"
      },
      {
        "Name": "Chapter 6"
      },
      {
        "Name": "Chapter 7"
      },
      {
        "Name": "Chapter 8"
      },
      {
        "Name": "Chapter 9"
      },
      {
        "Name": "Chapter 10"
      },
      {
        "Name": "Chapter 11"
      },
      {
        "Name": "Chapter 12"
      },
      {
        "Name": "Chapter 13"
      },
      {
        "Name": "Chapter 14"
      },
      {
        "Name": "Chapter 15"
      },
      {
        "Name": "Chapter 16"
      },
      {
        "Name": "Chapter 17"
      },
      {
        "Name": "Chapter 18"
      }
    ],
    "ChapterMarkers": true,
    "AlignAVStart": false,
    "File": "C:\\Users\\myuser\\Videos\\Handbrake Export\\Video with 25fps.mp4",
    "Mp4Options": {
      "IpodAtom": false,
      "Mp4Optimize": true
    },
    "Mux": "av_mp4"
  },
  "Filters": {
    "FilterList": [
      {
        "ID": 5,
        "Settings": {
          "mode": "3"
        }
      },
      {
        "ID": 13,
        "Settings": {
          "crop-bottom": "0",
          "crop-left": "0",
          "crop-right": "0",
          "crop-top": "0",
          "height": "446",
          "width": "1002"
        }
      },
      {
        "ID": 6,
        "Settings": {
          "mode": "1",
          "rate": "27000000/1126125"
        }
      }
    ]
  },
  "PAR": {
    "Num": 1,
    "Den": 1
  },
  "Metadata": {
    "Name": "Video with 25fps"
  },
  "SequenceID": 0,
  "Source": {
    "Angle": 1,
    "Range": {
      "Type": "chapter",
      "Start": 1,
      "End": 18
    },
    "Title": 1,
    "Path": "C:\\Users\\myuser\\Videos\\_Test\\Video with 25fps.mkv"
  },
  "Subtitle": {
    "Search": {
      "Burn": false,
      "Default": false,
      "Enable": false,
      "Forced": false
    },
    "SubtitleList": []
  },
  "Video": {
    "Encoder": "nvenc_h265",
    "Level": "auto",
    "TwoPass": false,
    "Turbo": false,
    "ColorMatrixCode": 0,
    "Options": "",
    "Preset": "medium",
    "Profile": "auto",
    "Quality": 23,
    "QSV": {
      "Decode": false
    }
  }
}
[14:08:34] CPU: AMD Ryzen 9 5900X 12-Core Processor
[14:08:34]  - logical processor count: 24
[14:08:34] Intel Quick Sync Video support: no
[14:08:34] hb_scan: path=C:\Users\myuser\Videos\_Test\Video with 25fps.mkv, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
src/libbluray/disc/disc.c:333: failed opening UDF image C:\Users\myuser\Videos\_Test\Video with 25fps.mkv
src/libbluray/disc/disc.c:437: error opening file BDMV\index.bdmv
src/libbluray/disc/disc.c:437: error opening file BDMV\BACKUP\index.bdmv
src/libbluray/bluray.c:2646: nav_get_title_list(C:\Users\myuser\Videos\_Test\Video with 25fps.mkv\) failed
[14:08:34] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvlibdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
dread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[14:08:34] dvd: not a dvd - trying as a stream/file instead
Input #0, matroska,webm, from 'C:\Users\myuser\Videos\_Test\Video with 25fps.mkv':
  Metadata:
    ENCODER         : Lavf55.12.0
    TITLE           : Video with 25fps
  Duration: 01:34:52.60, start: 0.080000, bitrate: 2387 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 94.520000
      Metadata:
        title           : Chapter 1
    Chapter #0:1: start 94.520000, end 462.560000
      Metadata:
        title           : Chapter 2
    Chapter #0:2: start 462.560000, end 586.360000
      Metadata:
        title           : Chapter 3
    Chapter #0:3: start 586.360000, end 840.440000
      Metadata:
        title           : Chapter 4
    Chapter #0:4: start 840.440000, end 987.800000
      Metadata:
        title           : Chapter 5
    Chapter #0:5: start 987.800000, end 1424.720000
      Metadata:
        title           : Chapter 6
    Chapter #0:6: start 1424.720000, end 1972.800000
      Metadata:
        title           : Chapter 7
    Chapter #0:7: start 1972.800000, end 2185.920000
      Metadata:
        title           : Chapter 8
    Chapter #0:8: start 2185.920000, end 2720.320000
      Metadata:
        title           : Chapter 9
    Chapter #0:9: start 2720.320000, end 2893.920000
      Metadata:
        title           : Chapter 10
    Chapter #0:10: start 2893.920000, end 3075.600000
      Metadata:
        title           : Chapter 11
    Chapter #0:11: start 3075.600000, end 3547.360000
      Metadata:
        title           : Chapter 12
    Chapter #0:12: start 3547.360000, end 4237.880000
      Metadata:
        title           : Chapter 13
    Chapter #0:13: start 4237.880000, end 4433.960000
      Metadata:
        title           : Chapter 14
    Chapter #0:14: start 4433.960000, end 4833.760000
      Metadata:
        title           : Chapter 15
    Chapter #0:15: start 4833.760000, end 5115.520000
      Metadata:
        title           : Chapter 16
    Chapter #0:16: start 5115.520000, end 5676.160000
      Metadata:
        title           : Chapter 17
    Chapter #0:17: start 5676.160000, end 5692.560000
      Metadata:
        title           : Chapter 18
  Stream #0:0: Video: hevc (Main), yuv420p(tv, smpte170m/bt470bg/bt709), 1002x446, SAR 1:1 DAR 501:223, 25 fps, 25 tbr, 1k tbn, 25 tbc (default)
  Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
    Metadata:
      title           : Stereo
      LANGUAGE        : ger
  Stream #0:2(eng): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
    Metadata:
      title           : Stereo
      LANGUAGE        : eng
[14:08:34] scan: decoding previews for title 1
[14:08:34] scan: audio 0x1: ac3, rate=48000Hz, bitrate=224000 Deutsch (AC3) (2.0 ch) (224 kbps)
[14:08:34] scan: audio 0x2: ac3, rate=48000Hz, bitrate=224000 English (AC3) (2.0 ch) (224 kbps)
[14:08:34] scan: 10 previews, 1002x446, 25.000 fps, autocrop = 0/0/0/0, aspect 2.25:1, PAR 1:1, color profile: 5-1-6, chroma location: left
[14:08:34] libhb: scan thread found 1 valid title(s)
[14:08:34] Starting Task: Encoding Pass
[14:08:34] Skipping crop/scale filter
[14:08:34] work: track 1, dithering not supported by codec
[14:08:34] work: track 2, dithering not supported by codec
[14:08:34] job configuration:
[14:08:34]  * source
[14:08:34]    + C:\Users\myuser\Videos\_Test\Video with 25fps.mkv
[14:08:34]    + title 1, chapter(s) 1 to 18
[14:08:34]    + container: matroska,webm
[14:08:34]    + data rate: 2387 kbps
[14:08:34]  * destination
[14:08:34]    + C:\Users\myuser\Videos\Handbrake Export\Video with 25fps.mp4
[14:08:34]    + container: MPEG-4 (libavformat)
[14:08:34]      + optimized for HTTP streaming (fast start)
[14:08:34]      + chapter markers
[14:08:34]  * video track
[14:08:34]    + decoder: hevc 8-bit (yuv420p)
[14:08:34]    + filters
[14:08:34]      + Deinterlace (mode=3)
[14:08:34]      + Framerate Shaper (mode=1:rate=27000000/1126125)
[14:08:34]        + frame rate: 25.000 fps -> constant 23.976 fps
[14:08:34]    + Output geometry
[14:08:34]      + storage dimensions: 1002 x 446
[14:08:34]      + pixel aspect ratio: 1 : 1
[14:08:34]      + display dimensions: 1002 x 446
[14:08:34]    + encoder: H.265 (NVEnc)
[14:08:34]      + preset:  medium
[14:08:34]      + profile: auto
[14:08:34]      + level:   auto
[14:08:34]      + quality: 23.00 (CQ)
[14:08:34]      + color profile: 5-1-6
[14:08:34]      + chroma location: left
[14:08:34]  * audio track 1
[14:08:34]    + name: Stereo
[14:08:34]    + decoder: Deutsch (AC3) (2.0 ch) (224 kbps) (track 1, id 0x1)
[14:08:34]      + bitrate: 224 kbps, samplerate: 48000 Hz
[14:08:34]    + mixdown: Stereo
[14:08:34]    + encoder: AAC (libavcodec)
[14:08:34]      + bitrate: 192 kbps, samplerate: 48000 Hz
[14:08:34]  * audio track 2
[14:08:34]    + name: Stereo
[14:08:34]    + decoder: English (AC3) (2.0 ch) (224 kbps) (track 2, id 0x2)
[14:08:34]      + bitrate: 224 kbps, samplerate: 48000 Hz
[14:08:34]    + mixdown: Stereo
[14:08:34]    + encoder: AAC (libavcodec)
[14:08:34]      + bitrate: 192 kbps, samplerate: 48000 Hz
[14:08:34] sync: expecting 142315 video frames
[14:08:34] encavcodecInit: H.265 (Nvidia NVENC)
[14:08:34] encavcodec: encoding at rc=vbr, multipass=fullres, 23.00
[14:08:34] encavcodec: encoding with stored aspect 1/1
[14:08:35] sync: first pts video is 0
[14:08:35] sync: "Chapter 1" (1) at frame 1 time 0
[14:08:35] sync: first pts audio 0x1 is 0
[14:08:35] sync: first pts audio 0x2 is 0
[14:08:36] sync: "Chapter 2" (2) at frame 2366 time 8514000
[14:08:45] sync: "Chapter 3" (3) at frame 11569 time 41644800
[14:08:47] sync: "Chapter 4" (4) at frame 14663 time 52783200
[14:08:52] sync: "Chapter 5" (5) at frame 21014 time 75646800
[14:08:56] sync: "Chapter 6" (6) at frame 24698 time 88909200
[14:09:05] sync: "Chapter 7" (7) at frame 35622 time 128235600
[14:09:19] sync: "Chapter 8" (8) at frame 49323 time 177559200
[14:09:23] sync: "Chapter 9" (9) at frame 54652 time 196743600
[14:09:36] sync: "Chapter 10" (10) at frame 68011 time 244836000
[14:09:41] sync: "Chapter 11" (11) at frame 72352 time 260463600
[14:09:45] sync: "Chapter 12" (12) at frame 76894 time 276814800
[14:09:54] sync: "Chapter 13" (13) at frame 88687 time 319269600
[14:10:09] sync: "Chapter 14" (14) at frame 105951 time 381420000
[14:10:13] sync: "Chapter 15" (15) at frame 110853 time 399067200
[14:10:20] sync: "Chapter 16" (16) at frame 120847 time 435045600
[14:10:26] sync: "Chapter 17" (17) at frame 127891 time 460404000
[14:10:40] sync: "Chapter 18" (18) at frame 141908 time 510865200
[14:10:40] reader: done. 1 scr changes
[14:10:41] work: average encoding speed for job is 1131.593018 fps
[14:10:41] vfr: 136484 frames output, 5829 dropped and 0 duped for CFR/PFR
[14:10:41] vfr: lost time: 0 (0 frames)
[14:10:41] vfr: gained time: 0 (0 frames) (0 not accounted for)
[14:10:41] ac3-decoder done: 177889 frames, 0 decoder errors
[14:10:41] ac3-decoder done: 177889 frames, 0 decoder errors
[14:10:41] hevc-decoder done: 142313 frames, 0 decoder errors
[14:10:41] sync: got 142313 frames, 142315 expected
[14:10:41] sync: framerate min 25.000 fps, max 25.000 fps, avg 25.000 fps
[14:10:41] mux: track 0, 136484 frames, 1356063814 bytes, 1905.75 kbps, fifo 2048
[14:10:41] mux: track 1, 266834 frames, 136562043 bytes, 191.92 kbps, fifo 4096
[14:10:41] mux: track 2, 266834 frames, 136655711 bytes, 192.05 kbps, fifo 4096
[14:10:41] Finished work at: Mon Dec 19 14:10:41 2022
[14:10:41] libhb: work result = 0

 # Job Completed!
rollin_eng
Veteran User
Posts: 4854
Joined: Wed May 04, 2011 11:06 pm

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by rollin_eng »

You still have the same length of video, just at a different frame rate.
Micky
Posts: 14
Joined: Wed Mar 09, 2022 10:36 am

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Micky »

A regular conversion from 25fps to 23,976fps results in a longer playback time, what do I have to set differently than constant frame rate to achieve a regular conversion with Handbrake? I don't want frames to be dropped, never set that. Is it a bug?
Deleted User 11865

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Deleted User 11865 »

Nope, "PAL speedup" (23.976 -> 25 fps) and the reverse are not "regular conversions" and require adjusting the audio track as well to maintain A/V sync and audio pitch. HandBrake does a basic ("regular") frame rate conversion instead, by duplicating/dropping frames as necessary, leaving the audio unchanged.
Micky
Posts: 14
Joined: Wed Mar 09, 2022 10:36 am

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Micky »

Well, seems to be a matter of opinion.
When I choose a different than source frame rate, I'd expect it to be "regular" adding or subtracting frames to achieve desired frame rate, and adjust length of audio accordingly.

With Handbrake's method I get a variable frame rate video what I wouldn't expect, because i chose to encode a constant frame rate in settings.

At least, calling it constant framerate is misleading in Handbrake, when the result is a variable frame rate video, don't you think?

It would have been nice to get a message that the conversion method is preserving the same length as source, because of not touching audio and an description of why audio is not being touched would be nice in that regard.

Why is the audio not being touched when converting video frame rate?
Deleted User 11865

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Deleted User 11865 »

Micky wrote: Mon Dec 19, 2022 5:10 pm Well, seems to be a matter of opinion.
When I choose a different than source frame rate, I'd expect it to be "regular" adding or subtracting frames to achieve desired frame rate
That's what HandBrake is doing (adding or subtracting video frames as required). What you want it to do is non-standard (not add nor remove any frames, but adjust the frame durations instead).
Micky wrote: Mon Dec 19, 2022 5:10 pmWith Handbrake's method I get a variable frame rate video what I wouldn't expect, because i chose to encode a constant frame rate in settings.

At least, calling it constant framerate is misleading in Handbrake, when the result is a variable frame rate video, don't you think?
HandBrake outputs constant framerate when requested. MediaInfo and some similar tools is can misreport variable framerate because of the 90 kHz timebase used by HandBrake, but that's their problem (and entirely unrelated to your original issue).
Micky wrote: Mon Dec 19, 2022 5:10 pmWhy is the audio not being touched when converting video frame rate?
Because that's how standard frame rate conversion is done.

PAL speedup and its inverse are non-standard and only work for 24 <-> 25 fps because they are within 4% of each other; when watching film converted to PAL this way, you're actually fast-forwarding through the entire movie/episode.

Every other frame rate combo must use a more standard form of conversion or the results would be unwatchable.
Micky
Posts: 14
Joined: Wed Mar 09, 2022 10:36 am

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Micky »

Rodeo wrote: Mon Dec 19, 2022 7:23 pm
Micky wrote: Mon Dec 19, 2022 5:10 pm Well, seems to be a matter of opinion.
When I choose a different than source frame rate, I'd expect it to be "regular" adding or subtracting frames to achieve desired frame rate
That's what HandBrake is doing (adding or subtracting video frames as required). What you want it to do is non-standard (not add nor remove any frames, but adjust the frame durations instead).

Well, it's a standard in Handbrake, ok, but it's misleading to call it a standard in general. 24 <-> 25 conversions are being done since ever they invented TV in Germany back when. And when filmed in 24fps there always was a speed up to get the PAL framerate (25) which was used in the most countries all over the world. Long, they had the problem with pitch change (which they solved at some point), but a converted movie always played 4% faster on that PAL TV and total playing time always was shorter.

Rodeo wrote: Mon Dec 19, 2022 7:23 pm
Micky wrote: Mon Dec 19, 2022 5:10 pmWith Handbrake's method I get a variable frame rate video what I wouldn't expect, because i chose to encode a constant frame rate in settings.

At least, calling it constant framerate is misleading in Handbrake, when the result is a variable frame rate video, don't you think
HandBrake outputs constant framerate when requested. MediaInfo and some similar tools is can misreport variable framerate because of the 90 kHz timebase used by HandBrake, but that's their problem (and entirely unrelated to your original issue).
That's not a problem of theirs, they only show what's inside that video file.
But if you know that they show wrong info, why wouldn't you help them? It seems to be a topic with some confusion.
MediaInfo is being used all over the place and it would be very helpful.

Well, I requested Constant Framerate and I got dropped frames, that I did not request, because going from more frames (25) to less frames (24) per second could be easy to distribute over time. The Encoder app is not the one to decide which frames are being dropped. That's being done in the edit room.
Rodeo wrote: Mon Dec 19, 2022 7:23 pm
Micky wrote: Mon Dec 19, 2022 5:10 pmWhy is the audio not being touched when converting video frame rate?
Because that's how standard frame rate conversion is done.

PAL speedup and its inverse are non-standard and only work for 24 <-> 25 fps because they are within 4% of each other; when watching film converted to PAL this way, you're actually fast-forwarding through the entire movie/episode.

Every other frame rate combo must use a more standard form of conversion or the results would be unwatchable.
What standard is it exactly that you mention here? PAL speedup and its inverse is done for ages and really is a standard. There are still differences in frame rates even with the invention of HDTV. Droppoing frames without knowing which is being dropped seems not to be the right choice for me.

Thank you for your explanation about how Handbrake handles frame rate conversion, I did not find anything in the manual.
Deleted User 11865

Re: Framerate conversion: Why same length when 25fps to 23,976fps

Post by Deleted User 11865 »

HandBrake has one frame rate conversion algorithm that works for everything. PAL speedup works for one special case only, so there is little interest in implementing a second algorithm just for that. But feel free to write the code and submit a pull request if you care enough.

Regarding MediaInfo, because with a 90 kHz timebase a 24/1001 second frame lasts 3753.75 ticks, every 4th frame will last 3753 ticks instead of 3754. The video bitstream is flagged as CFR correctly and each frame does last the same duration for all practical intents and purposes. MediaInfo understands this when the source is e.g. an MPEG Transport Stream (with the same 90 kHz timebase), but not for MPEG-4 Part 14, go figure.
Post Reply