Opened 7 years ago

Closed 7 years ago

#6406 closed defect (invalid)

Framerate issues with HVEC and mkv container

Reported by: Nobody Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
Similar to ticket: https://trac.ffmpeg.org/ticket/259

The issue is that FFMPEG does not detect the right framerate. My mkv file is 4k and i want to downscale the video to 1920 x1080 full HD. FFMPEG detects the framerate as 29.98 while this needs to be 29.986.

I have been looking at the source but I cant seem to figure out where the framerate detection is. To me it means your floats are capped to 2 decimals or something or the framerate is not detected properly with x265 lib I dunno...

How to reproduce:
% ffmpeg -i input.mkv
Stream #0.0: Video: vc1 (Advanced), yuv420p, 3840x2160 [PAR 1:1 DAR 16:9], 29.98 fps, 29.98 tbr, 1k tbn, 29.98 tbc (default)

ffmpeg version: tried two versions both gave the same error. latest from ubuntu 16.04 (yesterday) and pulled latest source through git yesterday and compiled it)

built on:
Ubuntu 16.04

I wil update the ticket monday with more info

Change History (5)

comment:1 by Hendrik, 7 years ago

The actual fully accurate "23p" framerate is 23.9760239760239760....., not 23.98 or 23.976.

It appears to simply be rounding for display purposes, it has the right framerate internally.

comment:2 by Nobody, 7 years ago

I understand what you are saying and aboutg the frame rate you are right. But the reason I raised this ticket is that the audio is out of sync. And this sounds to me to most viable reason. I can not think of anything else that could cause this issue to appear ...

Here is the additional info I promised.
Framerate from the original ffmpeg file before conversion:

ffmpeg version N-86111-ga441aa9 Copyright (c) 2000-2017 the FFmpeg developers

built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/home/joris/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/joris/ffmpeg_build/include --extra-ldflags=-L/home/joris/ffmpeg_build/lib --bindir=/home/joris/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 55. 63.100 / 55. 63.100
libavcodec 57. 96.101 / 57. 96.101
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 89.101 / 6. 89.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100

Input #0, matroska,webm, from 'The.Amazing.Spiderman.2.mkv':

Metadata:

CREATION_TIME : 2016-07-01T21:08:20Z
ENCODER : Lavf56.1.0

Duration: 02:21:32.88, start: 0.000000, bitrate: 30469 kb/s

Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, smpte170m/bt709/bt709), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:

title : Stereo

At least one output file must be specified

And here is the framerate from same original file, but from mediainfo:

General
Unique ID : 186140261711886736390264232193180678147 (0x8C094F75A2435ABB0987FED77919B803)
Complete name : The.Amazing.Spiderman.2.mkv
Format : Matroska
Format version : Version 2
File size : 30.1 GiB
Duration : 2h 21mn
Overall bit rate : 30.5 Mbps
Encoded date : UTC 2016-07-01T21:08:20Z
Writing application : HandBrake 20160604111422-9206444-master 2016060501
Writing library : Lavf56.1.0 / Lavf56.1.0

Video
ID : 1
Format : HEVC
Format/Info : High Efficiency Video Coding
Format profile : Main 10@L5.1@Main
Codec ID : V_MPEGH/ISO/HEVC
Duration : 2h 21mn
Width : 3 840 pixels
Height : 2 160 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 (24000/1001) fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 10 bits
Writing library : x265 1.9+3-63308f7658c3:[Windows][GCC 5.2.0][64 bit] 10bit
Encoding settings : wpp / ctu=64 / min-cu-size=8 / max-tu-size=32 / tu-intra-depth=1 / tu-inter-depth=1 / me=1 / subme=2 / merange=57 / no-rect / no-amp / max-merge=2 / temporal-mvp / no-early-skip / rdpenalty=0 / no-tskip / no-tskip-fast / strong-intra-smoothing / no-lossless / no-cu-lossless / no-constrained-intra / no-fast-intra / open-gop / no-temporal-layers / interlace=0 / keyint=240 / min-keyint=24 / scenecut=40 / rc-lookahead=20 / lookahead-slices=8 / bframes=4 / bframe-bias=0 / b-adapt=2 / ref=3 / limit-refs=3 / no-limit-modes / weightp / no-weightb / aq-mode=1 / qg-size=32 / aq-strength=1.00 / cbqpoffs=0 / crqpoffs=0 / rd=3 / psy-rd=2.00 / rdoq-level=0 / psy-rdoq=0.00 / signhide / deblock / sao / no-sao-non-deblock / b-pyramid / cutree / no-intra-refresh / rc=abr / bitrate=31000 / qcomp=0.60 / qpmin=0 / qpmax=51 / qpstep=4 / ipratio=1.40 / pbratio=1.30
Default : Yes
Forced : No
Color range : Limited
Color primaries : BT.709
Transfer characteristics : BT.709
Matrix coefficients : BT.601

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : A_AAC
Duration : 2h 21mn
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Frame rate : 46.875 fps (1024 spf)
Compression mode : Lossy
Delay relative to video : -21ms
Title : Stereo
Default : Yes
Forced : No

Once I scale and convert it to 1080p I get this:

ffmpeg version N-86111-ga441aa9 Copyright (c) 2000-2017 the FFmpeg developers

built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/home/joris/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/joris/ffmpeg_build/include --extra-ldflags=-L/home/joris/ffmpeg_build/lib --bindir=/home/joris/bin --enable-gpl --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree
libavutil 55. 63.100 / 55. 63.100
libavcodec 57. 96.101 / 57. 96.101
libavformat 57. 72.101 / 57. 72.101
libavdevice 57. 7.100 / 57. 7.100
libavfilter 6. 89.101 / 6. 89.101
libswscale 4. 7.101 / 4. 7.101
libswresample 2. 8.100 / 2. 8.100
libpostproc 54. 6.100 / 54. 6.100

Input #0, matroska,webm, from 'The.Amazing.Spiderman.2.mkv':

Metadata:

CREATION_TIME : 2016-07-01T21:08:20Z
ENCODER : Lavf56.1.0

Duration: 02:21:32.88, start: 0.000000, bitrate: 30469 kb/s

Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv, smpte170m/bt709/bt709), 3840x2160 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)

Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:

title : Stereo

Stream mapping:

Stream #0:0 -> #0:0 (hevc (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> vorbis (libvorbis))

Press [q] to stop, ? for help
[libx264 @ 0x3acefc0] using SAR=1/1
[libx264 @ 0x3acefc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x3acefc0] profile High, level 4.0
[libx264 @ 0x3acefc0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'The.Amazing.Spiderman.2.1080p.mkv':

Metadata:

encoder : Lavf57.72.101

Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 23.98 fps, 1k tbn, 23.98 tbc (default)

Metadata:

encoder : Lavc57.96.101 libx264

Side data:

cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1

Stream #0:1: Audio: vorbis (libvorbis) (oV[0][0] / 0x566F), 48000 Hz, stereo, fltp (default)
Metadata:

title : Stereo
encoder : Lavc57.96.101 libvorbis

comment:3 by Nobody, 7 years ago

Sorry, you are right, I judged to quick. The new encoded file is also 24p, so something else might be going on, not sure what though ...

Frame rate : 23.976 (24000/1001) fps

comment:4 by Nobody, 7 years ago

Status: newopen

I will close the ticket.

comment:5 by Nobody, 7 years ago

Resolution: invalid
Status: openclosed
Note: See TracTickets for help on using tickets.