Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: naltimari on Wed 14/05/2008 19:37:46

Title: Anyone using Avisynth?
Post by: naltimari on Wed 14/05/2008 19:37:46
I'm still investigating, but in my game I intend to use Avisynth (http://avisynth.org) to handle the videos. In short, Avisynth is an open-source app that acts as a proxy to WMP. Which means that in AGS, you just have to call PlayVideo and point it to an '.avs' file, which is an Avisynth 'script'.

I'm sure this explanation is overly simplified, and my english is not very good, so you'd rather visit the site (http://avisynth.org) to understand it better than take my word for it. But the advantages, from an AGS game designer perspective, are:

As soon as I'm done with it, I intend to post a new thread explaining it, but if you guys want to do some research on your own and exchange information via PM, that would be awesome.

Avisynth has a huge following among video editors, and a huge community also. I think it would be a great addition to an AGS game designer's toolbox.
Title: Re: Anyone using Avisynth?
Post by: Rui 'Trovatore' Pires on Wed 14/05/2008 22:16:26
QuoteAvisynth could be used to play video 'inside' the game screen

This in particular interests me A LOT. And if regular AGS processing could go on in the meantime (even if non-interactible - a cutscene would do) it would be even perfect...
Title: Re: Anyone using Avisynth?
Post by: GarageGothic on Wed 14/05/2008 22:31:12
QuoteInstead of just playing videos full-screen, Avisynth could be used to play video 'inside' the game screen, if only you take a snapshot of the screen prior to playing the video, then 'composite' the video inside the snapshot using the Avisynth scripting language.

But pressumedly this wouldn't work during gameplay? You could just have static screens while the video plays? E.g. the player character sits down and turns on the tv. The video plays. He gets up and you resume gameplay.

Nevetheless, it's an interesting technology. And whether it's Avisynth or Ogg Theora, I'd be happy to see an AGS video format not dependent on installed codecs.
Title: Re: Anyone using Avisynth?
Post by: Rui 'Trovatore' Pires on Wed 14/05/2008 22:44:12
But I'd like to, say have a border around the video. Maybe even some AGS-scripted subtitles, to be played during the video playback. Something for a Temujin-style game, for instance.

Of course it would be awsome if we could also have something Urban-Runner style - actually be able to play as the movie progresses. But at the moment you can fake it with lots of frames AND it's not something that's likely to be made any time soon, realistically, so it's ok.
Title: Re: Anyone using Avisynth?
Post by: naltimari on Wed 14/05/2008 22:48:28
Quote from: Rui 'Trovatore' Pires on Wed 14/05/2008 22:16:26
This in particular interests me A LOT. And if regular AGS processing could go on in the meantime (even if non-interactible - a cutscene would do) it would be even perfect...

Unless i'm mistaken, while PlayVideo is working its magic, the screen is no longer controlled by AGS, but by WMP. Then, to mix an AGS cutscene and video you would have to use an Avisynth script, because it HAS the control of the screen (although indirectly, via WMP).

But you would have to convert your cutscene into a 'video', in order to Avisynth to 'play'. Avisynth scripting language is pretty powerful, but I wonder if it's worth the trouble to code a cutscene in it... but i guess it's possible, if you really like to experiment... ;)

My suggestion was waaaay simpler than that, just take a snapshot of the room, for example, one that has a large LCD screen next to your character, and then, inside Avisynth script, compose the snapshot (which would be a PNG file sitting somewhere) with the video, using Avisynth commands to size & position the video right inside the LCD screen.
Title: Re: Anyone using Avisynth?
Post by: Rui 'Trovatore' Pires on Wed 14/05/2008 22:51:17
That would be enough for the "border" effect. ;D (yeah, I know I can just put the borders in the video, but I don't really like that "look")

Just wish I could AGS-code subtitles for while movies display... ah well, maybe this Xmas Santa will surprise me! :D
Title: Re: Anyone using Avisynth?
Post by: naltimari on Wed 14/05/2008 22:56:29
Quote from: Rui 'Trovatore' Pires on Wed 14/05/2008 22:51:17
Just wish I could AGS-code subtitles for while movies display... ah well, maybe this Xmas Santa will surprise me! :D

This certainly can be done, all you have to do is make an avisynth script with text commands (the subtitles) and fire it up in AGS with PlayVideo. Since avisynth scripts are text files, you can even generate them on the fly, prior to calling PlayVideo.
Title: Re: Anyone using Avisynth?
Post by: Rui 'Trovatore' Pires on Wed 14/05/2008 22:59:42
Hmmm, I couldn't control them from AGS, with all the slight nuances available... but nevertheless, it might be more than enough for my needs - or should I say dreams, as I don't *need* any of this now.

Super!!!
Title: Re: Anyone using Avisynth?
Post by: GarageGothic on Wed 14/05/2008 23:01:04
Quote from: naltimari on Wed 14/05/2008 22:56:29This certainly can be done, all you have to do is make an avisynth script with text commands (the subtitles) and fire it up in AGS with PlayVideo. Since avisynth scripts are text files, you can even generate them on the fly, prior to calling PlayVideo.

If it was possible to parse the name of the AGS translation file to Avisynth, would Avisynth scripts be able to display language-specific subtitles? 
Title: Re: Anyone using Avisynth?
Post by: Rui 'Trovatore' Pires on Wed 14/05/2008 23:03:07
Hmm, that could probably be done by generating the script on-the-fly, as suggested, or just by having as many scripts as there are languages, and then in AGS finding out which tranlsation is being used and play the correct script.
Title: Re: Anyone using Avisynth?
Post by: GarageGothic on Wed 14/05/2008 23:12:04
Ah yes, if the script was generated on-the-fly with AGS file commands, then the alternate language Strings could be retrieved directly from the translation file itself.
Title: Re: Anyone using Avisynth?
Post by: naltimari on Wed 14/05/2008 23:21:55
Quote from: GarageGothic on Wed 14/05/2008 23:12:04
Ah yes, if the script was generated on-the-fly with AGS file commands, then the alternate language Strings could be retrieved directly from the translation file itself.

Yes. Avisynth supports 'traditional' subtitle file formats, like .srt, .ssa, etc, so you would have to supply one subtitle file for each language, and generate the script on-the-fly to match the movie and the appropriate language.

It could be done with multiple audio tracks too. I mean, you could have one video track and several audio tracks, and have avisynth play the selected audio track according to the language it is running on (supposing each audio track is in a different language).

This really opens up a lot of possibilites... :)
Title: Re: Anyone using Avisynth?
Post by: LimpingFish on Thu 15/05/2008 02:31:56
Indeed. :)

I'll be interested to see where this goes, and how practical it would be to use.
Title: Re: Anyone using Avisynth?
Post by: TheMagician on Thu 15/05/2008 15:15:25
This really sounds interesting.
Especially the "one video - multiple audio files" thing.

Thanks Naltimari for bringing this to our attention.
Title: Re: Anyone using Avisynth?
Post by: Dualnames on Thu 15/05/2008 15:23:42
Good job, that might actually kill us all... in a good way. Good job for pointing it out.