Repository: yt-dlp
Issue: Problem when embedding a subtitle with .ttml format to a video
Labels: external issue,core:post-processor

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I *intentionally* remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a bug unrelated to a specific site
- [X] I've verified that I have **updated yt-dlp to nightly or master** ([update instructions](https://github.com/yt-dlp/yt-dlp#update-channels))
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched [known issues](https://github.com/yt-dlp/yt-dlp/issues/3766) and the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)

### Provide a description that is worded well enough to be understood

When I try to download a video with the subtitle in **.ttml** format, I get the following message: `ERROR: Postprocessing: Error opening input files: Invalid data found when processing input`. Apparently, the same happens with **srv3**, **srv2**, **srv1** and **json3** formats. It only works fine with the **.vtt** format.

### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [ ] If using API, add `'verbose': True` to `YoutubeDL` params instead
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
>yt-dlp -vU -k test:youtube --format 137+140 --sub-format ttml --embed-subs
[debug] Command-line config: ['-vU', '-k', 'test:youtube', '--format', '137+140', '--sub-format', 'ttml', '--embed-subs']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.03.10 from yt-dlp/yt-dlp [615a84447] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19045-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 2024-04-04-git-478d97f303-full_build-www.gyan.dev (setts), ffprobe 2024-04-04-git-478d97f303-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02, mutagen-1.47.0, requests-2.31.0, sqlite3-3.35.5, urllib3-2.2.1, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1803 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: stable@2024.03.10 from yt-dlp/yt-dlp
yt-dlp is up to date (stable@2024.03.10 from yt-dlp/yt-dlp)
[TestURL] Extracting URL: test:youtube
[TestURL] Test URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[youtube] Extracting URL: https://www.youtube.com/watch?v=BaW_jenozKc&t=1s&end=9
[youtube] BaW_jenozKc: Downloading webpage
[youtube] BaW_jenozKc: Downloading ios player API JSON
[youtube] BaW_jenozKc: Downloading android player API JSON
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "BaW_jenozKc")
[debug] Loading youtube-nsig.1ced3a71 from cache
[debug] [youtube] Decrypted nsig VADEejNyiHRe7jscCg => hEDfHiG84tef1Q
[debug] Loading youtube-nsig.1ced3a71 from cache
[debug] [youtube] Decrypted nsig 2YzBSlnVYeZ29ijcHA => Ykq2vViX4ydEGA
[youtube] BaW_jenozKc: Downloading m3u8 information
[info] BaW_jenozKc: Downloading subtitles: en
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[info] BaW_jenozKc: Downloading 1 format(s): 137+140
[info] Writing video subtitles to: youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].en.ttml
[debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=BaW_jenozKc&ei=KRISZpudCv2_0_wPvbaBuAs&caps=asr&opi=112496729&xoaf=5&hl=en&ip=0.0.0.0&ipbits=0&expire=1712485529&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Copi%2Cxoaf&signature=B672E73FCF397353F3400C18D8E0A8F8A2A968BB.EFE8765B7F6096E2E1AD5E2ACCD8367B823DD34E&key=yt8&lang=en&fmt=ttml"
[debug] File locking is not supported. Proceeding without locking
[download] Destination: youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].en.ttml
[download] 100% of    820.00B in 00:00:00 at 7.71KiB/s
[debug] Invoking http downloader on "https://rr3---sn-j5caxh5n-hpqs.googlevideo.com/videoplayback?expire=1712481929&ei=KRISZv_HMJOi0_wPnbin2A0&ip=187.252.250.232&id=o-AHkO6WfLvTL2HcZWwahTR5FkSMsrd5lgGj18q3BJoS1P&itag=137&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=Rf&mm=31%2C29&mn=sn-j5caxh5n-hpqs%2Csn-ug5onuxajv-jwnz&ms=au%2Crdu&mv=m&mvi=3&pl=23&initcwndbps=1135000&vprv=1&svpuc=1&mime=video%2Fmp4&gir=yes&clen=293523&dur=9.833&lmt=1687568512138646&mt=1712460053&fvip=2&keepalive=yes&fexp=51141541&c=IOS&txp=1432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRQIgGfOv-2iysDnO1qAffu_rSuAxXFa_uRO8nDXTwiCJf5YCIQDNlAW-kpnJGWCHvuBfEAzsImTJ4_j_dcCAu633EOKbbQ%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ALClDIEwRgIhAI34Ueeb6PI2hWoYb-u5sVyuCTlvZ4b6FY5fi2rbuImoAiEAoIXJoXG1iXBgyZlsxzp61OCotJfGrWsygO6xHjEosgY%3D"
[download] Destination: youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].f137.mp4
[download] 100% of  286.64KiB in 00:00:00 at 690.03KiB/s
[debug] Invoking http downloader on "https://rr3---sn-j5caxh5n-hpqs.googlevideo.com/videoplayback?expire=1712481929&ei=KRISZv_HMJOi0_wPnbin2A0&ip=187.252.250.232&id=o-AHkO6WfLvTL2HcZWwahTR5FkSMsrd5lgGj18q3BJoS1P&itag=140&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=Rf&mm=31%2C29&mn=sn-j5caxh5n-hpqs%2Csn-ug5onuxajv-jwnz&ms=au%2Crdu&mv=m&mvi=3&pl=23&initcwndbps=1135000&vprv=1&svpuc=1&mime=audio%2Fmp4&gir=yes&clen=160839&dur=9.891&lmt=1687568430431279&mt=1712460053&fvip=2&keepalive=yes&fexp=51141541&c=IOS&txp=1432434&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cvprv%2Csvpuc%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AJfQdSswRQIhALuq_GWPpVbHUajWY9o1y9cOHNhUE_ZfLKbTvzQEZ1LzAiBqo34D73BLUHQFb7S16XwNpBt5NKpBOUPj_bicFwddeA%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=ALClDIEwRgIhAI34Ueeb6PI2hWoYb-u5sVyuCTlvZ4b6FY5fi2rbuImoAiEAoIXJoXG1iXBgyZlsxzp61OCotJfGrWsygO6xHjEosgY%3D"
[download] Destination: youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].f140.m4a
[download] 100% of  157.07KiB in 00:00:00 at 2.78MiB/s
[Merger] Merging formats into "youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].f1
37.mp4" -i "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].f140.m4a" -c copy -map "0:v:0" -map "1 :a:0" -movflags "+faststart" "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].temp.mp4"
[EmbedSubtitle] Embedding subtitles in "youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].mp
4" -i "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].en.ttml" -map 0 -dn -ignore_unknown -c copy  "-c:s" mov_text -map "-0:s" -map "1:0" "-metadata:s:s:0" "language=eng" "-metadata:s:s:0" "handler_name=English" "-metadata:s:s:0" "title=English" -movflags "+faststart" "file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].temp.mp4"
[debug] ffmpeg version 2024-04-04-git-478d97f303-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-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. 13.100 / 59. 13.100
  libavcodec     61.  5.101 / 61.  5.101
  libavformat    61.  3.100 / 61.  3.100
  libavdevice    61.  2.100 / 61.  2.100
  libavfilter    10.  2.101 / 10.  2.101
  libswscale      8.  2.100 /  8.  2.100
  libswresample   5.  2.100 /  5.  2.100
  libpostproc    58.  2.100 / 58.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf61.3.100
  Duration: 00:00:09.89, start: 0.000000, bitrate: 371 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 235 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
      Metadata:
        handler_name    : ISO Media file produced by Google Inc.
        vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
      Metadata:
        handler_name    : ISO Media file produced by Google Inc.
        vendor_id       : [0][0][0][0]
[in#1 @ 000002d6a78dbec0] Error opening input: Invalid data found when processing input
Error opening input file file:youtube-dl test video ＂'⧸⧹ä↭𝕐 [BaW_jenozKc].en.ttml.
Error opening input files: Invalid data found when processing input

ERROR: Postprocessing: Error opening input files: Invalid data found when processing input
Traceback (most recent call last):
  File "yt_dlp\YoutubeDL.py", line 3512, in process_info
  File "yt_dlp\YoutubeDL.py", line 3694, in post_process
  File "yt_dlp\YoutubeDL.py", line 3676, in run_all_pps
  File "yt_dlp\YoutubeDL.py", line 3654, in run_pp
  File "yt_dlp\postprocessor\common.py", line 23, in run
  File "yt_dlp\postprocessor\common.py", line 128, in wrapper
  File "yt_dlp\postprocessor\ffmpeg.py", line 662, in run
  File "yt_dlp\postprocessor\ffmpeg.py", line 329, in run_ffmpeg_multiple_files
  File "yt_dlp\postprocessor\ffmpeg.py", line 367, in real_run_ffmpeg
yt_dlp.postprocessor.ffmpeg.FFmpegPostProcessorError: Error opening input files: Invalid data found when processing input
```