oomek
Posts: 16
Joined: Wed Oct 31, 2018 1:51 pm

Non sequential timestamps causing premature EOS flag

Mon Apr 15, 2019 12:45 pm

As you know after calling av_read_frame() you get AVPacket timestamps not always in the sequential order. This causes premature EOS flag in the fill_egl_texture_buffer callback.

I emit the EOS in the follwing way after sending all the frames to the decoder:

Code: Select all

if ((flags & DONE_READING) && (~flags & LAST_BUFFER))
{
	if ((omx_video_buffer = ilclient_get_input_buffer (video_decode, VIDEO_DECODE_INPUT_PORT, 1)) != NULL)
	{
		omx_video_buffer->nFilledLen = 0;
		omx_video_buffer->nFlags =  OMX_BUFFERFLAG_TIME_UNKNOWN | OMX_BUFFERFLAG_EOS;
		if (OMX_EmptyThisBuffer (ILC_GET_HANDLE (video_decode), omx_video_buffer) != OMX_ErrorNone)
			printf ("error emptying last buffer error\n");
	}
	SET_FLAG(LAST_BUFFER);
}
ilclient_wait_for_event(egl_render, OMX_EventBufferFlag, 221, 0, 0, 1, ILCLIENT_BUFFER_FLAG_EOS, -1);

The log from decoding thread shows the following timestamps at the end of the stream with 7 second duration:

Code: Select all

V: 6790111
V: 6840166
V: 6806800
V: 6823477
V: 6856844
V: 6873533
V: 6906900
V: 6890211
V: 6923577
V: 6956944
V: 6940266
V: 6973633
V: 6990311

But the callback shows flag=17 (EOF+EOS) prematurely at frame with timestamp 6923577 where it should be 6990311

Code: Select all

6790111  FLAGS: 16
6806800  FLAGS: 16
6823477  FLAGS: 16
6840166  FLAGS: 16
6856844  FLAGS: 16
6873533  FLAGS: 16
6890211  FLAGS: 16
6906900  FLAGS: 16
6923577  FLAGS: 17
---av_seek_frame 0 ---
6940266  FLAGS: 16
6956944  FLAGS: 16

oomek
Posts: 16
Joined: Wed Oct 31, 2018 1:51 pm

Re: Non sequential timestamps causing premature EOS flag

Tue Apr 16, 2019 9:33 am

Strangely this behaviour starts to manifests on the second pass in a looped video. EOS is signalled on the correct frame on the first pass.

oomek
Posts: 16
Joined: Wed Oct 31, 2018 1:51 pm

Re: Non sequential timestamps causing premature EOS flag

Wed Apr 17, 2019 10:16 am

If you need any further details please let me know as I desperately need to get to the bottom of this.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7140
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Non sequential timestamps causing premature EOS flag

Wed Apr 17, 2019 11:04 am

Sorry, I'm out of the office all week.
I'd need a full test case that can be easily built (ie make, cmake, or provided script) to be really digging into it.
I'd suggest that you provide a timestamp (last pts + 1) rather than relying on time unknown flag.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

oomek
Posts: 16
Joined: Wed Oct 31, 2018 1:51 pm

Re: Non sequential timestamps causing premature EOS flag

Sat Apr 20, 2019 1:52 am

There are few issues that I'm struggling with at the moment which I believe are related:

1. On the second and all consecutive video passes 2 last frames are not displayes due to the premature EOS flag
2. With timer preroll = 0ms frames 2&3 and last 2 are not drawn
3. With timer preroll = -200ms 2 last frames are not drawn

Preroll is set in player.c at line 164

Here is a working example with stripped off audio thread that shows the issues I'm having. Please use the test video provided.
https://github.com/oomek/rpi-mediaplayer/tree/no-audio

Usage:
make clean all
./bin/player loop test1.mp4

Pause: space, enter
Stop: s, enter
Last edited by oomek on Sat Apr 20, 2019 2:04 pm, edited 3 times in total.

oomek
Posts: 16
Joined: Wed Oct 31, 2018 1:51 pm

Re: Non sequential timestamps causing premature EOS flag

Sat Apr 20, 2019 1:59 pm

Hi, freezing was caused by unneccessary usleep in my code, but now frames 2&3 and last 2 are not drawn on the second pass.
I've updated my post above to reflect the current state.

Return to “OpenMAX”