Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subtitles not merged in the Matroska (.mkv) container: "invalid data found when post processing" #5853

Closed
9 tasks done
ethicnology opened this issue Dec 22, 2022 · 4 comments
Labels
duplicate This issue or pull request already exists external issue Issue with an external tool

Comments

@ethicnology
Copy link

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I remove or skip any mandatory* field

Checklist

  • I'm reporting a bug unrelated to a specific site
  • I've verified that I'm running yt-dlp version 2022.11.11 (update instructions) or later (specify commit)
  • I've checked that all provided URLs are playable in a browser with the same IP and same login details
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I've read the guidelines for opening an issue

Provide a description that is worded well enough to be understood

For the given URL, I want to download the source video/audio with all the subtitles available and merge all this contents in a mkv container.

To achieve this I tried the following command:

yt-dlp --embed-subs --sub-langs all --convert-subs srt --merge mkv "https://www.arte.tv/fr/videos/077330-001-A/50-nuances-de-grecs/"

#5833 (comment)

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

[debug] Command-line config: ['-vU', '--embed-subs', '--sub-langs', 'all', '--convert-subs', 'srt', '--merge', 'mkv', 'https://www.arte.tv/fr/videos/077330-001-A/50-nuances-de-grecs/']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.11.11 [8b64402] (linux_exe)
[debug] Python 3.10.6 (CPython x86_64 64bit) - Linux-5.19.0-26-generic-x86_64-with-glibc2.36 (OpenSSL 3.0.7 1 Nov 2022, glibc 2.36)
[debug] exe versions: ffmpeg 5.1.1 (setts), ffprobe 5.1.1
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.09.24, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1723 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.11.11, Current version: 2022.11.11
yt-dlp is up to date (2022.11.11)
[debug] [ArteTV] Extracting URL: https://www.arte.tv/fr/videos/077330-001-A/50-nuances-de-grecs/
[ArteTV] 077330-001-A: Downloading JSON metadata
[ArteTV] 077330-001-A: Downloading m3u8 information
[ArteTV] 077330-001-A: Downloading m3u8 information
[ArteTV] 077330-001-A: Downloading m3u8 information
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[info] 077330-001-A: Downloading subtitles: fr, de
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 077330-001-A: Downloading 1 format(s): VOF-2320+VOF-program_audio_0-VOF
[info] Writing video subtitles to: Moi, mioches et méchant [077330-001-A].fr.vtt
[debug] Invoking hlsnative downloader on "https://arte-cmafhls.akamaized.net/am/cmaf/077000/077300/077330-001-A/201214144624/medias/077330-001-A_st_VF-MAL.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1
[download] Destination: Moi, mioches et méchant [077330-001-A].fr.vtt
[download] 100% of    7.91KiB in 00:00:00 at 33.82KiB/s
[info] Writing video subtitles to: Moi, mioches et méchant [077330-001-A].de.vtt
[debug] Invoking hlsnative downloader on "https://arte-cmafhls.akamaized.net/am/cmaf/077000/077300/077330-001-A/201214144624/medias/077330-001-A_st_VA-ALL.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1
[download] Destination: Moi, mioches et méchant [077330-001-A].de.vtt
[download] 100% of    1.16KiB in 00:00:00 at 4.37KiB/s
[SubtitlesConvertor] Converting subtitles
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Moi, mioches et méchant [077330-001-A].fr.vtt' -f srt -movflags +faststart 'file:Moi, mioches et méchant [077330-001-A].fr.srt'
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Moi, mioches et méchant [077330-001-A].de.vtt' -f srt -movflags +faststart 'file:Moi, mioches et méchant [077330-001-A].de.srt'
Deleting original file Moi, mioches et méchant [077330-001-A].de.vtt (pass -k to keep)
Deleting original file Moi, mioches et méchant [077330-001-A].fr.vtt (pass -k to keep)
[download] Moi, mioches et méchant [077330-001-A].mkv has already been downloaded
[EmbedSubtitle] Embedding subtitles in "Moi, mioches et méchant [077330-001-A].mkv"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Moi, mioches et méchant [077330-001-A].mkv' -i 'file:Moi, mioches et méchant [077330-001-A].fr.srt' -i 'file:Moi, mioches et méchant [077330-001-A].de.srt' -map 0 -dn -ignore_unknown -c copy -map -0:s -map 1:0 -metadata:s:s:0 language=fra -map 2:0 -metadata:s:s:1 language=deu -movflags +faststart 'file:Moi, mioches et méchant [077330-001-A].temp.mkv'
[debug] ffmpeg version 5.1.1-1ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12 (Ubuntu 12.2.0-1ubuntu1)
  configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
Input #0, matroska,webm, from 'file:Moi, mioches et méchant [077330-001-A].mkv':
  Metadata:
    COMPATIBLE_BRANDS: iso6mp41
    MAJOR_BRAND     : iso5
    MINOR_VERSION   : 512
    ENCODER         : Lavf59.27.100
  Duration: 00:03:00.48, start: 0.000000, bitrate: 2324 kb/s
  Stream #0:0(eng): Video: h264 (Main), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn (default)
    Metadata:
      HANDLER_NAME    : Mainconcept MP4 Video Media Handler
      VENDOR_ID       : [0][0][0][0]
      DURATION        : 00:03:00.480000000
  Stream #0:1(fra): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      HANDLER_NAME    : Mainconcept MP4 Sound Media Handler
      VENDOR_ID       : [0][0][0][0]
      DURATION        : 00:03:00.349000000
file:Moi, mioches et méchant [077330-001-A].fr.srt: Invalid data found when processing input

ERROR: Postprocessing: file:Moi, mioches et méchant [077330-001-A].fr.srt: Invalid data found when processing input
Traceback (most recent call last):
  File "yt_dlp/YoutubeDL.py", line 3276, in process_info
  File "yt_dlp/YoutubeDL.py", line 3453, in post_process
  File "yt_dlp/YoutubeDL.py", line 3435, in run_all_pps
  File "yt_dlp/YoutubeDL.py", line 3414, in run_pp
  File "yt_dlp/postprocessor/common.py", line 24, in run
  File "yt_dlp/postprocessor/common.py", line 129, in wrapper
  File "yt_dlp/postprocessor/ffmpeg.py", line 654, in run
  File "yt_dlp/postprocessor/ffmpeg.py", line 323, in run_ffmpeg_multiple_files
  File "yt_dlp/postprocessor/ffmpeg.py", line 361, in real_run_ffmpeg
yt_dlp.postprocessor.ffmpeg.FFmpegPostProcessorError: file:Moi, mioches et méchant [077330-001-A].fr.srt: Invalid data found when processing
@ethicnology ethicnology added bug Bug that is not site-specific triage Untriaged issue labels Dec 22, 2022
@pukkandan
Copy link
Member

Ah, so that's what your issue was. This looks like #4127. Try our custom ffmpeg builds where this is fixed - https://github.com/yt-dlp/FFmpeg-Builds

@pukkandan pukkandan added duplicate This issue or pull request already exists external issue Issue with an external tool and removed bug Bug that is not site-specific triage Untriaged issue labels Dec 22, 2022
@ethicnology
Copy link
Author

@pukkandan It seems to work with your custom FFmpeg, thank you I can kill my own script.

Why the first subtitle track is enabled by default ?
Is there a way to unset all subtitles tracks by default?
Do you have any idea if your patches will be implemented in official FFmpeg program ?

Actual subtitles merging command:

 ffmpeg -y -loglevel repeat+info -i 'file:Moi, mioches et méchant [077330-001-A].mkv' -i 'file:Moi, mioches et méchant [077330-001-A].fr.srt' -i 'file:Moi, mioches et méchant [077330-001-A].de.srt' -map 0 -dn -ignore_unknown -c copy -map -0:s -map 1:0 -metadata:s:s:0 language=fra -map 2:0 -metadata:s:s:1 language=deu -movflags +faststart 'file:Moi, mioches et méchant [077330-001-A].temp.mkv'

@pukkandan
Copy link
Member

Why the first subtitle track is enabled by default ?
Is there a way to unset all subtitles tracks by default?

See #3709 (comment)

Do you have any idea if your patches will be implemented in official FFmpeg program ?

No idea. You can track the issue at https://trac.ffmpeg.org/ticket/8684

@ethicnology
Copy link
Author

For posterity

Download source with all available subtitles converted to SubRip (.srt) without any default tracks merged into Matroska container (.mkv)

yt-dlp -vU --embed-subs --sub-langs all --convert-subs srt --ppa "EmbedSubtitle:-disposition:s:0 0" --merge mkv "URL"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists external issue Issue with an external tool
Projects
None yet
Development

No branches or pull requests

2 participants