Detecting AV1-encoded videos with Python

Python hunts AV1 videos; commenters shout “just use VLC” and debate overkill

TLDR: A developer wrote a Python test to find AV1-format videos using ffprobe or MediaInfo so he can convert them. Commenters split between “install VLC and move on” and “ffprobe is fine, reencoding is the real cost,” with side jokes about piracy and code style.

A developer tries to play detective, using Python to sniff out which videos are in AV1—an efficient new video format—so he can convert them before his iPhone refuses to play them. He shows two routes: shelling out to ffprobe (a tool from FFmpeg) and using the MediaInfo library via Python. But the comments turned this tiny codec check into a full-on courtroom drama. One camp expected sci‑fi magic: wolttam hoped for frame-based detection, not just reading metadata. Another camp, led by nick238, asked: is launching ffmpeg really that heavy? In fact, they argued it’s perfect for parallel runs when scanning lots of files. Then came the pragmatists with popcorn: avidiax joked about where anyone even finds AV1 “on the high seas,” and declared all this optimization premature because reencoding (actually converting the video) is the real time sink. Code-style sticklers joined in too—zahlman nitpicked the test, insisting you should short‑circuit with any() instead of building a whole set. And finally, the mic drop: breve says stop fussing and install VLC, claiming even older iPhones can play AV1 thanks to the speedy dav1d decoder. Verdict? Half the crowd loves the Python sleuthing, half says “use a player,” and everyone’s dunking on micro‑optimizations.

Key Points

  • The author needs to find AV1-encoded videos that won’t play on their current iPhone to convert them to an older codec.
  • ffprobe (from FFmpeg) can report a video’s codec_name, and a Python function using subprocess.check_output can return True when it equals “av1.”
  • MediaInfo offers a simpler CLI to get the codec and provides a Python library via pymediainfo to read codec_id in-process.
  • Using pymediainfo avoids spawning a new process per file and can identify AV1 by checking the first video track’s codec_id (e.g., “av01”).
  • There’s a potential IndexError if a file lacks a video track; the author plans a test to scan a folder for AV1 videos.

Hottest takes

"Somehow I thought this was going to be about detecting AV1 based on the decoded video frames" — wolttam
"Is launching an ffmpeg process so heavyweight that there's a reason to avoid it?" — nick238
"Install VLC on your phone and you'll be able to play the AV1 videos" — breve
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.