yt-dlp: Getting Postprocessing: "Cannot allocate memory" for embedding meta data for some mp4

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.10.04 (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

Getting Postprocessing Cannot allocate memory for embedding meta data for some mp4

[Metadata] Adding metadata to “Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4” ERROR: Postprocessing: file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.meta: Cannot allocate memory

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

$ yt-dlp 'https://player.vimeo.com/video/756714419' --referer https://sleepsuperconference.com  --all-subs -f 'bv*[height<=480]+ba/b[height<=480] / wv*+ba/w' --embed-chapters -o 'Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4' --download-archive download-archive -v -U[debug] Command-line config: ['https://player.vimeo.com/video/756714419', '--referer', 'https://sleepsuperconference.com', '--all-subs', '-f', 'bv*[height<=480]+ba/b[height<=480] / wv*+ba/w', '--embed-chapters', '-o', 'Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4', '--download-archive', 'download-archive', '-v', '-U']
[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.10.04 [4e0511f] (zip)
[debug] Python 3.10.7 (CPython 64bit) - Linux-5.18.19-3-MANJARO-x86_64-with-glibc2.36 (glibc 2.36)
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg N-108541-g2c2aaa5bd0 (fdk,setts), ffprobe N-108541-g2c2aaa5bd0, phantomjs 2.1.1, rtmpdump 2.4
[debug] Optional libraries: Cryptodome-3.12.0, brotlicffi-1.0.9.2, certifi-2022.09.24, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Loaded 1690 extractors
[debug] Loading archive file 'download-archive'
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.10.04, Current version: 2022.10.04
yt-dlp is up to date (2022.10.04)
[debug] [vimeo] Extracting URL: https://player.vimeo.com/video/756714419
[vimeo] 756714419: Downloading webpage
[vimeo] 756714419: Downloading akfire_interconnect_quic m3u8 information
[vimeo] 756714419: Downloading akfire_interconnect_quic m3u8 information
[vimeo] 756714419: Downloading fastly_skyfire m3u8 information
[vimeo] 756714419: Downloading fastly_skyfire m3u8 information
[vimeo] 756714419: Downloading akfire_interconnect_quic MPD information
[vimeo] 756714419: Downloading akfire_interconnect_quic MPD information
[vimeo] 756714419: Downloading fastly_skyfire MPD information
[vimeo] 756714419: Downloading fastly_skyfire MPD information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, lang, vcodec:vp9.2(10), channels, acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, id
[info] 756714419: Downloading subtitles: en-US
[info] 756714419: Downloading 1 format(s): hls-fastly_skyfire_sep-811+dash-fastly_skyfire_sep-audio-c3718307
Deleting existing file Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.en-US.vtt
[info] Writing video subtitles to: Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.en-US.vtt
[debug] Invoking http downloader on "https://vimeo.com/texttrack/47916355.vtt?token=63516159_0xbd4960524a65f70c7e69feccbf520b577414229a"
[download] Destination: Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.en-US.vtt
[download] 100% of   56.67KiB in 00:00:00 at 231.02KiB/s
[download] Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4 has already been downloaded
[Metadata] Adding metadata to "Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4' -i 'file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.meta' -map 0 -dn -ignore_unknown -c copy -map_metadata 1 -movflags +faststart 'file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.temp.mp4'
[debug] ffmpeg version N-108541-g2c2aaa5bd0 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.2.0 (GCC)
  configuration: --prefix=/usr --enable-lto --disable-rpath --enable-gpl --enable-version3 --enable-nonfree --enable-shared --disable-static --disable-stripping --enable-gray --enable-alsa --enable-avisynth --enable-bzlib --enable-chromaprint --enable-frei0r --enable-gcrypt --enable-gmp --enable-gnutls --enable-iconv --enable-ladspa --enable-lcms2 --enable-libaom --enable-libaribb24 --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcelt --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libdavs2 --enable-libdc1394 --enable-libfdk-aac --enable-libflite --enable-fontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libiec61883 --enable-libilbc --enable-libjack --enable-libjxl --enable-libklvanc --enable-libkvazaar --enable-liblensfun --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-libopencv --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --disable-libopenvino --enable-libopus --enable-libplacebo --enable-libpulse --enable-librabbitmq --enable-librav1e --disable-librist --enable-librsvg --enable-librubberband --enable-librtmp --enable-libshine --enable-libsmbclient --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libsvthevc --enable-libsvtvp9 --disable-libtensorflow --enable-libtesseract --enable-libtheora --disable-libtls --enable-libtwolame --enable-libuavs3d --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxavs2 --enable-libxcb --enable-libxcb-shm --enable-libxcb-xfixes --enable-libxcb-shape --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-lzma --enable-decklink --disable-mbedtls --enable-libmysofa --enable-openal --enable-opencl --enable-opengl --disable-openssl --enable-pocketsphinx --enable-sndio --enable-sdl2 --enable-vapoursynth --enable-vulkan --enable-xlib --enable-zlib --enable-amf --disable-cuda-nvcc --disable-cuda-llvm --disable-cuvid --disable-ffnvcodec --enable-libdrm --disable-libmfx --disable-libnpp --disable-nvdec --disable-nvenc --enable-omx --disable-rkmpp --enable-v4l2-m2m --enable-vaapi --enable-vdpau
  libavutil      57. 39.100 / 57. 39.100
  libavcodec     59. 50.100 / 59. 50.100
  libavformat    59. 34.100 / 59. 34.100
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 49.101 /  8. 49.101
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf59.34.100
  Duration: 00:43:56.00, start: 0.000000, bitrate: 720 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m, progressive), 640x360, 618 kb/s, 25 fps, 25 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: opus (Opus / 0x7375704F), 48000 Hz, stereo, fltp, 96 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
[ffmetadata @ 0x562694d3cc40] Chapter end time 888000 before start 2510000
file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.meta: Cannot allocate memory

ERROR: Postprocessing: file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.meta: Cannot allocate memory
Traceback (most recent call last):
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3272, in process_info
    replace_info_dict(self.post_process(dl_filename, info_dict, files_to_move))
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3449, in post_process
    info = self.run_all_pps('post_process', info, additional_pps=info.get('__postprocessors'))
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3431, in run_all_pps
    info = self.run_pp(pp, info)
  File "/usr/local/bin/yt-dlp/yt_dlp/YoutubeDL.py", line 3410, in run_pp
    files_to_delete, infodict = pp.run(infodict)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/common.py", line 24, in run
    ret = func(self, info, *args, **kwargs)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/common.py", line 129, in wrapper
    return func(self, info)
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 702, in run
    self.run_ffmpeg_multiple_files(
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 323, in run_ffmpeg_multiple_files
    return self.real_run_ffmpeg(
  File "/usr/local/bin/yt-dlp/yt_dlp/postprocessor/ffmpeg.py", line 361, in real_run_ffmpeg
    raise FFmpegPostProcessorError(stderr.strip().splitlines()[-1])
yt_dlp.postprocessor.ffmpeg.FFmpegPostProcessorError: file:Therapeutic yoga for optimum sleep - Dr Arielle Schwartz.meta: Cannot allocate memory

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

There’s one particular value (888) that’s obviously wrong. Either Vimeo is sending bad data, or the extraction is failing. As 888 isn’t likely to result from parsing a number as octal or missing the first or last decimal digit, it looks like a valid timecode in the wrong place.

This code (l.224 ff. in extractor/vimeo.py) could be the problem:

        chapter_data = try_get(config, lambda x: x['embed']['chapters']) or []
        chapters = [{
            'title': current_chapter.get('title'),
            'start_time': current_chapter.get('timecode'),
            'end_time': next_chapter.get('timecode'),
        } for current_chapter, next_chapter in zip(chapter_data, chapter_data[1:] + [{'timecode': duration}])]
        if chapters and chapters[0]['start_time']:  # Chapters may not start from 0
            chapters[:0] = [{'title': '<Untitled>', 'start_time': 0, 'end_time': chapters[0]['start_time']}]

It assumes that the chapter_data is sorted by timecode. The observed error is consistent with the final element of chapter_data being

    {
        'timecode': 888',
        'title': "Dr Schwartz' insomnia experience",
        ...,
    }

The values for “Where to find out more” come from chapter_data[-2]['timecode'] and chapter_data[-1]['timecode'] (== 888), and the latter is used for “Dr Schwartz’ insomnia experience” together with the forced end value from {'timecode': duration}.

A solution is to sort the chapter_data after l.224:

         chapter_data = try_get(config, lambda x: x['embed']['chapters']) or []
+        chapter_data = sorted(chapter_data, key=lambda c: int_or_none(c.get('timecode'), default=0))
         chapters = [{

Obviously ffmpeg needs to be fixed as well, but that isn’t required if the above or similar solve this issue.

No, they have a “Skip Intro” button (haven’t encountered a “Skip Outro” yet)

Just leaving another example here since it was just reported in the linked issue: yt-dlp.exe "--add-metadata" "https://youtube.com/clip/UgkxEmuva_arOMau4REcelQYZGoI6kixSwYt"

It’s the same error, but with a different root cause and solution.

The immediate cause of the error is also that a chapter’s end_time is before its start_time. In this case, it’s the last chapter:

$ yt-dlp -O "duration,chapters.-1=" "https://youtube.com/clip/UgkxEmuva_arOMau4REcelQYZGoI6kixSwYt"

duration = 57.363
chapters.-1 = {
    "start_time": 1336.0,
    "title": "Tidepool-2: Escape Artist",
    "end_time": 57.363
}

We can see that the duration that’s being extracted is the duration of the clip (rather than the full video that the clip is taken from.) But the full video’s chapter metadata is still being extracted for the clip, and yt-dlp core code sets the final chapter’s end_time to the extracted duration (the clip duration).

Per this code comment and as noted by #5852, the YoutubeClip extractor needs be improved to extract the clip’s metadata instead of the base video’s metadata: https://github.com/yt-dlp/yt-dlp/blob/b032ff0f032512bd6fc70c9c1994d906eacc06cb/yt_dlp/extractor/youtube.py#L6894-L6898

and chapters should simply be discarded for clips, which would fix this problem