Adventure Game Studio

AGS Development => Engine Development => Topic started by: KodiakBehr on Wed 02/09/2015 19:07:59

Title: Best video format for AGS
Post by: KodiakBehr on Wed 02/09/2015 19:07:59
Was debating which forum to post this in, so no worries if it needs relocation.

Until now, we've been implementing video in .ogv format for the usual obvious reasons.  Problem is no matter how the video is compiled, the framerate just isn't as smooth in AGS as I would like.

With this in mind, is there any reason why we wouldn't want to use a MP4 with the H.264 codec instead?  That's pretty much as universal as it gets, isn't it?
Title: Re: Best video format for AGS
Post by: Cassiebsg on Wed 02/09/2015 21:09:57
What about xvid, isn't that one free too?
Title: Re: Best video format for AGS
Post by: selmiak on Wed 02/09/2015 23:05:30
xvid is getting old and has its flaws. MP4 with H.264 inside or .MKV with H.264 inside should be first on the list of video compatibility for AGS, especially with the new HD resolutions in AGS. After that of course XVID.
Title: Re: Best video format for AGS
Post by: Problem on Thu 03/09/2015 08:38:48
Is there a way to check from inside AGS if a video has been successfully played? (I don't think so, because PlayVideo doesn't return anything.) This would allow us to use H.264 and have a fallback OGV if for some reason it doesn't play.
Title: Re: Best video format for AGS
Post by: abstauber on Thu 03/09/2015 08:52:29
Using h.264 would be no option for commercial developers (same as mp3), because of the pretty steep licensing fees.
Title: Re: Best video format for AGS
Post by: Monsieur OUXX on Thu 03/09/2015 10:20:35
Also, does H.264 do lossless? That's important for low-res games.
Title: Re: Best video format for AGS
Post by: Snarky on Thu 03/09/2015 10:33:55
I would argue that even in a low-resolution game, there are very few use-cases for lossless video. Video is much more forgiving of minor compression artifacts, since because each frame is displayed for a very short moment, you don't have time to study it and notice them. A high-quality lossy encoding should be indistinguishable in practice and save a lot of storage. If you do need absolutely lossless video, you can just import the frames as sprites and display them as an animation.

In any case, x264 apparently allows encoding lossless into h.264 format: https://stackoverflow.com/questions/768999/what-is-a-good-lossless-video-codec
Title: Re: Best video format for AGS
Post by: Monsieur OUXX on Fri 04/09/2015 13:10:50
Quote from: Snarky on Thu 03/09/2015 10:33:55
I would argue that even in a low-resolution game, there are very few use-cases for lossless video. Video is much more forgiving of minor compression artifacts, since because each frame is displayed for a very short moment, you don't have time to study it and notice them. A high-quality lossy encoding should be indistinguishable in practice and save a lot of storage. If you do need absolutely lossless video, you can just import the frames as sprites and display them as an animation.

In any case, x264 apparently allows encoding lossless into h.264 format: https://stackoverflow.com/questions/768999/what-is-a-good-lossless-video-codec

yeah but sometimes you want to do sequences that look like actual gameplay, but without going through the hassle of scripting the whole thing. And in a pixel-art game, the transition between "real" gameplay" and video is not seemless if the codec is not lossless. That was a problem in many 90's games, such as Heart of Darkness.

If H.264 allows encapsulating lossless codecs such as x264, then I'm happy.
Title: Re: Best video format for AGS
Post by: abstauber on Fri 04/09/2015 13:40:00
About h.264 again: according to the MPEG-LA, everything under 100.000 units is free, after that, it's 0.20$ per "encoder", which I suppose can be interpreted as a game. So for most of us, h.264 pricing shouldn't be a big deal - even for the commercial devs.

Btw. this is also a quite interesting read:
http://www.gamasutra.com/view/news/170671/Indepth_Playing_with_video.php

Title: Re: Best video format for AGS
Post by: KodiakBehr on Sat 05/09/2015 03:31:54
Thanks for pointing out this information to us -- this is something I'm afraid I would have overlooked otherwise.  I guess we'll pursue the H.264 and see about obtaining a license.
Title: Re: Best video format for AGS
Post by: abstauber on Sat 05/09/2015 11:42:51
Honestly this was more a pointer towards OGV ;)
But since I haven't worked with videos in AGS since .flc, I obviously have no idea how good the Theora implementation is.
Title: Re: Best video format for AGS
Post by: Problem on Sat 05/09/2015 12:08:27
It's pretty bad unfortunately. I don't know why, but the built-in video playback just doesn't run smoothly, at least for high resolution games. On some PCs even the audio stutters. Other video formats work much better, maybe because they are not played by AGS? Of course the best solution would be to improve the performance of the built-in OGV playback, because it doesn't depend on any codecs being installed, but for now we'll try our luck with H.264.
I don't know much about Windows codecs, is it safe to assume that the H.264 codec is installed on current Windows machines?
Title: Re: Best video format for AGS
Post by: KodiakBehr on Wed 09/09/2015 13:49:37
H.264 is supposed to be pretty universal.  However, AGS delivered an interesting error when it attempted to play an external .mp4.  Note that I have no trouble running this .mp4 outside of AGS, but when being called through AGS, it says:

(http://i.imgur.com/JUbQ45I.png)

This is a message generally associated with a filter/codec absence.  But the video runs just fine outside of AGS, so I'm at a loss for explaining why things are different inside.  Is this an engine bug?
Title: Re: Best video format for AGS
Post by: Cassiebsg on Wed 09/09/2015 19:07:05
My guess is that Allegro does not have the codec to render the video, and therefor gives that error.
You have no idea how many head bangs I have given cause VirtualDub refuses to load any mp4 file, or mkv, or... >:(
Title: Re: Best video format for AGS
Post by: Problem on Wed 09/09/2015 19:48:15
This has nothing to do with Allegro. The AGS manual says that AGS plays anything supported by Windows Media Player.
Title: Re: Best video format for AGS
Post by: Monsieur OUXX on Fri 11/09/2015 16:39:56
Quote from: Problem on Wed 09/09/2015 19:48:15
This has nothing to do with Allegro. The AGS manual says that AGS plays anything supported by Windows Media Player.
You said the vido plays well outside of AGS, but with what player? For example if you use VLC they have their own codecs embedded, they don't care about what's on your system.
Title: Re: Best video format for AGS
Post by: KodiakBehr on Sun 13/09/2015 03:20:35
It ran perfectly in Windows Media Player.  With no idea why we're having issues with MP4s in AGS, we're currently trying to make do with Theora, which is good for the universality and the lack of codec licensing issues.  We're dropping the framerate and resolution a fair bit, but it still chugs...just a little less so.
Title: Re: Best video format for AGS
Post by: Cassiebsg on Sun 13/09/2015 09:00:37
I'm not sure what frame rate you are using, but keep in mind that animated series/movies only normally use 15fps. Your video is mostly still pics, so you could probably drop the rate fairly low with still decent show... or import the "spites" and code the intro in AGS. (Which am currently considering for my own intro, since I haven't had much success playing AGS videos on my system so far).
Title: Re: Best video format for AGS
Post by: Problem on Sun 13/09/2015 16:55:22
The camera zooms and parallax layers in the video can't be done in AGS at this resolution, so the intro would have to be a lot simpler without a video. We've dropped the framerate a bit, which makes the video playback more stable. 15fps is too low though, the camera movement doesn't look good this way. But I think with careful testing we can find a compromise between video quality and smooth playback.
Title: Re: Best video format for AGS
Post by: abstauber on Mon 14/09/2015 09:01:06
Did you already try AJA direct3d plugin?
http://www.adventuregamestudio.co.uk/forums/index.php?topic=45348.0

Since it seems like it addresses D3D directly, you might see better performance - or at least you can corner the culprit ;)
Title: Re: Best video format for AGS
Post by: Problem on Mon 14/09/2015 09:42:27
I didn't know this plugin. Looks interesting, though I guess it will only be useful for the Windows build.
Title: Re: Best video format for AGS
Post by: Problem on Fri 18/09/2015 20:25:58
So, in case anyone else is interested: The solution for Theora videos in AGS seems to be playing a silent video and having the audio as a separate .ogg file. This way the video stutters a lot less. And even if it still stutters a little, the audio remains intact and the timing is still correct. The video keeps up even if it has to skip frames.
So even if the video is slightly choppy on some systems, we can get rid of the annoying audio dropouts.

I'll do a couple more tests, but so far this seems to be the best solution that doesn't depend on any installed codecs.