Skip to content
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

Render final frame of MPEG-TS video #7909

Closed
arlimm318 opened this issue Sep 15, 2020 · 7 comments
Closed

Render final frame of MPEG-TS video #7909

arlimm318 opened this issue Sep 15, 2020 · 7 comments
Assignees

Comments

@arlimm318
Copy link

This TS contains only one I frame,android Error while playing.
bjws-20655436911.zip

The error log:
09-15 10:07:06.325 6394-6394/com.google.android.exoplayer2.demo E/EventLogger: playerFailed [eventTime=4.32, mediaPos=0.00, window=0, period=0
com.google.android.exoplayer2.ExoPlaybackException: Source error
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:487)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)
Caused by: com.google.android.exoplayer2.ParserException: Loading finished before preparation is complete.
at com.google.android.exoplayer2.source.ProgressiveMediaPeriod.maybeThrowPrepareError(ProgressiveMediaPeriod.java:239)
at com.google.android.exoplayer2.source.MaskingMediaPeriod.maybeThrowPrepareError(MaskingMediaPeriod.java:144)
at com.google.android.exoplayer2.ExoPlayerImplInternal.doSomeWork(ExoPlayerImplInternal.java:838)
at com.google.android.exoplayer2.ExoPlayerImplInternal.handleMessage(ExoPlayerImplInternal.java:410)
at android.os.Handler.dispatchMessage(Handler.java:98) 
at android.os.Looper.loop(Looper.java:136) 
at android.os.HandlerThread.run(HandlerThread.java:61) 
]

@icbaker
Copy link
Collaborator

icbaker commented Sep 15, 2020

I tried to reproduce with your provided file in the ExoPlayer demo app built from dev-v2 branch on a Pixel 3a XL running R. Playback seems to complete fine and I don't see any errors in logcat.

Can you provide the info requested in the issue template?

@arlimm318
Copy link
Author

Device name & OS version: STB Based on the Hisilicon chip mv310, android4.4.2
ExoPlayer version:dev-v2 2.11.7

The previous mistake was due to my negligence,Ignore the previous error.
device-2020-09-16-110936.zip
Now there are no errors, but no images are displayed.I recorded the video and the log.

@icbaker
Copy link
Collaborator

icbaker commented Sep 16, 2020

I agree no image is shown. I don't see any image when I play the .ts video file in VLC either.

For such a short video what image are you expecting to see?

@arlimm318
Copy link
Author

You can see the picture with FFPlay.
This TS file contains only frame I,I think I should see the decoded frame I.

@icbaker icbaker changed the title Error playing super-short TS MPEG-TS file with single video frame doesn't show image when played Sep 16, 2020
@icbaker
Copy link
Collaborator

icbaker commented Sep 17, 2020

Thanks - I looked deeper into what's going on here.

When parsing MPEG-TS we use the start of the next frame as the trigger for calling SampleQueue#sampleMetadata call for the previous one:

// If the NAL unit ending is the start of a new sample, output the previous one.

We probably always fail to output the final frame properly. It just happens to be more visible when the final frame is also the first and only frame. We do it this way because MPEG-TS doesn't clearly indicate where the end of each sample is, unlike something like MP4/MKV.

We could use end-of-stream as a signal to flush out the final sample, but given MPEG-TS is often clipped in random places, that would quite likely cause a new problem where we output a partial frame as the last sample in some cases. So, I guess the question is whether upon seeing end-of-stream, there's a good way to determine whether the sample data that has been output is a complete sample, in which case we could call sampleMetadata conditionally on that check passing.

@icbaker icbaker changed the title MPEG-TS file with single video frame doesn't show image when played Render final frame of MPEG-TS video Sep 17, 2020
@icbaker icbaker assigned AquilesCanta and unassigned icbaker Sep 17, 2020
@arlimm318
Copy link
Author

Thanks very much.
I look forward to the resolution of this problem.

@icbaker
Copy link
Collaborator

icbaker commented Jun 29, 2023

This should be resolved by androidx/media#419

@icbaker icbaker closed this as completed Jun 29, 2023
@google google locked and limited conversation to collaborators Aug 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants