Repository navigation
Drain FFmpeg video output before end of stream - #211
Open
anilbeesetti wants to merge 1 commit into
Open
anilbeesetti wants to merge 1 commit into
anilbeesetti wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Media3's
SimpleDecoderpublishes EOS without invoking the decoder and assumes one output per input. This can discard delayed H.264, HEVC, and MPEG-2 frames and classify reordered output against the wrong timestamp after a seek.Implement the video
Decodercontract directly with fixed input/output pools and one worker. Java EOS sends FFmpeg's null packet, and output EOS follows receive-EOF after every delayed frame. Retain unaccepted packets across send-EAGAIN, bound the VP9 hidden-frame retry exception, and use decoded timestamps for presentation and seek filtering. Flush invalidates in-flight work; release reclaims outstanding native frames. Existing output modes, AV1 low-delay behavior, codec initialization data, and audio behavior are preserved.Add runnable Java/JNI regressions for delayed and multiple outputs, hidden VP9 frames, missing PTS, repeated seeks, flush/EOS races, callbacks, and frame ownership. YUV frames are checked against reference timestamps and pixel hashes. Only consumed test assets are checked in; generated playback files and machine-specific validation artifacts remain outside Git.
Validation
lintDebugpassed.3cab1e90, using-PnextlibPath, passedassembleDebug, 205 JVM tests, andktlintCheck, with test failures enforced. Builds also passed on JDK 17; the final Robolectric API 36 tests used the app's checked-in Java 21 runtime because Robolectric rejects Java 17.Explicit FFmpeg playback in Next Player rendered all expected frames and reached
STATE_ENDED:Every rendered timestamp matched host ffprobe within 1 µs. The installed APK's six JNI/FFmpeg libraries matched the local builds byte-for-byte;
libmedia3ext.sobuild ID was408d2e25e8451cff8e601a5905293436d4506d08.Interactive H.264 checks also covered forward/backward seeks, FFmpeg → hardware → FFmpeg on the same surface, pause/resume near EOS, the labelled final frame, and replay. Those captures preceded the final missing-PTS rounding/callback adjustment; the final APK repeated the five-codec counts above and the final Java/JNI suite repeated the seek/ownership cases. The disposable emulator was stopped and removed; both Next Player checkouts were left clean.
Reproduction
With FFmpeg dependencies already built and
ANDROID_SERIALset to a disposable ARM64 emulator:./gradlew assembleDebug assembleRelease test :media3ext:lintDebug -x ffmpegSetup bash media3ext/src/androidTest/run_video_decoder_test.sh -x ffmpegSetup bash media3ext/src/test/cpp/run_ffvideo_test.shFixture generation and required SDK/NDK environment variables are documented with the test runners and fixtures.
Known limitations
lintDebugfails on 507 existingMissingTranslationerrors incore/ui.1df6554decoder source and the same dependencies; its cause is unresolved.