Skip to main content

Event timing

15 replies [Last post]
hooligancat
Offline
Joined: 2009-10-20
Points: 0

We are still having problems getting graphics to synch with the video correctly. Can I ask what events people have found to be the most reliable. We are trying to avoid the graphics showing before the video has loaded.

For instance:
Video clip is playing. A button on this takes you to another playitem in the same playlist. When the 1st frame of video on this new playitem is actually on the TV the graphics are to be displayed (ie so the graphics and video appear together, or at the very least the graphics immediately after the 1st frame).

I have tried every event I can think of, and every one of them seems to fire before the 1st frame of the video is actually presented.

The only way we can get the graphics to always show after the video has started is to have a monitor thread, that checks the playback time of the video and compares it to the starting time. The problem with this, is it is upto the player when to actually start the thread, so on some players we are waiting for 5-6 secs for the graphics to show.

I can't believe this is the right way to do this.

The events we are monitoring from ControllerListener are:
EndOfMediaEvent
StartEvent
StopEvent
RateChangeEvent
MediaPresentedEvent

and from playbackListener are:
playItemReached
markReached

We are jumping to the correct playmark (which is on frame 0 of the playitem and set as type LINK) with

m_playback_control.skipToMark(l_mark);

I've noticed that the cookbook doesn't use this or the skipToPlayitem. Is there anything else we should be aware of?

What I want and expect to happen is that we call skipToMark and an event fires that tells us the 1st video frame is on screen so that the graphics can be redrawn (at this point the graphics have already been drawn to the internal buffer and just need to be presented).

Please help with this most infuriating problem.

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joe Rice

That's indeed one of the more frustrating quotidian issues in BD-J.

The MediaPresentedEvent is the intended event for this, as it's the only one which is meant to reflect what's actually displayed, as opposed to what's happening in the PCE, which may be ahead of the presentation engine. We've found it works well on most players, at least when first playing a playlist (at any mark/item). The PS3 used to fire these early, but that was resolved around firmware version 2.71 IIRC. PS3 sill fires PlaybackPlayItemEvent and PlaybackMarkEvent before the associated frame video is decoded to screen.

One common technique we'll use is to place PLMark two frames into the PlayItem and use the corresponding PlaybackMarkEvent to trigger graphics display. That seems to work universally. As you mention, another option is to monitor the media time of the player after a skip to make sure it's incrementing before displaying the graphics.

We've used both skipToMark and skipToPlayItem hundreds of times and haven't found any issues with either. One thing to note with skipToPlayItem is that it will have no effect if skipping to the current PlayItem. (That's not an issue with skipToMark). I'd love to know the thinking behind that one!

Cheers,
Joe

On Feb 20, 2010, at 2:30 AM, bd-j-dev@mobileandembedded.org wrote:

> We are still having problems getting graphics to synch with the video correctly. Can I ask what events people have found to be the most reliable. We are trying to avoid the graphics showing before the video has loaded.
>
> For instance:
> Video clip is playing. A button on this takes you to another playitem in the same playlist. When the 1st frame of video on this new playitem is actually on the TV the graphics are to be displayed (ie so the graphics and video appear together, or at the very least the graphics immediately after the 1st frame).
>
> I have tried every event I can think of, and every one of them seems to fire before the 1st frame of the video is actually presented.
>
> The only way we can get the graphics to always show after the video has started is to have a monitor thread, that checks the playback time of the video and compares it to the starting time. The problem with this, is it is upto the player when to actually start the thread, so on some players we are waiting for 5-6 secs for the graphics to show.
>
> I can't believe this is the right way to do this.
>
> The events we are monitoring from ControllerListener are:
> EndOfMediaEvent
> StartEvent
> StopEvent
> RateChangeEvent
> MediaPresentedEvent
>
> and from playbackListener are:
> playItemReached
> markReached
>
> We are jumping to the correct playmark (which is on frame 0 of the playitem and set as type LINK) with
>
> m_playback_control.skipToMark(l_mark);
>
> I've noticed that the cookbook doesn't use this or the skipToPlayitem. Is there anything else we should be aware of?
>
> What I want and expect to happen is that we call skipToMark and an event fires that tells us the 1st video frame is on screen so that the graphics can be redrawn (at this point the graphics have already been drawn to the internal buffer and just need to be presented).
>
> Please help with this most infuriating problem.
>
> Thanks in advance.
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=387720
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Thanks Joe,

So if I understand you correctly, the best approach is to use skipToPlayItem (unless you're already in that playitem), with a PL Mark 2 frames into it. When the PL Mark event fires display the graphics. This means additional work with the encoding to ensure there is an I frame for the mark but I think that is a small price to pay.

Advice like this really should be put into a sticky somewhere; so that anyone experiencing these 'nuances' can instantly know where to look. A repository of bdj coding techniques would be very useful I think.

Thanks again,
Adam

Joe Rice

Adam,

That's right, and there's no need for special encoding, as BD doesn't
require that PLMarks be on I frames. (that's the best practice if
using as an entry mark, but for marks used as triggers they can be
anywhere and set as link points if you want to allow skipping to other
defined entry marks).

Cheers,
Joe

On Feb 21, 2010, at 3:28, bd-j-dev@mobileandembedded.org wrote:

> Thanks Joe,
>
> So if I understand you correctly, the best approach is to use
> skipToPlayItem (unless you're already in that playitem), with a PL
> Mark 2 frames into it. When the PL Mark event fires display the
> graphics. This means additional work with the encoding to ensure
> there is an I frame for the mark but I think that is a small price
> to pay.
>
> Advice like this really should be put into a sticky somewhere; so
> that anyone experiencing these 'nuances' can instantly know where to
> look. A repository of bdj coding techniques would be very useful I
> think.
>
> Thanks again,
> Adam
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=387853
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Great. Thanks Joe.

So, taking this a stage further. If we want to jump to an arbitrary time in the video (using setMediaTime) what is the preferred approach to knowing when this time has been reached and again the video frame is actually on the TV? It appears that org.dvb.dsmcc.MediaTimeEventControl would handle this except there is no way to de-register a listener; and according to the cookbook because of this, this event should not be used.

Thanks

Joe Rice

Adam,

I haven't tested this, but I wonder if a MediaPresentedEvent should be generated in this case, since MHP 11.4.2.5.2 indicates it should be generated when DAVIC controls are used to make changes to the player. That's the only event I know of which accommodates the idea of actual video presentation to the viewer.

As an alternative to setting a MediaTimeEvent, a MediaTimePositionChangedEvent should also be generated when the position is changed, however.

Regarding MediaTimeEvents, the deregistration issue was resolved, but maybe after HDCookbook was written. It's still true that one doesn't have a guarantee of deregistration support on profile 1.0 players, but all profile 1.1 and later players support it. (See BD-ROM 3-2 v2.4 11.4.2.1 and DVB-GEM v1.0.3 A.2.1)

From MediaTimeEventContro#notifyWhen() javadocs:

When this method is called with a listener, an id and a negative mediaTime as arguments, the listener is deregistered for the negated value of the corresponding mediaTime parameter and matching id. The availability of this deregistration feature on the platform may be indicated via the existence of the system property.

Cheers,
Joe

On Feb 22, 2010, at 4:55 AM, bd-j-dev@mobileandembedded.org wrote:

> Great. Thanks Joe.
>
> So, taking this a stage further. If we want to jump to an arbitrary time in the video (using setMediaTime) what is the preferred approach to knowing when this time has been reached and again the video frame is actually on the TV? It appears that org.dvb.dsmcc.MediaTimeEventControl would handle this except there is no way to de-register a listener; and according to the cookbook because of this, this event should not be used.
>
> Thanks
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=387985
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

[att1.html]

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Thanks Joe,

I'll give that a try. Based on the prevelance of 1.1 and 2.0 players now, it is probably safe enough to consider the MediaTimeEvent. Do you know if the event is deregistered on xlet destroy or immediately after the event has been generated?

Any idea on what the actual system property is for checking this? Probably a good idea to confirm its existance first, and if not available fall back to a thread monitor.

Thanks

Joe Rice

IIRC, if bluray.event.extension exists and is set to YES, it'll be supported. (I believe this property must exists and be YES on all players >= profile 1.1.

Joe

On Feb 23, 2010, at 12:49 PM, bd-j-dev@mobileandembedded.org wrote:

> Thanks Joe,
>
> I'll give that a try. Based on the prevelance of 1.1 and 2.0 players now, it is probably safe enough to consider the MediaTimeEvent. Do you know if the event is deregistered on xlet destroy or immediately after the event has been generated?
>
> Any idea on what the actual system property is for checking this? Probably a good idea to confirm its existance first, and if not available fall back to a thread monitor.
>
> Thanks
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=388301
>
[att1.html]

billf
Offline
Joined: 2004-02-13
Points: 0

> IIRC, if bluray.event.extension exists and is set to
> YES, it'll be supported. (I believe this property
> must exists and be YES on all players >= profile 1.1.

That sounds right. It was quite some time ago when we caught this bug -- the fix is incorporated into GEM, and it's been a loooong time since GEM needed bugfixing for BD-J.

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Thanks guys.

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Still having a problem with this. It seems this approach (2 frames after the start of the playitem), does not work when a playlist is started. It appears to work fine when skipping between playitems.

What do you suggest for when starting a new playlist?

Also, are there any known issues if you pass a bdlocator when the mark is 0 ie

bd://1.PLAYLIST:00001.MARK:00000

Thanks again.

Joe Rice

For starting a new PlayList we typically see good results with a MediaPresentedEvent.

If having trouble with that locator, you might try a single digit for the mark. The PlayList has to be 5 digits, but marks and items do not. (Since Playlists always have to contain mark 0 at the first frame of the PlayList, there's not strictly a need for the mark element of the locator in that example, but I don't see why it would hurt).

Cheers,
Joe

On Mar 2, 2010, at 9:03 AM, bd-j-dev@mobileandembedded.org wrote:

> Still having a problem with this. It seems this approach (2 frames after the start of the playitem), does not work when a playlist is started. It appears to work fine when skipping between playitems.
>
> What do you suggest for when starting a new playlist?
>
> Also, are there any known issues if you pass a bdlocator when the mark is 0 ie
>
> bd://1.PLAYLIST:00001.MARK:00000
>
> Thanks again.
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389655
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Unfortuantely that didn't work any better. To be more precise the issue is that the background layer has an image loaded onto it. When changing playlists the player has to be stopped which end up showing the background through. To 'hide' the background, I am painting a black screen over the video, and the idea is that when the video is playing the black screen will be wiped. In all cases so far (except when using a monitoring thread), all the events fire too soon, so the back screen is wiped before the 1st video frame is shown; this results in a horrible flicker.

Thanks

Joe Rice

Hmm, I suppose you could try a MediaTimeEvent or add a mark 3-4 frames in to the PlayList and check the mark ID of the event to make sure you're getting the right one. (IIRC some players may skip generating events for marks that are too close to an adjacent mark, and a mark is required on frame 0).

Alternatively, you could try setting the background to solid black prior to stopping playback, resetting the image to the background device during video playback before it needs to be seen. This would require reserving about 4MB of the image buffer for the background image, though.

Thanks,
Joe

On Mar 2, 2010, at 10:18 AM, bd-j-dev@mobileandembedded.org wrote:

> Unfortuantely that didn't work any better. To be more precise the issue is that the background layer has an image loaded onto it. When changing playlists the player has to be stopped which end up showing the background through. To 'hide' the background, I am painting a black screen over the video, and the idea is that when the video is playing the black screen will be wiped. In all cases so far (except when using a monitoring thread), all the events fire too soon, so the back screen is wiped before the 1st video frame is shown; this results in a horrible flicker.
>
> Thanks
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389663
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
> For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net
>

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net

hooligancat
Offline
Joined: 2009-10-20
Points: 0

Do you recall what the minimum distance between marks is for all players to work as expected?

Joe Rice

I don't think I'd do less than a four frame gap, but it's probably best determined through testing on whatever player matrix your client requires.

Cheers,
Joe

On Mar 2, 2010, at 11:13 AM, bd-j-dev@mobileandembedded.org wrote:

> Do you recall what the minimum distance between marks is for all players to work as expected?
> [Message sent by forum member 'hooligancat' (adame@tellx.com)]
>
> http://forums.java.net/jive/thread.jspa?messageID=389676

---------------------------------------------------------------------
To unsubscribe, e-mail: bd-j-dev-unsubscribe@hdcookbook.dev.java.net
For additional commands, e-mail: bd-j-dev-help@hdcookbook.dev.java.net