Skip to content

fix: play live video whose size comes with the first keyframe - #600

Merged
devopvoid merged 2 commits into
mainfrom
fix/video-without-size
Nov 20, 2026
Merged

devopvoid merged 2 commits into
mainfrom
fix/video-without-size

Conversation

@devopvoid

@devopvoid devopvoid commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Description

Live H.264 whose picture size is only known from the first keyframe now plays through MediaFileSource:

  • MediaInfo.hasVideo() goes by the video stream (its codec) instead of a known size, so a 0x0 stream still gets a video source.
  • VideoDecoder passes over AVERROR_INVALIDDATA until its first picture, so the undecodable pictures ahead of the first keyframe no longer stop the player. Once there are pictures, the error is a fault as before.
  • MediaReaderOptions sets the timeout, the analysis duration and the probe size of a MediaReader, so a camera whose keyframes come further apart than FFmpeg's 5 seconds reports its size when it opens. Opening gets the analysis duration on top of the timeout. The new MediaFileSource(MediaReader, boolean) plays a reader opened that way.

Motivation and Context

An IP camera that sends SPS/PPS only in band, joined between keyframes, gives FFmpeg no size before it stops looking ("Could not find codec parameters ... unspecified size"). The stream was then reported as having no video, and playback failed with "Decoding failed: Invalid data found when processing input".

Refs #598

Type of Change

  • Bug fix (fix)
  • New feature (feat)

Affected Modules

  • webrtc-media
  • docs

Breaking Changes (if applicable)

MediaInfo.hasVideo() is now true for a video stream whose size is not known yet; getVideoWidth()/getVideoHeight() are 0 then.

How Has This Been Tested?

Tested on:

  • Linux (x64)

Java version: 25

Checklist

  • The change is focused on one topic.
  • My commits follow Conventional Commits.
  • I have reviewed my own code.
  • My branch is up to date with main.
  • I have added or updated tests that cover my change.
  • I have documented new public API with Javadoc.
  • I have updated the documentation in docs/guide if behavior changed.
  • I have not edited CHANGELOG.md, it is generated from the commits.

An IP camera that sends its parameter sets only in band, joined between
keyframes, says nothing about its picture size before FFmpeg stops looking.
MediaInfo then reported no video, so MediaFileSource made no video source,
and the undecodable pictures ahead of the first keyframe stopped the
player with a decoding error. hasVideo() now goes by the stream, and those
pictures are passed over until the first one decodes.

Refs #598
MediaReaderOptions sets the timeout, the analysis duration and the probe
size of a reader, so that a camera whose keyframes come further apart than
FFmpeg's 5 seconds reports its video size when it opens. Opening gets the
analysis duration on top of the timeout. MediaFileSource takes a reader
opened that way.

Refs #598
@devopvoid
devopvoid merged commit 68a0460 into main Nov 20, 2026
27 checks passed
@devopvoid
devopvoid deleted the fix/video-without-size branch November 20, 2026 19:39
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.

1 participant