alexheretic / ab-av1

AV1 re-encoding using ffmpeg, svt-av1 & vmaf.
MIT License
378 stars 27 forks source link

(crf 18, VMAF -1.00, size 69%)Error: Failed to find a suitable crf #207

Closed allrobot closed 1 day ago

allrobot commented 2 weeks ago
D:\>ab-av1 auto-encode -i "20240107-06_カズサとあけおめックス.mp4" --preset 4 --svt tune=0 --pix-format yuv420p10le --max-crf 60 --min-crf 18  --min-vmaf 95 
Encoding F:\BaiduNetdiskDownload\20240615\カズサとあけおめックス\20240107-06_カズサとあけおめッ クス 
Searching 00:54:05 #################################################################### (crf 18, VMAF -1.00, size 69%)Error: Failed to find a suitable crf                                                                                   )
Stack backtrace:
   0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: BaseThreadInitThunk
   9: RtlUserThreadStart
  1. The VMAF calculation result shows -1 instead of a positive integer of xx, which should be a BUG.
  2. When I drag the edge to resize the command prompt window, it becomes very ugly in style. image
mr44er commented 2 weeks ago

Maybe some error with the charset, on my box I see only empty glyphs, characters only visible in the screenshot. Could you retry with latin only? For example: F:\BaiduNetdiskDownload\20240615\myfolder\20240107-06_myfile.mp4

alexheretic commented 2 weeks ago

It seems no vmaf result could be parsed vmaf command output, yet it also did not fail.

Can you try installing the latest git version and run with the new logging, e.g. set RUST_LOG=ab_av1=debug. This should print out the full ffmpeg vmaf command which you can then run independently to see the output. This may suggest why it cannot be parsed.

alexheretic commented 2 weeks ago

I've done a little more work to improve this so this scenario should produce a ffmpeg vmaf error showing the output instead of a -1.0 score.

allrobot commented 1 week ago

I've done a little more work to improve this so this scenario should produce a ffmpeg vmaf error showing the output instead of a -1.0 score.

I use cargo install --git https://github.com/alexheretic/ab-av1.Reinstalling ab-av1 this time did not result in the -1.0 issue; if a bug occurs next time, I will be reported.(I cannot determine what caused the error.)

Maybe some error with the charset, on my box I see only empty glyphs, characters only visible in the screenshot. Could you retry with latin only?

You can try chcp 65001

allrobot commented 4 days ago

While batch encoding some videos overnight, the command ran successfully with FFmpeg processing the video frames, but the VMAF score was not displayed in the output. The program then threw an error, indicating an inability to parse FFmpeg's VMAF score.

subprocess.run(f'ab-av1 auto-encode -i "{old_file}" --preset 5 --svt tune=0  --svt film-grain=4 --svt film-grain-denoise=0 --pix-format yuv420p10le --max-crf 60 --min-crf 5 --min-vmaf 94',shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True,encoding='utf-8')

report

2024-07-08 01:00:40 - ERROR - ----------------------------------------------------------------------------------------------------
压缩视频出错: F:\BaiduNetdiskDownload\2D动画\[2D动画] laomeng到A62视频合集 (度盘 42.73GB)\A11 崩三 黑曼巴之影_1.mp4
[2024-07-07T16:58:18Z INFO  ab_av1::command::sample_encode] encoding sample 1/1 crf 32
[2024-07-07T16:58:34Z INFO  ab_av1::command::sample_encode] 51%, 18 fps, eta 16 seconds
[2024-07-07T16:58:50Z INFO  ab_av1::command::sample_encode] 74%, 14 fps, eta 11 seconds
[2024-07-07T16:59:01Z INFO  ab_av1::vmaf] vmaf A11 崩三 黑曼巴之影_1.sample2+600f.av1.crf32.5.mp4 vs reference A11 崩三 黑曼巴之影_1.sample2+600f.mkv
[2024-07-07T16:59:07Z INFO  ab_av1::command::sample_encode] crf 32 VMAF 97.57 predicted video stream size 6.72 MiB (36%) taking 54 seconds
[2024-07-07T16:59:07Z INFO  ab_av1::command::sample_encode] encoding sample 1/1 crf 46
[2024-07-07T16:59:23Z INFO  ab_av1::command::sample_encode] 52%, 19 fps, eta 15 seconds
[2024-07-07T16:59:39Z INFO  ab_av1::command::sample_encode] 78%, 14 fps, eta 9 seconds
[2024-07-07T16:59:48Z INFO  ab_av1::vmaf] vmaf A11 崩三 黑曼巴之影_1.sample2+600f.av1.crf46.5.mp4 vs reference A11 崩三 黑曼巴之影_1.sample2+600f.mkv
[2024-07-07T16:59:54Z INFO  ab_av1::command::sample_encode] crf 46 VMAF 88.23 predicted video stream size 2.72 MiB (15%) taking 52 seconds
[2024-07-07T16:59:54Z INFO  ab_av1::command::sample_encode] encoding sample 1/1 crf 37
[2024-07-07T17:00:10Z INFO  ab_av1::command::sample_encode] 52%, 19 fps, eta 15 seconds
[2024-07-07T17:00:26Z INFO  ab_av1::command::sample_encode] 79%, 15 fps, eta 9 seconds
[2024-07-07T17:00:34Z INFO  ab_av1::vmaf] vmaf A11 崩三 黑曼巴之影_1.sample2+600f.av1.crf37.5.mp4 vs reference A11 崩三 黑曼巴之影_1.sample2+600f.mkv
Error: could not parse ffmpeg vmaf score
----cmd-----
ffmpeg -r 24 -i C:\Users\Administrator\Personal_scripts\Python\PythonScripts\PythonScripts\src\.ab-av1-RM46M2PZOVjb\A11 崩三 黑曼巴之影_1.sample2+600f.av1.crf37.5.mp4 -r 24 -i C:\Users\Administrator\Personal_scripts\Python\PythonScripts\PythonScripts\src\.ab-av1-RM46M2PZOVjb\A11 崩三 黑曼巴之影_1.sample2+600f.mkv -filter_complex [0:v]format=yuv420p10le,scale=-1:1080:flags=bicubic,setpts=PTS-STARTPTS[dis];[1:v]format=yuv420p10le,scale=-1:1080:flags=bicubic,setpts=PTS-STARTPTS[ref];[dis][ref]libvmaf=n_threads=16 -f null -
---stderr---
le-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Administrator\Personal_scripts\Python\PythonScripts\PythonScripts\src\.ab-av1-RM46M2PZOVjb\A11 崩三 黑曼巴之影_1.sample2+600f.av1.crf37.5.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Project 1
    date            : 2019-07-11
    encoder         : Lavf61.1.100
  Duration: 00:00:20.00, start: 0.000000, bitrate: 1562 kb/s
  Stream #0:0[0x1](und): Video: av1 (libdav1d) (Main) (av01 / 0x31307661), yuv420p10le(tv, progressive), 1000x696, 1560 kb/s, SAR 1:1 DAR 125:87, 30 fps, 30 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : VideoHandler
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.3.100 libsvtav1
Input #1, matroska,webm, from 'C:\Users\Administrator\Personal_scripts\Python\PythonScripts\PythonScripts\src\.ab-av1-RM46M2PZOVjb\A11 崩三 黑曼巴之影_1.sample2+600f.mkv':
  Metadata:
    title           : Project 1
    DATE            : 2019-07-11
    MAJOR_BRAND     : isom
    MINOR_VERSION   : 512
    COMPATIBLE_BRANDS: isomiso2mp41
    ENCODER         : Lavf61.1.100
  Duration: 00:00:20.00, start: 0.000000, bitrate: 6114 kb/s
  Stream #1:0: Video: mpeg4 (Simple Profile), yuv420p, 1000x696 [SAR 1:1 DAR 125:87], 30 fps, 30 tbr, 1k tbn (default)
      Metadata:
        HANDLER_NAME    : VideoHandler
        VENDOR_ID       : [0][0][0][0]
        DURATION        : 00:00:20.000000000
Stream mapping:
  Stream #0:0 (libdav1d) -> format:default
  Stream #1:0 (mpeg4) -> format:default
  libvmaf:default -> Stream #0:0 (wrapped_avframe)
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomav01iso2mp41
    title           : Project 1
    date            : 2019-07-11
    encoder         : Lavf61.1.100
  Stream #0:0: Video: wrapped_avframe, yuv420p10le(tv, progressive), 1552x1080 [SAR 5625:5626 DAR 125:87], q=2-31, 200 kb/s, 24 tbn
      Metadata:
        encoder         : Lavc61.3.100 wrapped_avframe
frame=   48 fps=0.0 q=-0.0 size=N/A time=00:00:01.95 bitrate=N/A speed=3.79x    
frame=  101 fps= 97 q=-0.0 size=N/A time=00:00:04.16 bitrate=N/A speed=   4x    
frame=  156 fps=100 q=-0.0 size=N/A time=00:00:06.45 bitrate=N/A speed=4.14x    
frame=  209 fps=101 q=-0.0 size=N/A time=00:00:08.66 bitrate=N/A speed= 4.2x    
frame=  264 fps=102 q=-0.0 size=N/A time=00:00:10.95 bitrate=N/A speed=4.23x    
frame=  319 fps=103 q=-0.0 size=N/A time=00:00:13.25 bitrate=N/A speed=4.26x    
frame=  373 fps=103 q=-0.0 size=N/A time=00:00:15.50 bitrate=N/A speed=4.27x    
frame=  429 fps=103 q=-0.0 size=N/A time=00:00:17.83 bitrate=N/A speed= 4.3x    
frame=  482 fps=103 q=-0.0 size=N/A time=00:00:20.04 bitrate=N/A speed=4.29x    
frame=  536 fps=104 q=-0.0 size=N/A time=00:00:22.29 bitrate=N/A speed=4.31x    
frame=  589 fps=103 q=-0.0 size=N/A time=00:00:24.50 bitrate=N/A speed= 4.3x    
[Parsed_libvmaf_6 @ 000002b296bac480] VMAF score: 94.826380
[out#0/null @ 000002b2916f8b80] video:258KiB audio:0KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: unknown
frame=  600 fps=102 q=-0.0 Lsize=N/A time=00:00:24.95 bitrate=N/A speed=4.24x
------------

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

error_log.txt

alexheretic commented 4 days ago

Thanks for following up. It looks like the new reporting is paying off, showing that the way we read the chunks streamed from the ffmpeg output means we are not properly finding the vmaf score even though it is there and ffmpeg worked fine.

I've pushed accc5e5 which should address this. I'll release towards the end of the week.

allrobot commented 3 days ago

could not parse ffmpeg vmaf score

You can download this video for testing (NSFW): https://www.mediafire.com/file/1s6geexrc22yiaf/A11+崩三+黑曼巴之影_1.zip/file

alexheretic commented 1 day ago

This should now be fixed in v0.7.16. Please re-open or raise a new issue if you encounter more problems.