Idea - Darkplaces support for playing video files on brushes

Developer discussion of experimental fixes, changes, and improvements.

Moderators: Nexuiz Moderators, Moderators


  • This idea has been poking me for a few days now so I thought it could be interesting to bring it up here. What if there would be support in the Darkplaces engine to be able to play avi and mpg files (and other similar formats maybe, even just quicktime videos) in a map on a screen or other surfaces?

    This is my idea: Every such video would consist of the video file itself in avi, mpg, wmv or whichever format, and a new special / common texture for gtkRadiant, probably called video or something else. There would be a videos folder under data in which the video files would be put in. Then when mapping in gtkRadiant, you'd normally make a brush and on every side of it that you want the video to play on, put this special common texture for playing video and in-game that side would act like a screen and have the video file showing on it. Another phase however would require a brush transformation in Radian, so the brush can be transformed into a screen (just like you have to transform a brush into a mover for doors and elevators), so that in its entities you can specify the address to the video file and possibly other properties like brightness, colors, and if you want the video's sound to play and at what volume as keys.

    Regarding sound, the video file's sound if it has any (if specified that wanted to play under the brush's entities) would just be played in the center of the brush you transformed into a screen. In-game the video would loop, or if that could be a good idea it could be triggered somehow as well if you set it to a trigger in-game.

    I believe this could be an interesting thing because it could make maps very pretty and be an interesting feature. Imagine making an arena and having large screens around it showing other combat scenes from that map. Also such a technology could be used to make small videos of unique texture effects and have them around rooms. For example, considering that such videos would be playable as a skybox texture, one could put a video with battleships fighting in space as a skybox, and in a map like Starship or Soylent Space when you'd look out you'd see the planets spinning, ships fighting, exploding, etc.

    Just an idea but what do you think, good or bad? Could it be given a shot in DP sometime? Also please don't take my idea the wrong way, I know this isn't something easy to make either and am not demanding that the devs do the impossible now. I know this is open source, that it brings no money and that development possibilities are limited, but this is just an idea which could be pretty nice in case it is easy enough to make and anyone feels like trying it :)
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Tue Dec 09, 2008 1:35 pm

  • It'd get overused fast, leading to very huge CPU consumption for most people.

    Also, none of the formats you mentioned can be implemented. Part of DP development is in a very oppressive country where it is not allowed to support these formats in free software, and these developers would have to fear lawsuits for software patent violations all the time (I was talking about the USA). The only possible format would be OggTheora, but seriously - who even knows how to ENCODE to that? It's basically yet another "weird format that nobody uses".
    Last edited by divVerent on Tue Dec 09, 2008 1:38 pm, edited 1 time in total.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Tue Dec 09, 2008 1:36 pm

Tue Dec 09, 2008 1:41 pm

  • Video sizes included in the map is no issue. And we COULD use a single viable video format - OggTheora.

    But as long as nobody uses that format except for some weirdos, we can't expect good (and usable, even for Windows and Mac users) encoding tools for it to appear.

    Even all the pirates encode in MPG or AVI, or possibly OGM and MKV, and in all cases with a MPEG based codec for which patent licenses would have to be bought. And movie/anime piracy is basically the only existing motor in development of high quality audio/video codecs today... (not talking about low quality, low bitrate codecs for webcam, or microphones)
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Tue Dec 09, 2008 1:59 pm

  • Animated gif (their patent has already expired).

    x264 is free and is better than all other h264 implementations.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Tue Dec 09, 2008 2:04 pm

  • divVerent wrote:It'd get overused fast, leading to very huge CPU consumption for most people.

    Also, none of the formats you mentioned can be implemented. Part of DP development is in a very oppressive country where it is not allowed to support these formats in free software, and these developers would have to fear lawsuits for software patent violations all the time (I was talking about the USA). The only possible format would be OggTheora, but seriously - who even knows how to ENCODE to that? It's basically yet another "weird format that nobody uses".


    Hmm... could playing a certain video file on many screens at the same time on the map use the same amount of CPU as for a single video (process just a single video but play it in many places)? There could then be a limit of only 3-4 videos allowed simultaneously on a map to avoid high CPU usage.

    And yeah, I was worried of a legal problem especially involving patents. Not sure when the dictatorship in the US and other countries will stop ruining good software. There are converters around though and as far as I know there should still be some video formats that you can use freely in more uncivilized countries and should not be too big in file size either. I was very much thinking the quicktime format... or the .flv format by Adobe which Youtube uses, which is of great quality and highly compressed, although its a pretty uncommon format.
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Tue Dec 09, 2008 2:08 pm

  • No way for quicktime cause it is a container and not a codec, same goes to flv.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Tue Dec 09, 2008 2:14 pm

  • There has to be a safe and usable common video format out there though. As far as I know there is avi, wmv, mpg, mp4, mov, and a few more as well which I may be missing now, so maybe something can work out. I was curious though, if in case a good video format is found which can have have a decoder in the game, how possible it would be to make it play on surfaces.
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Tue Dec 09, 2008 2:16 pm

  • x264? H.264 is based on MPEG-4, and thus covered by patents. x264 is certainly not legal to distribute in the USA.

    FLV? A MPEG-4 variant again.

    Quicktime? Apple is much more violent against patent violators than the MPEG guys. Also, they either use a MPEG-4 variant (known as "H.264" or "MPEG-4 AVC"), or a Sorenson codec that is heavily protected by patent lawyers.

    There is no safe and usable COMMON video format. The only potentially safe and space efficient format is Ogg container, OggVorbis audio, Theora video. I bet most people don't even know which file extension this combination would have... just so you get an idea of how uncommon this is. The extension would be "OGV", by the way.[1]

    Anyway, you should by now know why mplayer/ffmpeg development is hosted in Hungary, and not in a so-called "civilized" country like the USA. If the EU take over software patents too, they'll sure go to Russia.

    If the same video is played on many surface, it is same CPU usage as if it is on one surface. But mappers would put LOTS of videos in their map, and overuse it that way. Just like they already overuse reflections and put them on the tiniest and most useless surfaces, and we get like 30 reflection planes (or 4 fps, if reflections are enabled).

    [1]Not OGM, as OGM is yet another (now deprecated) container format, and commonly used for anime with MPEG-4 video, OggVorbis audio, and subtitles.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Tue Dec 09, 2008 2:50 pm

  • Matroska is also totally free.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Tue Dec 09, 2008 3:07 pm

  • Matroska is just a container format. Even AVI can be freely used, as it is just so simple that patents can't possibly be in its way.

    The problem is the codecs, not the container format. Except that the container format sometimes restricts the choice of codecs:

    • AVI does not allow Vorbis audio (there is simply no codec number for it). Because of this, AVI files almost always use MP3 as audio codec. The only viable AVI-supported audio codec is PCM (uncompressed).
    • OGM and OGV don't allow MP3 audio (but Vorbis audio would be used instead).
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Tue Dec 09, 2008 3:13 pm

  • Matroska can support anything, the problem is video because of U.S. it seems we can't use neither x264 nor xvid, only theora.

    Btw, what is darplaces dpv video format? Something based on demo format or more bik (bink video file) like?
    Last edited by Alien on Tue Dec 09, 2008 3:13 pm, edited 2 times in total.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Tue Dec 09, 2008 3:13 pm

  • divVerent wrote:Matroska is just a container format. Even AVI can be freely used, as it is just so simple that patents can't possibly be in its way.

    The problem is the codecs, not the container format. Except that the container format sometimes restricts the choice of codecs:

    • AVI does not allow Vorbis audio (there is simply no codec number for it). Because of this, AVI files almost always use MP3 as audio codec. The only viable AVI-supported audio codec is PCM (uncompressed).
    • OGM and OGV don't allow MP3 audio (but Vorbis audio would be used instead).


    In a worst case scenario, video files could only play the image without their audio if the audio couldn't be hearable from the screen's location. Video + audio would be best preferred but in games which use screens you often just see the video on them so if that wouldn't work this could be something at least.
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Tue Dec 09, 2008 8:01 pm

  • Audio is the smallest problem here.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Tue Dec 09, 2008 8:07 pm

  • Good question, what IS dpv?
    Image
    User avatar
    torus
    Forum addon
     
    Posts: 1341
    Joined: Sun Dec 24, 2006 6:59 am
    Location: USA

Tue Dec 09, 2008 8:23 pm

  • torus wrote:Good question, what IS dpv?


    DPV stands for dark places video, the original intro video used this format. I'm not sure how to create it.
    User avatar
    [-z-]
    Site Admin and Nexuiz Ninja
     
    Posts: 1794
    Joined: Mon Nov 13, 2006 12:20 am
    Location: Florida

Wed Dec 10, 2008 7:59 am

  • It's a video-only format, and only usable for very short clips, as it does not compress well. On the other hand, it is free.
    1. Open Notepad
    2. Paste: ÿþMSMSMS
    3. Save
    4. Open the file in Notepad again

    You can vary the number of "MS", so you can clearly see it's MS which is causing it.
    User avatar
    divVerent
    Site admin and keyboard killer
     
    Posts: 3809
    Joined: Thu Mar 02, 2006 4:46 pm
    Location: BRLOGENSHFEGLE

Wed Dec 10, 2008 10:34 am

  • divVerent wrote:But as long as nobody uses that format except for some weirdos, we can't expect good (and usable, even for Windows and Mac users) encoding tools for it to appear.


    ffmpeg2theora isn't exactly difficult to use and there *are* GUI frontends for it. It's for sure much more reasonable to use than the DPV encoder ;-)

    And right, Ogg Theora (and theoretically Dirac, too) are the only available free video codecs out there (XviD and x264 are open sourced, but not free due to patents). That's why Wikipedia uses Theora for all moving content, Archive.org has versions in Theora for all films and Firefox will play Ogg Theora out of the box beginning with version 3.1.

    Anyway, the biggest problem wouldn't be the choice for a format (there aren't many free formats to choose from) but the actual implementation. I wouldn't bet that DP's renderer can just stream textures to arbitrary surfaces of the world.
    User avatar
    SavageX
    Site Admin
     
    Posts: 442
    Joined: Wed Mar 01, 2006 9:34 am

Wed Dec 10, 2008 4:28 pm

  • I took a look and dirac is royalty free so not suitable either. There is LGPL'ed Snow and Tarkin.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Wed Dec 10, 2008 6:47 pm

  • Dirac is GPL-compatible, and there are several GPL/LGPL/MPL implementations out there. The problem with x264 et al is not the license the code is released under but the patents that cover the algorithms that the code implements. Dirac and Theora have been developed to remain clear of any such patents.

    Dirac is somewhat more CPU-intensive being wavelet based than the DCT based Theora though. Any long/high resolution videos will bloat the .pk3 sizes, but a 256*256 res video a few minutes long could still be practical.

    Remember RoQ video in Q3A?

    Further info:

    BBC R&D Dirac page: http://www.bbc.co.uk/rd/projects/dirac/index.shtml
    Wikipedia article on Dirac: http://en.wikipedia.org/wiki/Dirac_(codec)
    Dirac site: http://diracvideo.org/

    Theora page at xiph: http://www.theora.org/
    Wikipedia article on Theora: http://en.wikipedia.org/wiki/Theora
    Taiyo.uk
    Alien trapper
     
    Posts: 436
    Joined: Mon Apr 17, 2006 8:48 pm
    Location: Reading, IN-GER-LUND!!!

Wed Dec 10, 2008 7:13 pm

  • Well, the one which works that Taiyo.uk mentioned above could be the one, or if not the video version of the ogg system. I think the ogg video format would be most normal given the fact the audio uses .ogg so that would still use the ogg set.

    I also believe that implementing at least one video format would be important not only to play media on screens, but to be able to have an introduction video when the game starts like most other games have as well (which plays at game startup, about 1 minute long and can be skipped by pressing any key). We could then also make an artistic video that plays when you finish the Nexuiz campaign mode and such. Sounds really tempting to me :)
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Wed Dec 10, 2008 8:30 pm

  • Well, .ogg is a container format, normally .ogg files use the Theora video codec and the Vorbis audio codec.

    Could these "artistic videos" such as title/end sequences be implemented as machinimas - playing back demos that have been specifically recorded for the purpose?
    Taiyo.uk
    Alien trapper
     
    Posts: 436
    Joined: Mon Apr 17, 2006 8:48 pm
    Location: Reading, IN-GER-LUND!!!

Wed Dec 10, 2008 8:52 pm

  • Taiyo.uk wrote:Could these "artistic videos" such as title/end sequences be implemented as machinimas - playing back demos that have been specifically recorded for the purpose?


    My idea was: We record some of the best fights and sequences for the game from a multiplayer server or where's best, then put them on over a good open-sourced background song (or one made especially for the event) and make a video with it combined with the logo as well. Then, whenever you startup Nexuiz and enter full screen with it, that video would play on the entire screen. 40-45 seconds is usually best for such an intro, and as I said skipable with space or any key. That would make the game look much more solid and at the quality of commercial games imho.

    As for one for the campaign... a video with a Nexuiz character holding a cup after a battle over the final map or something like that could do. In the UT series these were done by loading a map where the camera over a set trajectory rather then a recorded video.
    User avatar
    MirceaKitsune
    Keyboard killer
     
    Posts: 593
    Joined: Thu Aug 14, 2008 6:48 am
    Location: Romania - Bucharest

Thu Dec 11, 2008 5:17 am

  • This is way different than playing video on a brush.
    Alien
    Forum addon
     
    Posts: 1212
    Joined: Tue Apr 22, 2008 7:12 am

Fri Jan 16, 2009 12:20 am

  • Q3A uses RoQ videos, which didn't use excessive amounts of CPU in 2000, and aren't going to in 2009. Decoding is mainly lots of memcpy calls. In fact it's a very easy format to decode overall, I wrote a full audio/video decoder for it and it was about 750 lines of code. You can encode them directly from AVIs with FFMPEG, Switchblade, or Quake Movie Maker.

    Theora is substantially better quality-wise (especially at high resolutions, RoQ does NOT scale well), which would be better for FMVs, but it's much more CPU-intensive, and more difficult to implement.
    Riot
    Newbie
     
    Posts: 1
    Joined: Fri Jan 16, 2009 12:09 am



Return to Nexuiz - Development




Information
  • Who is online
  • Users browsing this forum: No registered users and 1 guest