Skip to content

feat: add ffprobe metadata extraction (profile, level, bit depth, ref frames, audio language)#334

Open
firestaerter3 wants to merge 2 commits intokrinkuto11:mainfrom
firestaerter3:feat/ffprobe-stream-metadata
Open

feat: add ffprobe metadata extraction (profile, level, bit depth, ref frames, audio language)#334
firestaerter3 wants to merge 2 commits intokrinkuto11:mainfrom
firestaerter3:feat/ffprobe-stream-metadata

Conversation

@firestaerter3
Copy link

@firestaerter3 firestaerter3 commented Mar 6, 2026

What this adds

Extends the existing ffmpeg stderr parsing in get_stream_info_and_bitrate() to pull additional metadata out of the stream info lines that ffmpeg already prints — no second upstream connection is opened.

New fields in stream_stats

Field Example Source in ffmpeg output
video_profile "High" Video: h264 (High), ...
video_bit_depth 10 pixel format suffix — yuv420p10le → 10, yuv420p → 8
audio_language "eng" stream specifier — Stream #0:1(eng):
sample_rate 48000 Audio: aac, 48000 Hz, ...
audio_channels "5.1" ..., 5.1(side), ... — trailing (side)/(back) stripped

video_level and video_ref_frames are not included — they're not reliably present in ffmpeg debug output and would require a separate probe call to get them consistently.

Backwards compatibility

  • All new fields are optional — filtered by the existing {k: v for k, v in ... if v not in [None, "N/A"]} cleanup
  • No changes to existing fields or behaviour

@krinkuto11
Copy link
Owner

I have to give it a thought, since ideally a single connection to the provider would be optimal. I´ll try to do it via the ffmpeg process so it can route a ffprobe without opening a new connection.

@firestaerter3
Copy link
Author

That's a fair point — hadn't thought about the concurrent connection issue when providers enforce a single-stream limit.

I had a look at what ffmpeg's stderr actually gives us when it starts up. Most of what I need is already there: profile, pixel format (bit depth), sample rate, channel layout, and audio language all show up in the stream info lines. Level sometimes appears inline too (e.g. h264 (High 4.2)) but it's not consistent enough to rely on. Ref frames are basically never there.

So if it makes more sense, I could rework this to parse the existing ffmpeg stderr output instead of the separate ffprobe call — that way there's no second connection at all. The only thing we'd lose is reliable level and ref frame extraction, but those are edge cases anyway. Happy to go that route if you'd prefer it over the ffprobe approach.

@firestaerter3 firestaerter3 force-pushed the feat/ffprobe-stream-metadata branch from cbf254d to 78be589 Compare March 9, 2026 07:49
firestaerter3 and others added 2 commits March 9, 2026 10:16
…epth, ref frames and audio language

Adds a new get_stream_metadata() function to stream_check_utils.py that runs
a fast ffprobe JSON call (~2-3s) before the existing ffmpeg bitrate analysis.
Extracts structured metadata not reliably available from ffmpeg debug output:

Video: profile (High/Main), level (e.g. 42), bit depth (8/10), ref frame count
Audio: language tag (ISO 639-2), sample rate, channel layout

Results are merged into the analyze_stream() result dict and included in the
stream_stats payload written to Dispatcharr by both _update_stream_stats() and
_prepare_stream_stats_for_batch().

This enables downstream consumers (e.g. Emby/Jellyfin plugins) to make correct
direct-play vs transcode decisions for HEVC 10-bit content, high ref-frame H.264,
and multi-language streams without probing at playback time.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…robe call

Replaces the standalone ffprobe JSON call with inline parsing of ffmpeg's
existing stderr output. All new fields (video_profile, video_bit_depth,
audio_language, sample_rate, audio_channels) are extracted from the stream
info lines that ffmpeg already prints during analysis — no second upstream
connection is opened.

video_level and video_ref_frames are dropped; these are not reliably present
in ffmpeg stderr output.
@firestaerter3 firestaerter3 force-pushed the feat/ffprobe-stream-metadata branch from 78be589 to 736ccb6 Compare March 9, 2026 09:16
@krinkuto11
Copy link
Owner

Check the latest dev build to see if it satisfies your requirements.

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

Successfully merging this pull request may close these issues.

2 participants