Opened 14 months ago

Last modified 14 months ago

#11613 reopened defect

ffv1_vulkan and level 4 does not work well

Reported by: Andrew-R Owned by:
Priority: normal Component: avformat
Version: git-master Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

bash-5.1$ RADV_PERFTEST=video_decode ~/bin/ffmpeg8-vk -init_hw_device vulkan -hwaccel vulkan -hwaccel_output_format vulkan  -i ~/6029.mp4 -an -c:v ffv1_vulkan -level 4 -strict -2  -vframes 1000 frame-ffv1-vulkan.mkv
ffmpeg version N-118546-g903b085f91 Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 11.2.0 (GCC)
  configuration: --enable-opencl --disable-debug --enable-libx265 --enable-libx264 --enable-gpl --enable-libplacebo --enable-vulkan --enable-libshaderc --enable-libzimg --enable-libaom --enable-libdav1d --enable-libsoxr --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gnutls --enable-libass --enable-libbluray --enable-libcdio --enable-frei0r --enable-libgsm --enable-openal --enable-libopus --enable-librtmp --enable-libsnappy --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp
  libavutil      60.  3.100 / 60.  3.100
  libavcodec     62.  3.101 / 62.  3.101
  libavformat    62.  0.102 / 62.  0.102
  libavdevice    62.  0.100 / 62.  0.100
  libavfilter    11.  0.100 / 11.  0.100
  libswscale      9.  0.100 /  9.  0.100
  libswresample   6.  0.100 /  6.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/guest/6029.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    creation_time   : 2011-06-24T09:52:37.000000Z
    encoder         : HandBrake 0.9.5 2011043000
  Duration: 01:28:31.60, start: 0.000000, bitrate: 789 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/smpte170m/bt709, progressive), 720x400, 657 kb/s, 25 fps, 25 tbr, 90k tbn (default)
    Metadata:
      creation_time   : 2011-06-24T09:52:37.000000Z
      vendor_id       : [0][0][0][0]
      encoder         : JVT/AVC Coding
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 2011-06-24T09:52:37.000000Z
      vendor_id       : [0][0][0][0]
File 'frame-ffv1-vulkan.mkv' already exists. Overwrite? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> ffv1 (ffv1_vulkan))
Press [q] to stop, [?] for help
[ffv1_vulkan @ 0xc85f1c0] Async buffers: 0MiB per context, 0MiB total, depth: 1
Output #0, matroska, to 'frame-ffv1-vulkan.mkv':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: mp42isomavc1
    encoder         : Lavf62.0.102
  Stream #0:0(und): Video: ffv1 (FFV1 / 0x31564646), vulkan(tv, smpte170m/smpte170m/bt709, progressive), 720x400, q=2-31, 200 kb/s, 25 fps, 1k tbn (default)
    Metadata:
      encoder         : Lavc62.3.101 ffv1_vulkan
      creation_time   : 2011-06-24T09:52:37.000000Z
      vendor_id       : [0][0][0][0]
[out#0/matroska @ 0xc85d980] video:83357KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 0.053416%
frame= 1000 fps= 44 q=-0.0 Lsize=   83402KiB time=00:00:40.00 bitrate=17080.6kbits/s speed=1.77x elapsed=0:00:22.62


Resulting file is uplayable:

bash-5.1$ mpv frame-ffv1-vulkan.mkv
 (+) Video --vid=1 (*) (ffv1 720x400 25.000fps)
[ffmpeg/video] ffv1: CRC mismatch 1ED3EEA2!
Could not open codec.
Decoder init failed for ffv1
Failed to initialize a decoder for codec 'ffv1'.
Video: no video
No video or audio streams selected.
Exiting... (Errors when loading file)

Note that same problem seem to exist in sw ffv1 encoder.

Without -level 4 Vulkan encoder complains:

[ffv1_vulkan @ 0xc8e2b80] Encoding frames with subsampling and unaligned dimensions is only supported in version 4 (-level 4)

while sw encoder works fine.

Change History (8)

comment:1 by Lynne, 14 months ago

Note that same problem seem to exist in sw ffv1 encoder.

Then it's not really a vulkan encoder issue, is it?

These fix it.
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-May/344097.html

comment:2 by Andrew-R, 14 months ago

Even with slicecrc 1 or slicecrc 0 (as suggested on IRC) it stil produces broken (mostly green) image.

Ah, moment will check link

in reply to:  1 comment:3 by Andrew-R, 14 months ago

Replying to Lynne:

Note that same problem seem to exist in sw ffv1 encoder.

Then it's not really a vulkan encoder issue, is it?

These fix it.
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-May/344097.html

you mean
https://ffmpeg.org/pipermail/ffmpeg-devel/2025-May/344155.html
"[FFmpeg-devel] [PATCH] avcodec/ffv1enc: Fix explicitly set -slicecrc 2" ?

comment:5 by mkver, 14 months ago

Component: avcodecavformat
Resolution: fixed
Status: newclosed

Should be fixed in 92e310eb82e04713e55d248b65c22f0eb95afada. Reopen if not.

comment:6 by Andrew-R, 14 months ago

well, ffplay in ffmpeg 92e310eb82e04713e55d248b65c22f0eb95afada indeed can play mkv encoded by command in this ticket. Yet older ffv1 decoders (ffmpeg 4.4.6 for example) just show crc error :(

comment:7 by Andrew-R, 14 months ago

It seems that ffv1_vulkan outputs

bash-5.1$ mediainfo  frame-ffv1-vulkan.avi
General
Complete name                            : frame-ffv1-vulkan.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 81.4 MiB
Duration                                 : 40 s 0 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 17.1 Mb/s
Frame rate                               : 25.000 FPS
Writing application                      : Lavf62.0.102

Video
ID                                       : 0
Format                                   : FFV1
Format version                           : Version 4.3
Codec ID                                 : FFV1
Duration                                 : 40 s 0 ms
Bit rate mode                            : Variable
Bit rate                                 : 17.1 Mb/s
Width                                    : 720 pixels
Height                                   : 400 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 FPS
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 2.371
Stream size                              : 81.4 MiB (100%)
Conformance errors                       : 1
 HEADER                                  : Yes
  version                                : Yes
   LATERVERSION                          : LATERVERSION (conf, offset 0xD4)

FFV1 v 4.3

and software ffv1 encoder does

bash-5.1$ mediainfo  frame-ffv1.avi
General
Complete name                            : frame-ffv1.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 55.4 MiB
Duration                                 : 40 s 0 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 11.6 Mb/s
Frame rate                               : 25.000 FPS
Writing application                      : Lavf62.0.102

Video
ID                                       : 0
Format                                   : FFV1
Format version                           : Version 3.4
Format settings, Slice count             : 4 slices per frame
Codec ID                                 : FFV1
Duration                                 : 40 s 0 ms
Bit rate mode                            : Variable
Bit rate                                 : 11.6 Mb/s
Width                                    : 720 pixels
Height                                   : 400 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossless
Bits/(Pixel*Frame)                       : 1.612
Stream size                              : 55.4 MiB (100%)
coder_type                               : Golomb Rice
ErrorDetectionType                       : Per slice

FFV1 version 3.4/Colomb

So, without any option sw encoded ffv1 plays in earlier ffmpeg/mpv and hw encoded ffv1 only plays in new ffplay (and may be mpv linked to it)

comment:8 by Andrew-R, 14 months ago

Resolution: fixed
Status: closedreopened
Note: See TracTickets for help on using tickets.