Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] FFMPEG support for x265 vbv-end and vbv-end-fr-adj
@ 2024-05-01 21:10 Tom Vaughan
  2024-05-15 12:59 ` Michael Niedermayer
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Vaughan @ 2024-05-01 21:10 UTC (permalink / raw)
  To: ffmpeg-devel

When I attempt to pass vbv-end and vbv-end-fr-adj parameters to x265, FFMPEG fails.

x265 [error]: vbv-end-fr-adj cannot be enabled when total number of frames is unknown

x265 needs to know how many frames it is encoding so that it knows when the vbv-end logic needs to kick in. In this case it would be after 96% of the source video is encoded. Despite specifying a duration of 30 seconds ( -t 30 ) on both input and output (using a 60 second source video), x265 does not know the total number of frames (but FFMPEG surely does).

ffmpeg -i test_uhdsdr_1min.mov -t 30 -an -sn -dn -c:v libx265 -b:v 12000k -maxrate 8M -bufsize 18M -x265-params vbv-init=0.9:vbv-end=0.9:vbv-end-fr-adj=.96:rc-lookahead=48:qg-size=32:scenecut=0:no-open-gop=1:frame-threads=0:repeat-headers=1:nr-inter=400:nr-intra=100:psy-rd=0:cbqpoffs=0:crqpoffs=3 -t 30 test_uhdsdr_96.mp4

ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with Apple clang version 15.0.0 (clang-1500.1.0.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/6.1.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags='-Wl,-ld_classic' --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libaribb24 --enable-libbluray --enable-libdav1d --enable-libharfbuzz --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopenvino --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-video
 toolbox --enable-audiotoolbox --enable-neon
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test_uhdsdr_1min.mov':
  Metadata:
    major_brand     : qt
    minor_version   : 512
    compatible_brands: qt
    encoder         : Lavf60.3.100
  Duration: 00:01:00.06, start: 0.000000, bitrate: 693020 kb/s
  Stream #0:0[0x1]: Video: prores (HQ) (apch / 0x68637061), yuv422p10le(bt709, progressive), 3840x2160, 693017 kb/s, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 24k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : FFMP
      encoder         : Apple ProRes 422 (HQ)
      timecode        : 00:00:00:00
  Stream #0:1[0x2](eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      handler_name    : TimeCodeHandler
      timecode        : 00:00:00:00
Stream mapping:
  Stream #0:0 -> #0:0 (prores (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 3.4+31-6722fce1f
x265 [info]: build info [Mac OS X][clang 14.0.0][32 bit][noasm] 10bit
x265 [info]: using cpu capabilities: none!
x265 [error]: vbv-end-fr-adj cannot be enabled when total number of frames is unknown
[libx265 @ 0x120706a30] Cannot open libx265 encoder.
[vost#0:0/libx265 @ 0x1207067c0] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.
Error while filtering: Invalid data found when processing input
[out#0/mp4 @ 0x600002dc0240] Nothing was written into output file, because at least one of its streams received no packets.
frame=    0 fps=0.0 q=0.0 Lsize=       0kB time=N/A bitrate=N/A speed=N/A
Conversion failed!

Running x265 directly (using the decoded YUV in a Y4M container as the source) with the same parameters works fine.
x265 --input test_uhdsdr_1min.Y4M --y4m --bitrate 12000 --profile main10 --keyint 48 --no-open-gop --scenecut 0 --vbv-init 0.9 --vbv-maxrate 18000 --vbv-bufsize 18000 --vbv-end 0.9 --vbv-end-fr-adj .96 --csv fr_adj_96.csv --csv-log-level 1 -o test_UHDSDR_12000_fr_adj_20.265
y4m  [info]: 3840x2160 fps 24000/1001 i420p10 sar 1:1 frames 0 - 1438 of 1439
raw  [info]: output file: test_UHDSDR_12000_fr_adj_20.265
x265 [info]: HEVC encoder version 3.6+7-53afbf5f5
x265 [info]: build info [Mac OS X][GCC 13.2.0][64 bit] 10bit
x265 [info]: using cpu capabilities: NEON
x265 [info]: Main 10 profile, Level-5 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(34 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         : hex / 57 / 2 / 3
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : ABR-12000 kbps / 0.60
x265 [info]: VBV/HRD buffer / max-rate / init / end / fr-adj: 18000 / 18000 / 0.900 / 0.900 / 0.960
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp
x265 [info]: tools: b-intra strong-intra-smoothing lslices=8 deblock sao
x265 [info]: frame I:     30, Avg QP:33.26  kb/s: 53324.81
x265 [info]: frame P:    318, Avg QP:35.26  kb/s: 21643.30
x265 [info]: frame B:   1091, Avg QP:37.73  kb/s: 8003.99
x265 [info]: Weighted P-Frames: Y:11.6% UV:9.4%

encoded 1439 frames in 937.04s (1.54 fps), 11962.94 kb/s, Avg QP:37.09

Tom Vaughan
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] FFMPEG support for x265 vbv-end and vbv-end-fr-adj
  2024-05-01 21:10 [FFmpeg-devel] FFMPEG support for x265 vbv-end and vbv-end-fr-adj Tom Vaughan
@ 2024-05-15 12:59 ` Michael Niedermayer
  2024-06-05 18:19   ` Tom Vaughan
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Niedermayer @ 2024-05-15 12:59 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 2022 bytes --]

On Wed, May 01, 2024 at 09:10:51PM +0000, Tom Vaughan wrote:
> When I attempt to pass vbv-end and vbv-end-fr-adj parameters to x265, FFMPEG fails.
> 
> x265 [error]: vbv-end-fr-adj cannot be enabled when total number of frames is unknown
> 
> x265 needs to know how many frames it is encoding so that it knows when the vbv-end logic needs to kick in. In this case it would be after 96% of the source video is encoded. Despite specifying a duration of 30 seconds ( -t 30 ) on both input and output (using a 60 second source video), x265 does not know the total number of frames (but FFMPEG surely does).
> 
> ffmpeg -i test_uhdsdr_1min.mov -t 30 -an -sn -dn -c:v libx265 -b:v 12000k -maxrate 8M -bufsize 18M -x265-params vbv-init=0.9:vbv-end=0.9:vbv-end-fr-adj=.96:rc-lookahead=48:qg-size=32:scenecut=0:no-open-gop=1:frame-threads=0:repeat-headers=1:nr-inter=400:nr-intra=100:psy-rd=0:cbqpoffs=0:crqpoffs=3 -t 30 test_uhdsdr_96.mp4

you can specify total_frames along with vbv-end-fr

there is in general not a 1:1 correspondance between duration and the number of frames
the frame rate may vary, there may be skiped frames or damaged frames that
where lost and so on.

in case of some 2 pass mode it should be possible to get the exact number of frames
in the 2nd pass.
Otherwise my gut feelng is that a time based instead of a frame number based
threshold would have been easier to work with

if you are thinking that the total frame number should be set automatically
and not by hand. I agree, its just not easy to do that in all cases.
It could maybe be done in specific cases but in the general case
it would need 2 passes to be reliable.

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [FFmpeg-devel] FFMPEG support for x265 vbv-end and vbv-end-fr-adj
  2024-05-15 12:59 ` Michael Niedermayer
@ 2024-06-05 18:19   ` Tom Vaughan
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Vaughan @ 2024-06-05 18:19 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Michael - Sorry I missed your response on 5/15. I led the x265 project from 2013 to 2018, and I helped to define this feature, but I can't speak for the x265 development team today. I could put you directly in touch with the x265 developers at Multicoreware to work this out. I will also encourage them to respond to this thread directly on the FFMPEG-devel mailing list.

Speaking as an end-user, I don't think we require frame-accurate precision. The vbv-end-fr-adj value specifies the point at which the vbv-end logic is activated. vbv-end-fr-adj is a value between 0 and 1, but should always be less than 1. Multiply vbv-end-fr-adj by 100 to get the % of the transcoding job in time where the vbv-end feature needs to be triggered. A flag that is passed from FFMPEG to x265 at this point would work. I'm aware of the challenges of frame-rate accuracy when transcoding. I would say that a "best effort" from FFMPEG to trigger the signal at the right point is good enough. Non-decodable frames should count as if they were decodable, to not throw off the time calculation.

As an example, if someone is chunking the encoding of a video title into 300 second chunks, and they want the vbv-end enforcement to start 15 seconds before the end of the chunk encode, they would use vbv-end-fr-adj 0.95. When x265 gets to the last 5% of the encode (last 15 seconds), vbv-end logic would be activated. 1 or 2 frames inaccuracy won't matter.

Thanks,
Tom

On 5/15/24, 5:59 AM, "ffmpeg-devel on behalf of Michael Niedermayer" <ffmpeg-devel-bounces@ffmpeg.org <mailto:ffmpeg-devel-bounces@ffmpeg.org> on behalf of michael@niedermayer.cc <mailto:michael@niedermayer.cc>> wrote:


On Wed, May 01, 2024 at 09:10:51PM +0000, Tom Vaughan wrote:
> When I attempt to pass vbv-end and vbv-end-fr-adj parameters to x265, FFMPEG fails.
> 
> x265 [error]: vbv-end-fr-adj cannot be enabled when total number of frames is unknown
> 
> x265 needs to know how many frames it is encoding so that it knows when the vbv-end logic needs to kick in. In this case it would be after 96% of the source video is encoded. Despite specifying a duration of 30 seconds ( -t 30 ) on both input and output (using a 60 second source video), x265 does not know the total number of frames (but FFMPEG surely does).
> 
> ffmpeg -i test_uhdsdr_1min.mov -t 30 -an -sn -dn -c:v libx265 -b:v 12000k -maxrate 8M -bufsize 18M -x265-params vbv-init=0.9:vbv-end=0.9:vbv-end-fr-adj=.96:rc-lookahead=48:qg-size=32:scenecut=0:no-open-gop=1:frame-threads=0:repeat-headers=1:nr-inter=400:nr-intra=100:psy-rd=0:cbqpoffs=0:crqpoffs=3 -t 30 test_uhdsdr_96.mp4


you can specify total_frames along with vbv-end-fr


there is in general not a 1:1 correspondance between duration and the number of frames
the frame rate may vary, there may be skiped frames or damaged frames that
where lost and so on.


in case of some 2 pass mode it should be possible to get the exact number of frames
in the 2nd pass.
Otherwise my gut feelng is that a time based instead of a frame number based
threshold would have been easier to work with


if you are thinking that the total frame number should be set automatically
and not by hand. I agree, its just not easy to do that in all cases.
It could maybe be done in specific cases but in the general case
it would need 2 passes to be reliable.


thx


[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB


Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-05 18:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-01 21:10 [FFmpeg-devel] FFMPEG support for x265 vbv-end and vbv-end-fr-adj Tom Vaughan
2024-05-15 12:59 ` Michael Niedermayer
2024-06-05 18:19   ` Tom Vaughan

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git