Skip to content

PyAV gets stuck when encountering a [mpeg2video] Invalid frame dimensions 0x0. #1876

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

Open
Alexandre-SCHOEPP opened this issue Apr 23, 2025 · 0 comments

Comments

@Alexandre-SCHOEPP
Copy link

Alexandre-SCHOEPP commented Apr 23, 2025

I have recently started to update my codebase in PyAV instead of batch-controlled FFMPEG, and encountered an issue:

I run a UDP+MPEG-TS video-only stream between two processes on my computer, and use it to transmit video between them. Unfortunately, this fails on PyAV:

My install

FFMPEG source build info

From the initialization of FFMPEG on the minimum example

ffmpeg version 7.1.1-full_build-www.gyan.dev Copyright (c) 2000-2025 the FFmpeg developers
  built with gcc 14.2.0 (Rev1, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-lcms2 --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-libdvdnav --enable-libdvdread --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libopenjpeg --enable-libquirc --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-libqrencode --enable-librav1e --enable-libsvtav1 --enable-libvvenc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --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-liblc3 --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. 39.100 / 59. 39.100
  libavcodec     61. 19.101 / 61. 19.101
  libavformat    61.  7.100 / 61.  7.100
  libavdevice    61.  3.100 / 61.  3.100
  libavfilter    10.  4.100 / 10.  4.100
  libswscale      8.  3.100 /  8.  3.100
  libswresample   5.  3.100 /  5.  3.100
  libpostproc    58.  3.100 / 58.  3.100

I run on Windows 11, on Python 3.12.3, and I use PyAV 14.3.0

Minimum reproducible example

This example is on this gif file

When running the following code

import av, subprocess, time

ffmpeg_command: list[str] = [
    "ffmpeg",
    "-re",  # Wait until the next frame should occur, rather than when it's ready
    "-stream_loop", "-1",  # loop the gif file infinitely
    "-i", str(race_horse),
    "-f", "mpegts", stream_addr  # stream as rtp stream
]
stream_src = subprocess.Popen(ffmpeg_command)
time.sleep(0.1)

with av.open(
    addr, 'r', timeout=10., metadata_errors="ignore", container_options={"video_size": "184x135"}
) as video:
    for packet in video.demux():
        ...

PyAV returns the error message [mpeg2video] Invalid frame dimensions 0x0, which is fine: ffmplay raises the same error (and does so a couple of times), but, while ffmplay gets unstuck in less than 3 seconds, PyAV get stuck seemingly permanently (I have yet to have the ... code executed

Would you know how I could get the stream to work ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant