WIP Skin video backdrops
#1
Hi dev's,

I'm trying to implement a new class CGUIVideoBackground to enable skins to play a video loop in the background. As a proof of concept this more or less works and I find the effect really beautiful.

There is however one thing that is not so beautiful and that is the fact that the video loop is not seamless. When the video restarts, for a very brief, but very noticable moment the background becomes black. At first I thought it was something with my code (which basically is a stripped version of the CApplication:TonguelayFile() function) so I decided to do a small test and copy the video that I use 3 times and rename the files such that they appear as a single stacked video in XBMC.
I then noticed that unfortunately, this stacked video also shows the black background when it moves from one video in the stack to the next. For normal stacked videos this does not seem to be a problem because they get cut at the end of a scene and you don't really notice it.

Basically, I'm looking for some hints and tips to overcome this limitation. I was thinking about introducing a new URI in CDVDFactoryInputStream::CreateInputStream() called 'loop://'. When encountered this would then instantiate a CDVDInputStreamFileLoop object. The CDVDInputStreamFileLoop class would be derived from CDVDInputStreamFile and would when the end of the video file is reached simply seek to the beginning of the file.
Now I'm wondering whether or not this is the right approach, or if there are better solutions.

Edit: Updated title, was "Seamless playback of video loop?"
Reply
#2
I have updated the post title to better reflect exactly what it is that I'm working on.

Good progress has been made. The looping of the video is now seamless; no more black background when the video restarts. At the moment I have solved this only for the DVDPlayer player by updating the CDVDPlayer::ReadPacket() function:

Code:
// read a data frame from stream.
  if(m_pDemuxer)
    packet = m_pDemuxer->Read();

  // Rewind to start of file used by the skin video backdrop
  if (!packet && m_PlayerOptions.endless_loop)
  {
      m_messenger.Put(new CDVDMsgPlayerSeek((int)0, true, false, true, true, true));
      SynchronizeDemuxer(100);

      packet = m_pDemuxer->Read();
  }

  if(packet)
  {

When the end of the file is reached, I simply seek to the start of the file and do another attempt to read the packet. So far this works very well. It actually saves me from requiring the use of the "loop://" URI and CDVDInputStreamFileLoop class that I first had in mind.

I have been going through the code of the OMXPlayer and it seems like the same change may apply there. For the AMLPlayer I'm not sure yet.

Questions that I have regarding the AMLPlayer and OMXPlayer:
  • Does the AMLPlayer play video in the background, i.e., when you play a video and hit the Tab-key to exit fullscreen mode, does the video continue to play in the background with the menu overlayed on top?
  • Does the OMXPlayer play video in the background, i.e., when you play a video and hit the Tab-key to exit fullscreen mode, does the video continue to play in the background with the menu overlayed on top?

Questions that I have regarding the architecture:
  • Is this the best way of implementing this feature, or does anyone have a better solution?
  • Currently, the player is part of the CGUIVideoBackground class. This keeps the player and window nicely together. It does have the drawback though that the video restarts everytime a window is opened. By moving the player out of the CGUIVideoBackground class (e.g. by creating a global variable like the current player object) the player can simply continue to play in case the video backdrop of the previous and newly opened window is the same video. Opinions on this are welcome. Personally, I'm not a big fan of globals.
  • Should it be possible to use playlists in addition to single movie files as backdrops? (I'm not sure if this will be possible due to the fact that the playlistplayer updates some globals)

Any hints, tips, remarks, whatever are most welcome.
Reply
#3
Hi leechguy,

great that you started working at this!

I think that
Code:
!packet
does not imply that the end of a file is reached.

Regards ace
Reply
#4
I think you're right. I have moved the code into the Process() function, this seems to be the better location just before all players are told that the end of the file has been reached:

Code:
// input stream asked us to just retry
      if(next == CDVDInputStream::NEXTSTREAM_RETRY)
      {
        Sleep(100);
        continue;
      }
      else if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER))
      {
        CDVDInputStreamPVRManager* pStream = static_cast<CDVDInputStreamPVRManager*>(m_pInputStream);
        if (pStream->IsEOF())
          break;

        Sleep(100);
        continue;
      }
      // Rewind to start of file, used when playing a skin video backdrop
      else if (m_PlayerOptions.endless_loop)
      {
        m_messenger.Put(new CDVDMsgPlayerSeek((int)0, true, false, true, true, true));
        SynchronizeDemuxer(100);
        continue;
      }

      // make sure we tell all players to finish it's data
      if(m_CurrentAudio.inited)
        m_dvdPlayerAudio.SendMessage   (new CDVDMsg(CDVDMsg::GENERAL_EOF));
      if(m_CurrentVideo.inited)
Reply
#5
A small update on current progress.

I have been playing 'a bit' more with the proof of concept and have been creating a CGUIVideoBackground control similar to the CGUIImage control. Next to a video backdrop I now also have video thumbs Smile These could for example be used in List view to show movie trailers instead of the PosterThumb images that are shown at the moment. This already works although I am playing the real movie instead of a trailer (not sure if the trailer filename is available at the moment).

When playing both a video backdrop and a 'video thumb' it seems as if both players are playing both videos. So the video backdrop also plays in the video thumb and vica versa with lots of flicker. Of course the players are not really playing two videos each. I have a feeling that this is a problem in the rendering of both videos. The rendering stuff in XBMC is something that I still need to take a good look at.

The biggest problem I am facing however is that I may have to come to the sad conclusion that using DVDPlayer may not be suitable at the moment. It simply is not stable when used for this purpose and when using VDPAU it will crash XBMC in no time. When using software decoding it is much more stable, although also not as stable as it must be. A conclusion to which oldnemesis also already came for the karaoke video background. However, using the karoake video player is not an option for me because it lacks hardware accelleration.

The coming week I want to investigate whether or not I should refactor the CGUIVideoBackground control and split it into a CGUIVideoBackground and CVideo part, similar to CGUIImage and CTexture.

Any hints, tips and/or remarks are most welcome.
Reply
#6
Confluence skin use to have a multiimage loading which loaded a bunch of images in sucession as a background basically looked like a video playback (similar), this was removed in Frodo because of resource usage on less poweful platforms but the code is still there and can be used by skins, quite a few do or did..

see http://wiki.xbmc.org/?title=MultiImage_Control

It would be more popular if this could be used as addon so if your resources are ok you can download addon and go from there.

This multiimage thing could be a video except it was saved as frames/images which is basically what video is lost a frames/images played in succession seamlessly..

uNi
Reply
#7
The MultiImage Control is meant for slideshows (e.g. looping through fanart). I don't think that it is particularly well suited for displaying approx. 25~30 different images/second. That would indeed be a bit of a resource problem.

A video on the otherhand that is decoded by the GPU is much lighter. I ripped a video from youtube as a 30 frames per second 1080p H.264 video. It uses only 3.1 MB for a movie of 12 seconds.

I recorded a little video which shows the current status:

Reply
#8
That may be the case, however think of platfoms like rPI and similar, I still think an addon stands better chance if thats even possible as addon.

uNi
Reply
#9
XBMC can have only one player active at the same time. So if you're playing mp3's with PAPlayer, you can't have DVDPlayer, OMXPlayer or any other player to play the video backdrop because that requires two players to be active at the same time. So to be able to allow for more than one player requires changes in XBMC, this simply is not possible with an addon.

I can't say what the result will be on the RPi, ATV and Android devices yet. The RPi is able to run video when not in fullscreen mode, but the menu does not scroll smoothly. Then again, I don't think that anyone is running heavy skins like for example Aeon MQ4 on a RPi either.
Reply
#10
Yes but for people that never use anything but default confluence skin will likely never see this "feature" as a addon anyone could.

uNi
Reply
#11
have a look at pr #1137.
Reply
#12
Yes, I'm already looking at the karaoke code and the ffmpeg tutorial mentioned in the code comments. I will probably create a prototype using that player to figure out how hard it will be to add hardware acceleration.
As a test of this player I tried using Lord of the Rings as a video background in karoake mode. On my Atom/ION2 it sort of works, but in very slow motion so hw acceleration really is a must (not that I plan to use LOTR as a video backdrop, but I do intend to use full HD video backdrops)
Reply
#13
This is spectacular. Shut up and take my money!
Reply
#14
Still needs a lot of work though. I had to down prioritize this a little due to some work on auto login profiles and a skiing holiday. Things should be moving forward again Smile
Reply
#15
Great work! You probably have seen the FFMPEG update, which's support decoding and demuxing animated gif's.
Reply

Logout Mark Read Team Forum Stats Members Help
Skin video backdrops1