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
Fix missing last frame of MPEG-TS content #419
Conversation
Thanks for the contribution! It looks like something went wrong with your PR setup as it includes thousands of commits (mostly by our team). Could you try to rebase/clean this up? |
Sorry, had wrongly left the base branch set to release :( should be fixed now. |
Please sign the CLA and we can take a look. |
Ready for review, sorry for the delay. |
I found that lots of tests in the I was able to fix many of them by updating the golden test files by temporarily setting
Also: I tried to push my commit updating the golden test files, but was unable to. Is it possible that you need to allow permission to me to push commits to this branch? https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork We will likely need to push more changes during internal review as well, so please check that access has been granted. Thanks! |
@icbaker you should have access now. Let me check the tests. |
Tests are now passing for me (after setting WRITE_TO_LOCAL to update the dumps). |
I received an invite to collaborate on https://github.com/v-novaltd/androidx-media which I've accepted, but I'm still not able to push commits to this PR. I did some experimentation with #443 and I see the same problem (can't push changes from androidx back to my icbaker personal fork) if I untick the 'allow edits by maintainers' on the PR itself. I can't see this tickbox on this PR, I think only you can as the creator of the PR. Can you please make sure it's ticked? Thanks! GitHub docs on this: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork Please also take a look at the couple of comments I added in the code itself. |
Ah, it's possible you can't tick this box this because v-novaltd is a GitHub organisation rather than an individual user: https://github.com/orgs/community/discussions/5634 And the recommended workaround in https://github.com/orgs/community/discussions/5634#discussioncomment-2155236 is exactly what you've done. Let me have a play around and see if I can work with the permission you've granted me. Sorry for being a bit unfamiliar here, we've recently changed the way we handle PRs to a process that requires pushing our own commits to the PR before merging it (to avoid 'evil merges') - you can see the full discussion about that here: google/ExoPlayer@e811749#commitcomment-107715150 |
@icbaker Yes, I cannot see the option 'Allow edits by maintainers' as v-novaltd is a github org. I'm afraid I don't see your comments yet. |
libraries/extractor/src/main/java/androidx/media3/extractor/ts/H264Reader.java
Show resolved
Hide resolved
@@ -323,7 +323,14 @@ public void release() { | |||
} | |||
|
|||
if (!fillBufferWithAtLeastOnePacket(input)) { | |||
return RESULT_END_OF_INPUT; | |||
if (mode != MODE_HLS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add some context about why it's correct to only do this if mode != HLS
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've seen this PR, as it is, would break HLS mode, because of the presence of the next segment. However I think the logic of the PR should still apply to the very last segment of a VOD HLS, which currently misses the last frame.
Let me investigate a bit further on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course when I say "would break" I mean without the if statement above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added the HLS case as well.
Sorry, I didn't realise they were stuck in 'pending' state - they should be published now I think. |
Current comments are now addressed. |
Thanks for the fixes! I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks! |
…eaders; add end of input flag to readers to flush accumulated data from last PES
18e705a
to
3572f90
Compare
Issue
With TS contents, any codec, the last access unit is never passed on to the input sample queue. The reason is that the end of the sample is currently triggered by the payload_unit_start_indicator (pusi) of the first TS packet of the following access unit, which doesn't exist for the very last access unit. As a result the playback of any TS content always misses the last frame.
For frame accurate applications this seems a non negligible issue.
This problem was already discussed here google/ExoPlayer#7909 and that ticket is still open.
Proposed solution
In our understanding, for a file based case, it is reasonable to assume that the end of stream is a valid end of the last access unit, provided all the accumulated TS packets of the access unit have correct TS header parameters such as transport_error_indicator (=0) and continuity_counter.
This pull request comes from a fix we implemented in our LCEVC-Exo fork. The idea is that on end of stream: