mikigal / Anime4K-GUI

GUI application for Anime4K shaders which allows to save upscaled video to disk
90 stars 7 forks source link

[Error] When Converting .mkv with embeded fonts (-c:s mov_text) #13

Closed Middlepepper closed 9 months ago

Middlepepper commented 9 months ago

Hi Mikigal,

I've done some testing and it looks like there are issue with processing anime with .ass subtitles and .ttf attachments.

I've used the same video file but removed the .ass subtitle and .ttf attachments it appears to covert without issue even if there are still attachment to the .MKV container.

See the log below.

Command from logs

ffmpeg.exe -hide_banner -y -hwaccel_device cuda -hwaccel_output_format cuda -i 1.mkv -init_hw_device vulkan -vf format=yuv420p,hwupload,libplacebo=w=1440:h=1080:upscaler=ewa_lanczos:custom_shader_path=shaders/Anime4K_ModeA.glsl,hwdownload,format=yuv420p -c:a copy -c:s mov_text -map 0 -c:v h264_nvenc -preset slow 1_upscaled.mkv

[matroska @ 000001d46672ae40] Subtitle codec 94213 is not supported.
[out#0/matroska @ 000001d4653630c0] Could not write header (incorrect codec parameters ?): Function not implemented
[vf#0:2 @ 000001d466e82e40] Error sending frames to consumers: Function not implemented
[vf#0:2 @ 000001d466e82e40] Task finished with error code: -40 (Function not implemented)
[vf#0:2 @ 000001d466e82e40] Terminating thread with return code -40 (Function not implemented)
[out#0/matroska @ 000001d4653630c0] 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!
Middlepepper commented 9 months ago

Running the command manually I think this is a issue from the -c:s mov_text, running the command manually I've swapped it with -c:s copy which seems to work.

mikigal commented 9 months ago

Hi, copying subtitlies stream caused similar issue with other subtitles format. I found using mov_text is most compatible. Do you know any way to make it working with all subtitles codecs?

Middlepepper commented 9 months ago

I've had a look online and all I can find is "-map 0:s -c:s copy" as the most recommend option for copying subtitles, So maybe it worth giving that a try or adding in a new toggle in the GUI.

Maybe since this is anime focus we can do something like below?

ffmpeg.exe -hide_banner -i input.mkv  -y -hwaccel_device cuda -hwaccel_output_format cuda -i input.mkv -init_hw_device vulkan -vf format=yuv420p,hwupload,libplacebo=w=1440:h=1080:upscaler=ewa_lanczos:custom_shader_path=shaders/Anime4K_ModeA.glsl,hwdownload,format=yuv420p  -map 0 -c:v h264_nvenc -preset slow -c:a copy -c:s copy -c:d copy output.mkv

the changes are -c:a copy -c:s copy -c:d copy

This command does the following: -c:a copy: Copies the audio stream without transcoding. -c:s copy: Copies the subtitle streams without transcoding. -c:d copy: Copies the data streams (attachments) without transcoding. (for Fonts)

If you have any example files which has issue with -c:s copy I can try playing around and see what issue happened.

mikigal commented 9 months ago

I will try combining copying subtitles AND data streams, maybe it will help. Can I send you version for testing?

Middlepepper commented 9 months ago

Sure happy to help with testing. Do you want a email to send it to or should I just check for a testing branch.

mikigal commented 9 months ago

@Middlepepper Please simply replace exe from latest release to this one (it's zip as GitHub does not allow to put exe to attachement) This version also have implemented CRF setting in GUI but it shouldn't have any impact to subtitles streams Let me know about results

Streams' parameters in this version:

"-c:a", "copy", // Copy all audio streams
"-c:s", "copy", // Copy all subtitles streams
"-c:d", "copy", // Copy all data streams
"-map", "0", // Map all streams

Anime4K-GUI.zip

Middlepepper commented 9 months ago

Running through a show now , Looks like it working but the progress bar seems to be locked on 0%, I'm just letting it run through a show will report back.

Edit: Looks like it is working just fine excluding the lack of progress bar, It seems to be adding Tags to the upscaled file though not sure if that just normal. I've never used that feature.

Edit2: I think the tags are just from the encoder from my googles so nothing major.

Original image

Upscale image

mikigal commented 9 months ago

EDIT: This problem exists happens only when trying to save file into MP4. When I use MKV as output everything works. I look MP4 simply does not support ASS

I tested this this changes with my file and it does not work. When I used mov_text it worked with this file correctly. Do you have any idea about that? It looks subs are in ASS format

Logs:

[22:41:04] FFMPEG logs:
[22:41:04] Input #0, matroska,webm, from 'D:\Evangelion\Evangelion 3.33 You Can (Not) Redo.mkv':
  Metadata:
    title           : Evangelion 3.33: You Can (Not) Redo
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2013-05-12T17:35:12.000000Z
  Duration: 01:35:31.43, start: 0.000000, bitrate: 6263 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 12.292000
      Metadata:
        title           : 01: EIRIN
    Chapter #0:1: start 12.292000, end 26.542000
      Metadata:
        title           : 02: TOEI
    Chapter #0:2: start 26.542000, end 32.709000
      Metadata:
        title           : 03: T-JOY
    Chapter #0:3: start 32.709000, end 202.209000
      Metadata:
        title           : 04: studio khara
    Chapter #0:4: start 202.209000, end 310.125000
      Metadata:
        title           : 05: 3EM01_EM20_Master
    Chapter #0:5: start 310.125000, end 546.625000
      Metadata:
        title           : 06: 3EM02_C17B_Nu_test02
    Chapter #0:6: start 546.625000, end 641.542000
      Metadata:
        title           : 07: 3EM03_P_131_2dames
    Chapter #0:7: start 641.542000, end 774.209000
      Metadata:
        title           : 08: 3EM04_EM10A_Q
    Chapter #0:8: start 774.209000, end 1017.792000
      Metadata:
        title           : 09: 3EM05_1125
    Chapter #0:9: start 1017.792000, end 1232.792000
      Metadata:
        title           : 10: 3EM06_C_16_take2
    Chapter #0:10: start 1232.792000, end 1498.750000
      Metadata:
        title           : 11: 3EM07_C_15_take2
    Chapter #0:11: start 1498.750000, end 1622.625000
      Metadata:
        title           : 12: 3EM08_SS_103_junko
    Chapter #0:12: start 1622.625000, end 1742.917000
      Metadata:
        title           : 13: 3EM09_P_83_2dames_mx3
    Chapter #0:13: start 1742.917000, end 1971.042000
      Metadata:
        title           : 14: 3EM10_1176_long_end
    Chapter #0:14: start 1971.042000, end 2069.375000
      Metadata:
        title           : 15: Main Title
    Chapter #0:15: start 2069.375000, end 2190.750000
      Metadata:
        title           : 16: 3EM11_QuatreMains_E_03_mx3
    Chapter #0:16: start 2190.750000, end 2259.542000
      Metadata:
        title           : 17: 3EM12_SS_101_2femmes_option
    Chapter #0:17: start 2259.542000, end 2478.875000
      Metadata:
        title           : 18: 3EM13_Guitar_ForQ
    Chapter #0:18: start 2478.875000, end 2518.834000
      Metadata:
        title           : 19: 3EM14_Piano_Adlib44
    Chapter #0:19: start 2518.834000, end 2555.125000
      Metadata:
        title           : 20: 3EM15_pre
    Chapter #0:20: start 2555.125000, end 2669.834000
      Metadata:
        title           : 21: 3EM15_QuatreMains_Fun_07_edit_B
    Chapter #0:21: start 2669.834000, end 2752.334000
      Metadata:
        title           : 22: 3EM16_QuatreMains_60sec
    Chapter #0:22: start 2752.334000, end 2886.209000
      Metadata:
        title           : 23: 3EM17_SS_106_female
    Chapter #0:23: start 2886.209000, end 3019.459000
      Metadata:
        title           : 24: 3EM18_P_140_70bpm
    Chapter #0:24: start 3019.459000, end 3179.709000
      Metadata:
        title           : 25: 3EM19_Omni_09
    Chapter #0:25: start 3179.709000, end 3356.542000
      Metadata:
        title           : 26: Eye Catch
    Chapter #0:26: start 3356.542000, end 3538.167000
      Metadata:
        title           : 27: 3EM20_P_56_A4_orch+piano
    Chapter #0:27: start 3538.167000, end 3645.834000
      Metadata:
        title           : 28: 3EM21_P_57_A4_2files+1
    Chapter #0:28: start 3645.834000, end 3654.250000
      Metadata:
        title           : 29: 3EM21A_QuatreMains_G
    Chapter #0:29: start 3654.250000, end 3874.500000
      Metadata:
        title           : 30: 3EM22_SS_101_Orch
    Chapter #0:30: start 3874.500000, end 4121.000000
      Metadata:
        title           : 31: 3EM23_1128_take4_360
    Chapter #0:31: start 4121.000000, end 4317.875000
      Metadata:
        title           : 32: 3EM24_SD2_01_take3_360
    Chapter #0:32: start 4317.875000, end 4450.667000
      Metadata:
        title           : 33: 3EM25_SD2_53_take3_IntroStart
    Chapter #0:33: start 4450.667000, end 4648.709000
      Metadata:
        title           : 34: 3EM26_1155_139_take4
    Chapter #0:34: start 4648.709000, end 4812.959000
      Metadata:
        title           : 35: 3EM27_Beethoven9_Orch+Cho
    Chapter #0:35: start 4812.959000, end 5013.167000
      Metadata:
        title           : 36: 3EM28_Nu09_360
    Chapter #0:36: start 5013.167000, end 5162.875000
      Metadata:
        title           : 37: 3EM30_GuitarForQ_Pno_Vo_Orch+Pno
    Chapter #0:37: start 5162.875000, end 5425.334000
      Metadata:
        title           : 38: 3EM31_1120_360
    Chapter #0:38: start 5425.334000, end 5703.167000
      Metadata:
        title           : 39: Sakura Nagashi 「桜流し」 / Utada Hikaru
    Chapter #0:39: start 5703.167000, end 5731.434000
      Metadata:
        title           : 40: 3EM32_F02
  Stream #0:0(jpn): Video: h264 (High 10), yuv420p10le(progressive), 1280x542, SAR 1:1 DAR 640:271, 24 fps, 24 tbr, 1k tbn (default)
  Stream #0:1(pol): Subtitle: ass (default) (forced)
      Metadata:
        title           : by groozin
  Stream #0:2(jpn): Audio: aac (LC), 48000 Hz, 5.1, fltp (default)
  Stream #0:3(eng): Subtitle: ass
  Stream #0:4: Attachment: otf
      Metadata:
        filename        : AGaramondPro-Regular.otf
        mimetype        : application/vnd.ms-opentype
  Stream #0:5: Attachment: ttf
      Metadata:
        filename        : FOT-MatElegProB-CP.ttf
        mimetype        : application/x-truetype-font
  Stream #0:6: Attachment: ttf
      Metadata:
        filename        : FOT-MatisseElegantoProQ-EB.ttf
        mimetype        : application/x-truetype-font
  Stream #0:7: Attachment: ttf
      Metadata:
        filename        : GARA.TTF
        mimetype        : application/x-truetype-font
  Stream #0:8: Attachment: ttf
      Metadata:
        filename        : GARABD.TTF
        mimetype        : application/x-truetype-font
  Stream #0:9: Attachment: ttf
      Metadata:
        filename        : GARAIT.TTF
        mimetype        : application/x-truetype-font
  Stream #0:10: Attachment: otf
      Metadata:
        filename        : AGaramondPro-Bold.otf
        mimetype        : application/vnd.ms-opentype
  Stream #0:11: Attachment: otf
      Metadata:
        filename        : AGaramondPro-BoldItalic.otf
        mimetype        : application/vnd.ms-opentype
  Stream #0:12: Attachment: otf
      Metadata:
        filename        : AGaramondPro-Italic.otf
        mimetype        : application/vnd.ms-opentype
  Stream #0:13: Attachment: ttf
      Metadata:
        filename        : 9SALERNO.TTF
        mimetype        : application/x-truetype-font
  Stream #0:14: Attachment: ttf
      Metadata:
        filename        : FOT-MatElegProB-CP.ttf
        mimetype        : application/x-truetype-font
  Stream #0:15: Attachment: ttf
      Metadata:
        filename        : FOT-MatisseElegantoProQ-EB.ttf
        mimetype        : application/x-truetype-font
  Stream #0:16: Attachment: ttf
      Metadata:
        filename        : Francis.ttf
        mimetype        : application/x-truetype-font
  Stream #0:17: Attachment: ttf
      Metadata:
        filename        : KGThisIsNotGoodbye.ttf
        mimetype        : application/x-truetype-font
  Stream #0:18: Attachment: ttf
      Metadata:
        filename        : KozMinPr6N-Bold-En.otf
        mimetype        : application/x-truetype-font
  Stream #0:19: Attachment: ttf
      Metadata:
        filename        : Long Island.ttf
        mimetype        : application/x-truetype-font
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (copy)
  Stream #0:2 -> #0:2 (copy)
  Stream #0:3 -> #0:3 (copy)
  Stream #0:4 -> #0:4 (copy)
  Stream #0:5 -> #0:5 (copy)
  Stream #0:6 -> #0:6 (copy)
  Stream #0:7 -> #0:7 (copy)
  Stream #0:8 -> #0:8 (copy)
  Stream #0:9 -> #0:9 (copy)
  Stream #0:10 -> #0:10 (copy)
  Stream #0:11 -> #0:11 (copy)
  Stream #0:12 -> #0:12 (copy)
  Stream #0:13 -> #0:13 (copy)
  Stream #0:14 -> #0:14 (copy)
  Stream #0:15 -> #0:15 (copy)
  Stream #0:16 -> #0:16 (copy)
  Stream #0:17 -> #0:17 (copy)
  Stream #0:18 -> #0:18 (copy)
  Stream #0:19 -> #0:19 (copy)
Press [q] to stop, [?] for help
[mp4 @ 000001e341d92e40] Could not find tag for codec ass in stream #1, codec not currently supported in container
[out#0/mp4 @ 000001e34bf20440] Could not write header (incorrect codec parameters ?): Invalid argument
[vf#0:0 @ 000001e348cea7c0] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 000001e348cea7c0] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 000001e348cea7c0] Terminating thread with return code -22 (Invalid argument)
[out#0/mp4 @ 000001e34bf20440] 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!
mikigal commented 9 months ago

Fixed in https://github.com/mikigal/Anime4K-GUI/commit/fa44f9d48c50a0ba17e34adedfbf2a8199b983da