mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.5k stars 206 forks source link

Embed subtitles srt. #1710

Closed ClankJake closed 2 months ago

ClankJake commented 2 months ago

Describe the bug Hello dev. I've been using your tool for some time. And this week I started embedding srt subtitles in my mkvs. I have noticed that the subtitles are missing some dialogue when going through the embedding process. I thought it was the subtitles that were saying the dialogue but I compared it with the subtitle before embedding and with the subtitle that was embedded. I tested with other versions of ffmpeg using your tool and the same error occurred and I tested directly through ffmpeg and the subtitles were embedded correctly.

autoProcess.ini settings [Subtitle] codec = srt, ass codec-image-based = dvd_subtitle, dvdsub, hdmv_pgs_subtitle languages = por default-language = por first-stream-of-language = False encoding = burn-subtitles = False burn-dispositions = embed-subs = True embed-image-subs = True embed-only-internal-subs = False filename-dispositions = forced ignore-embedded-subs = False ignored-dispositions = unique-dispositions = False attachment-codec = ttf, otf, unknown, TTF, OTF force-default = False include-original-language = False remove-bitstream-subs = False

Log files 2024-04-21 17:44:22 - MANUAL - INFO - Reading video stream. 2024-04-21 17:44:22 - MANUAL - INFO - Video codec detected: h264. 2024-04-21 17:44:22 - MANUAL - INFO - Pix Fmt: yuv420p. 2024-04-21 17:44:22 - MANUAL - INFO - Profile: high. 2024-04-21 17:44:22 - MANUAL - DEBUG - Stream is not HDR, color parameter bt709 does not match ['bt2020nc'] [hdr-['bt2020nc']]. 2024-04-21 17:44:22 - MANUAL - DEBUG - Pool of video codecs is ['h264_nvenc', 'h264', 'x264']. 2024-04-21 17:44:22 - MANUAL - DEBUG - Total bitrate is 8160603.0. 2024-04-21 17:44:22 - MANUAL - DEBUG - Total audio bitrate is 640000. 2024-04-21 17:44:22 - MANUAL - DEBUG - Estimated video bitrate is 7520603.0. 2024-04-21 17:44:22 - MANUAL - DEBUG - Using video bitrate ratio of 1.000000, which results in 7144.572850 changing to 7144.572850. 2024-04-21 17:44:22 - MANUAL - DEBUG - Source bit-depth 8, output 8, using depth 8. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video codec: copy. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video bitrate: 7144.57285. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video CRF: -1. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video maxrate: None. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video bufsize: None. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video level: 4.1. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video profile: high. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video preset: slow. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video pix_fmt: yuv420p. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video field order: progressive. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video width: None. 2024-04-21 17:44:22 - MANUAL - DEBUG - Video debug video. 2024-04-21 17:44:22 - MANUAL - INFO - Video codec parameters None. 2024-04-21 17:44:22 - MANUAL - INFO - Creating copy video stream from source stream 0. 2024-04-21 17:44:22 - MANUAL - INFO - Reading audio streams. 2024-04-21 17:44:22 - MANUAL - INFO - The following stream indexes have been identified as being copies: [] [stream-codec-combinations]. 2024-04-21 17:44:22 - MANUAL - DEBUG - Pool universal audio codecs is []. 2024-04-21 17:44:22 - MANUAL - DEBUG - Pool of audio codecs is ['eac3', 'aac', 'ac3']. 2024-04-21 17:44:22 - MANUAL - INFO - Audio detected for stream 1 - eac3 eng 6 channel. 2024-04-21 17:44:22 - MANUAL - DEBUG - Attempting to set bitrate based on source stream bitrate. 2024-04-21 17:44:22 - MANUAL - DEBUG - Audio codec: copy. 2024-04-21 17:44:22 - MANUAL - DEBUG - Channels: 6. 2024-04-21 17:44:22 - MANUAL - DEBUG - Bitrate: 640.0. 2024-04-21 17:44:22 - MANUAL - DEBUG - VBR: 0. 2024-04-21 17:44:22 - MANUAL - DEBUG - Audio Profile: None. 2024-04-21 17:44:22 - MANUAL - DEBUG - Language: eng. 2024-04-21 17:44:22 - MANUAL - DEBUG - Filter: None. 2024-04-21 17:44:22 - MANUAL - DEBUG - Disposition: +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired. 2024-04-21 17:44:22 - MANUAL - DEBUG - Debug: audio. 2024-04-21 17:44:22 - MANUAL - INFO - Creating copy audio stream from source stream 1. 2024-04-21 17:44:22 - MANUAL - DEBUG - Purging the following streams: 2024-04-21 17:44:22 - MANUAL - DEBUG - [] 2024-04-21 17:44:22 - MANUAL - INFO - Found 0 streams that can be removed from the output file since they will be duplicates [stream-codec-combinations]. 2024-04-21 17:44:22 - MANUAL - DEBUG - Triggering audio track sort [audio.sorting-sorting]. 2024-04-21 17:44:22 - MANUAL - DEBUG - Sorting streams with keys ['language', 'channels.d', 'map', 'd.comment']. 2024-04-21 17:44:22 - MANUAL - INFO - Final sorting: 2024-04-21 17:44:22 - MANUAL - INFO - ['0->0'] 2024-04-21 17:44:22 - MANUAL - DEBUG - Sorting streams with keys ['channels.d', 'map', 'd.comment']. 2024-04-21 17:44:22 - MANUAL - INFO - Final sorting: 2024-04-21 17:44:22 - MANUAL - INFO - ['0->0'] 2024-04-21 17:44:22 - MANUAL - DEBUG - Sorting audio streams for default audio stream designation. 2024-04-21 17:44:22 - MANUAL - DEBUG - 1 total audio streams with 1 set to default disposition. 0 defaults in your preferred language (por), 1 in other languages. 2024-04-21 17:44:22 - MANUAL - DEBUG - No audio streams in your preferred language, using other languages to determine default stream. 2024-04-21 17:44:22 - MANUAL - INFO - Default audio stream set to eng copy 6 channel stream [audio-default-sorting: ['channels.d', 'map', 'd.comment']]. 2024-04-21 17:44:22 - MANUAL - INFO - Reading subtitle streams. 2024-04-21 17:44:22 - MANUAL - INFO - Subtitle detected for stream 2 - subrip eng. 2024-04-21 17:44:23 - MANUAL - DEBUG - Potential subtitle candidate identified Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt. 2024-04-21 17:44:23 - MANUAL - DEBUG - Processing subtitle file suffix . 2024-04-21 17:44:23 - MANUAL - DEBUG - Valid external por subtitle file detected Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt. 2024-04-21 17:44:23 - MANUAL - INFO - Scanned for external subtitles and found 1 results in your approved languages. 2024-04-21 17:44:24 - MANUAL - DEBUG - isImageBasedSubtitle FFmpeg command: 2024-04-21 17:44:24 - MANUAL - DEBUG - /usr/bin/ffmpeg -i "/content/down/converter/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt" -c:s:0 srt -map 0:0 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=und -disposition:s:0 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f srt -t 00:00:01 -f null - 2024-04-21 17:44:24 - MANUAL - INFO - Creating srt subtitle stream by importing Text-based subtitle Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt [embed-subs]. 2024-04-21 17:44:24 - MANUAL - DEBUG - Path: /content/down/converter 4/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Codec: srt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Langauge: por. 2024-04-21 17:44:24 - MANUAL - DEBUG - Disposition: -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired. 2024-04-21 17:44:24 - MANUAL - DEBUG - Default subtitle stream already inherited from source material, will not override to subtitle-language-default. 2024-04-21 17:44:24 - MANUAL - DEBUG - Sorting streams with keys ['language', 'd.comment', 'd.default.d', 'd.forced.d']. 2024-04-21 17:44:24 - MANUAL - INFO - Final sorting: 2024-04-21 17:44:24 - MANUAL - INFO - ['0->0'] 2024-04-21 17:44:24 - MANUAL - DEBUG - Subtitle streams detected, adding fix_sub_duration option to preopts. 2024-04-21 17:44:24 - MANUAL - DEBUG - canBypassConvert returned False. 2024-04-21 17:44:24 - MANUAL - INFO - Output Data 2024-04-21 17:44:24 - MANUAL - INFO - { "source": [ "/content/down/converter 4/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv", "/content/down/converter 4/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt" ], "format": "mkv", "video": { "codec": "copy", "map": 0, "bitrate": 7144.57285, "crf": -1, "maxrate": null, "bufsize": null, "level": 4.1, "profile": "high", "preset": "slow", "pix_fmt": "yuv420p", "field_order": "progressive", "width": null, "filter": null, "params": null, "framedata": null, "bsf": null, "debug": "video", "title": "FHD" }, "audio": [ { "map": 1, "codec": "copy", "channels": 6, "bitrate": 640.0, "profile": null, "quality": 0, "filter": null, "samplerate": null, "sampleformat": "", "language": "eng", "disposition": "+default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired", "bsf": null, "debug": "audio", "title": "5.1 Channel" } ], "subtitle": [ { "source": 1, "map": 0, "codec": "srt", "disposition": "-default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired", "language": "por", "debug": "subtitle.embed-subs", "title": null } ], "attachment": [] } 2024-04-21 17:44:24 - MANUAL - INFO - Preopts 2024-04-21 17:44:24 - MANUAL - INFO - [ "-fix_sub_duration" ] 2024-04-21 17:44:24 - MANUAL - INFO - Postopts 2024-04-21 17:44:24 - MANUAL - INFO - [ "-threads", "0", "-metadata:g", "encoding_tool=SMA" ] 2024-04-21 17:44:24 - MANUAL - INFO - Starting conversion. 2024-04-21 17:44:24 - MANUAL - DEBUG - Input directory: /content/down/converter/Beacon.23.S02E01.1080p.WEB.h264-ETHEL. 2024-04-21 17:44:24 - MANUAL - DEBUG - File name: Beacon.23.S02E01.1080p.WEB.h264-ETHEL. 2024-04-21 17:44:24 - MANUAL - DEBUG - Input extension: mkv. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output directory: /mnt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output extension: /mnt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output file: /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv. 2024-04-21 17:44:24 - MANUAL - DEBUG - Input directory: /content/down/converter/Beacon.23.S02E01.1080p.WEB.h264-ETHEL. 2024-04-21 17:44:24 - MANUAL - DEBUG - File name: Beacon.23.S02E01.1080p.WEB.h264-ETHEL. 2024-04-21 17:44:24 - MANUAL - DEBUG - Input extension: mkv. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output directory: /mnt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output extension: /mnt. 2024-04-21 17:44:24 - MANUAL - DEBUG - Output file: /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv. 2024-04-21 17:44:24 - MANUAL - DEBUG - Final output file: /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv. 2024-04-21 17:44:24 - MANUAL - INFO - FFmpeg command: 2024-04-21 17:44:24 - MANUAL - INFO - ====================== 2024-04-21 17:44:24 - MANUAL - INFO - /usr/bin/ffmpeg -fix_sub_duration -i "/content/down/converter/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv" -i "/content/down/converter/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt" -vcodec copy -map 0:0 -metadata:s:v title=FHD -metadata:s:v handler_name=FHD -c:a:0 copy -map 0:1 -metadata:s:a:0 "title=5.1 Channel" -metadata:s:a:0 "handler_name=5.1 Channel" -metadata:s:a:0 language=eng -disposition:a:0 +default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -c:s:0 srt -map 1:0 -metadata:s:s:0 title= -metadata:s:s:0 handler_name= -metadata:s:s:0 language=por -disposition:s:0 -default-dub-original-comment-lyrics-karaoke-forced-hearing_impaired-visual_impaired-captions -f matroska -threads 0 -metadata:g encoding_tool=SMA -y /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv 2024-04-21 17:44:24 - MANUAL - INFO - ====================== 2024-04-21 17:45:13 - MANUAL - INFO - /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv created. 2024-04-21 17:45:13 - MANUAL - DEBUG - /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv created from /content/down/converter 4/Beacon.23.S02E01.1080p.WEB.h264-ETHEL/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv successfully. 2024-04-21 17:45:13 - MANUAL - DEBUG - Height: 1080 2024-04-21 17:45:13 - MANUAL - DEBUG - Width: 1920 2024-04-21 17:45:13 - MANUAL - DEBUG - Relocate MOOV enabled but format is %s, adding reserve_index_space parameter. 2024-04-21 17:45:13 - MANUAL - DEBUG - Tag language setting is por, using language por for tagging. 2024-04-21 17:45:13 - MANUAL - DEBUG - Moveto option is enabled. 2024-04-21 17:45:42 - MANUAL - INFO - /mnt/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv moved to /content/drive/Shareddrives/OTIMIZADORES - WAGNER/Diego/out. 2024-04-21 17:45:42 - MANUAL - DEBUG - Final output file: /content/out/Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv. 2024-04-21 17:45:42 - MANUAL - DEBUG - Invalid source, no video stream detected.

FFMpeg headers

ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/home/ffmpeg-builder/release --pkg-config-flags=--static --extra-libs=-lm --disable-doc --disable-debug --disable-shared --disable-ffprobe --enable-static --enable-gpl --enable-version3 --enable-runtime-cpudetect --enable-avfilter --enable-filters --enable-nvenc --enable-nvdec --enable-cuvid --toolchain=hardened --disable-stripping --enable-opengl --pkgconfigdir=/home/ffmpeg-builder/release/lib/pkgconfig --extra-cflags='-I/home/ffmpeg-builder/release/include -static-libstdc++ -static-libgcc ' --extra-ldflags='-L/home/ffmpeg-builder/release/lib -fstack-protector -static-libstdc++ -static-libgcc ' --extra-cxxflags=' -static-libstdc++ -static-libgcc ' --extra-libs='-ldl -lrt -lpthread' --enable-ffnvcodec --enable-gmp --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfdk-aac --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libkvazaar --enable-libmp3lame --enable-libopus --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libshine --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtheora --enable-libvidstab --ld=g++ --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg --enable-openssl --enable-zlib --enable-nonfree --extra-libs=-lpthread --enable-pthreads --extra-libs=-lgomp libavutil 58. 2.100 / 58. 2.100 libavcodec 60. 3.100 / 60. 3.100 libavformat 60. 3.100 / 60. 3.100 libavdevice 60. 1.100 / 60. 1.100 libavfilter 9. 3.100 / 9. 3.100 libswscale 7. 1.100 / 7. 1.100 libswresample 4. 10.100 / 4. 10.100 libpostproc 57. 1.100 / 57. 1.100 Hyper fast Audio and Video encoder usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

System Information

mdhiggins commented 2 months ago

Do you have clean it enabled in the settings? The script doesn't do any subtitle post processing unless that's on

ClankJake commented 2 months ago

I tested with it activated and deactivated, the same problem occurred.

mdhiggins commented 2 months ago

Gonna need some sample files to take a look cause the script doesn't do any post processing beyond that. Also if you could share your FFMPEG command that doesn't create the problem that would be helpful too

ClankJake commented 2 months ago

Here is the command I used:

ffmpeg -i Beacon.23.S02E01.1080p.WEB.h264-ETHEL.mkv -sub_charenc ISO-8859-1 -i Beacon.23.S02E01.1080p.WEB.h264-ETHEL.srt -map 0 -map 1 -c:v copy -c:a copy -c:s srt seu_video_com_duas_legendas.mkv

The "-sub_charenc ISO-8859-1" flag may have fixed the problem in my command.

mdhiggins commented 2 months ago

Does adding that command to post opts fix the issue for you?

postopts = -sub_charenc, ISO-8859-1

mdhiggins commented 2 months ago

If not try preopts

ClankJake commented 2 months ago

Moving now, I saw an option in the autoprocess.ini file in the subtitles part, I added ISO-8859-1 in encondig = I was able to embed it without any problem.