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

The command downloading subtitles prints errors: ERROR: Preprocessing: Error opening output files: Invalid argument #9547

Closed
9 of 10 tasks
yurivict opened this issue Mar 28, 2024 · 1 comment
Labels
question Question

Comments

@yurivict
Copy link

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

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

Checklist

Provide a description that is worded well enough to be understood

This command:
yt-dlp --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]:[0-9]:[0-9],[0-9] --> [0-9]:[0-9]:[0-9],[0-9]$/d' | tr -s '\n' ' ' > transcription.txt" https://www.youtube.com/watch?v=Y_U6qWmtmGE

prints these error messages:

ERROR: Preprocessing: Error opening output files: Invalid argument
ERROR: Preprocessing: Error opening output files: Invalid argument

Provide verbose output that clearly demonstrates the problem

  • 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
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

$ yt-dlp -vU --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\n' ' ' > transcription.txt" https://www.youtube.com/watch?v=Y_U6qWmtmGE
[debug] Command-line config: ['-vU', '--skip-download', '--write-auto-subs', '--write-subs', '--sub-lang', 'ru', '--convert-subs', 'srt', '--sub-format', 'txt', '--postprocessor-args', "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\\n' ' ' > transcription.txt", 'https://www.youtube.com/watch?v=Y_U6qWmtmGE']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.03.10 from yt-dlp/yt-dlp [615a84447]
[debug] Python 3.9.18 (CPython amd64 64bit) - FreeBSD-14.0-STABLE-amd64-64bit-ELF (OpenSSL 3.0.13 30 Jan 2024, libc 7)
[debug] exe versions: ffmpeg 6.1.1 (setts), ffprobe 6.1.1
[debug] Optional libraries: Cryptodome-3.20.0, brotli-1.1.0, certifi-2024.02.02, mutagen-1.47.0, requests-2.31.0, secretstorage-None, sqlite3-3.45.0, urllib3-1.26.18, websockets-12.0
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
WARNING: Post-Processor arguments given without specifying name. The arguments will be given to all post-processors
[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)
[youtube] Extracting URL: https://www.youtube.com/watch?v=Y_U6qWmtmGE
[youtube] Y_U6qWmtmGE: Downloading webpage
[youtube] Y_U6qWmtmGE: Downloading ios player API JSON
[youtube] Y_U6qWmtmGE: Downloading android player API JSON
[youtube] Y_U6qWmtmGE: Downloading m3u8 information
[info] Y_U6qWmtmGE: Downloading subtitles: ru
WARNING: No subtitle format found matching "txt" for language ru, using vtt
[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
[debug] Default format spec: bestvideo*+bestaudio/best
[info] Testing format 616
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 1193
[download] Destination: /tmp/tmpwrc45d6u.tmp
[download] 100% of    712.00B in 00:00:00 at 7.71KiB/s
[info] Y_U6qWmtmGE: Downloading 1 format(s): 616+251
Deleting existing file Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.vtt
[info] Writing video subtitles to: Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.vtt
[debug] Invoking http downloader on "https://www.youtube.com/api/timedtext?v=Y_U6qWmtmGE&ei=ZvgEZpm0F_b3sfIP1dW00As&caps=asr&opi=112496729&xoaf=4&hl=en&ip=0.0.0.0&ipbits=0&expire=1711626966&sparams=ip%2Cipbits%2Cexpire%2Cv%2Cei%2Ccaps%2Copi%2Cxoaf&signature=820FC4A3A17FDF674766B5793B433D3CF1CECA70.2584B4C037ED94A279FC7C3582CA2E0CC9F18C27&key=yt8&kind=asr&lang=ru&fmt=vtt"
[download] Destination: Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.vtt
[download] 100% of  736.63KiB in 00:00:00 at 4.02MiB/s
[SubtitlesConvertor] Converting subtitles
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.vtt' -f srt -movflags +faststart -ss 00:00:00 -to 99:59:59 -f srt - '|' sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' '|' tr -s '\n' ' ' '>' transcription.txt 'file:Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.srt'
[debug] ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
  configuration: --prefix=/usr/local --mandir=/usr/local/share/man --datadir=/usr/local/share/ffmpeg --docdir=/usr/local/share/doc/ffmpeg --pkgconfigdir=/usr/local/libdata/pkgconfig --disable-static --disable-libcelt --enable-shared --enable-pic --enable-gpl --cc=cc --cxx=c++ --disable-alsa --disable-libopencore-amrnb --disable-libopencore-amrwb --enable-libaom --disable-libaribb24 --disable-libaribcaption --enable-asm --enable-libass --disable-libbs2b --disable-libcaca --disable-libcdio --disable-libcodec2 --enable-libdav1d --disable-libdavs2 --disable-libdc1394 --disable-debug --enable-htmlpages --enable-libdrm --disable-libfdk-aac --disable-libflite --enable-fontconfig --enable-libfreetype --enable-frei0r --disable-libfribidi --disable-gcrypt --disable-libglslang --disable-libgme --enable-gmp --enable-gnutls --enable-version3 --disable-libgsm --enable-libharfbuzz --enable-iconv --disable-libilbc --disable-libjack --enable-libjxl --disable-libklvanc --disable-libkvazaar --disable-ladspa --enable-libmp3lame --enable-lcms2 --disable-liblensfun --disable-libbluray --enable-libplacebo --disable-librsvg --disable-librtmp --enable-libxml2 --disable-lv2 --disable-mbedtls --disable-libmfx --disable-libmodplug --disable-libmysofa --enable-network --disable-nonfree --enable-nvenc --disable-openal --disable-opencl --disable-opengl --disable-libopenh264 --disable-libopenjpeg --disable-libopenmpt --disable-openssl --disable-libopenvino --enable-optimizations --enable-libopus --disable-pocketsphinx --disable-libpulse --disable-librabbitmq --disable-librav1e --disable-librist --enable-runtime-cpudetect --disable-librubberband --disable-sdl2 --enable-libshaderc --disable-libsmbclient --disable-libsnappy --disable-sndio --disable-libsoxr --disable-libspeex --disable-libsrt --disable-libssh --enable-libsvtav1 --disable-libtensorflow --disable-libtesseract --disable-libtheora --disable-libtwolame --disable-libuavs3d --enable-libv4l2 --enable-vaapi --disable-vapoursynth --enable-vdpau --disable-libvidstab --enable-libvmaf --enable-libvorbis --disable-libvo-amrwbenc --disable-libvpl --enable-libvpx --enable-vulkan --enable-libwebp --enable-libx264 --enable-libx265 --disable-libxavs2 --enable-libxcb --disable-libxvid --disable-outdev=xv --disable-libzimg --disable-libzmq --disable-libzvbi
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Input #0, webvtt, from 'file:Гордон и Чичваркин гуляют по Киеву. Работа Навального на ФСБ, размахивание членом, свинорез в сапоге [Y_U6qWmtmGE].ru.vtt':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Subtitle: webvtt
Output #0, srt, to 'pipe:':
  Metadata:
    encoder         : Lavf60.16.100
  Stream #0:0: Subtitle: subrip
    Metadata:
      encoder         : Lavc60.31.102 srt
[AVFormatContext @ 0x1c8095232180] Unable to choose an output format for '|'; use a standard extension for the filename or specify the format manually.
[out#1 @ 0x1c8095983c00] Error initializing the muxer for |: Invalid argument
Error opening output file |.
Error opening output files: Invalid argument

ERROR: Preprocessing: Error opening output files: Invalid argument
Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3683, in pre_process
    info = self.run_all_pps(key, info)
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3676, in run_all_pps
    info = self.run_pp(pp, info)
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3654, in run_pp
    files_to_delete, infodict = pp.run(infodict)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/common.py", line 23, in run
    ret = func(self, info, *args, **kwargs)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 1010, in run
    self.run_ffmpeg(old_file, new_file, ['-f', new_format])
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 374, in run_ffmpeg
    return self.run_ffmpeg_multiple_files([path], out_path, opts, **kwargs)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 329, in run_ffmpeg_multiple_files
    return self.real_run_ffmpeg(
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 367, in real_run_ffmpeg
    raise FFmpegPostProcessorError(stderr.strip().splitlines()[-1])
yt_dlp.postprocessor.ffmpeg.FFmpegPostProcessorError: Error opening output files: Invalid argument

ERROR: Preprocessing: Error opening output files: Invalid argument
@yurivict yurivict added bug Bug that is not site-specific triage Untriaged issue labels Mar 28, 2024
@yurivict yurivict changed the title Command downloading subtitles prints errors: ERROR: Preprocessing: Error opening output files: Invalid argument The command downloading subtitles prints errors: ERROR: Preprocessing: Error opening output files: Invalid argument Mar 28, 2024
@dirkf
Copy link
Contributor

dirkf commented Mar 28, 2024

  1. The pipe (|) is part of the shell syntax and not something that can be passed in ...-args.
  2. --convert-subs xxx already forces -f xxx.
  3. You can't force the postprocessor output to stdout because yt-dlp automatically supplies the output file name.
  4. In principle, something like the below would work but doesn't because writing subtitles to stdout isn't supported (you get, eg, -.ru.srt):
-yt-dlp -vU --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\n' ' ' > transcription.txt" https://www.youtube.com/watch?v=Y_U6qWmtmGE
+yt-dlp -vU --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args '-ss 00:00:00 -to 99:59:59' -o - 'https://www.youtube.com/watch?v=Y_U6qWmtmGE' | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\n' ' ' > transcription.txt

Instead of piping, use a fixed intermediate file. Also, you could do the tr command in sed:s/\n\+/ /g (s/\n+/ /g using extended REs, -r):

-yt-dlp -vU --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args "-ss 00:00:00 -to 99:59:59 -f srt - | sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d' | tr -s '\n' ' ' > transcription.txt" https://www.youtube.com/watch?v=Y_U6qWmtmGE
+yt-dlp -v --skip-download --write-auto-subs --write-subs --sub-lang ru --convert-subs srt --sub-format txt --postprocessor-args '-ss 00:00:00 -to 99:59:59' -o 'subtitle:transcription' 'https://www.youtube.com/watch?v=Y_U6qWmtmGE' && sed '/^[0-9]*:[0-9]*:[0-9]*,[0-9]* --> [0-9]*:[0-9]*:[0-9]*,[0-9]*$/d;s/\n\+/ /g' transcription.ru.srt > transcription.txt && rm -f transcription.ru.srt

Somewhat excessively, passing -U when yt-dlp isn't updatable causes an ERROR that breaks the && chain; if there are other arguments it could just be a WARNING.

@bashonly bashonly added question Question and removed bug Bug that is not site-specific triage Untriaged issue labels Mar 28, 2024
@bashonly bashonly closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question
Projects
None yet
Development

No branches or pull requests

3 participants