When you capture an AVI movie in X-Plane, a few things can make the video capture look bad:

  • X-Plane might not be able to compress and save the frames to disk as fast as they’re being recorded. In this case you’ll see a message on screen about dropped frames. (This isn’t a huge problem because the AVI compressor is multi-core, so it can usually keep up on modern machines.)
  • X-Plane itself might not be able to hit the framerate you’ve selected in the AVI capture settings.
  • If X-Plane’s framerate is fluctuating, the AVI movie can’t record that properly, because AVI files run at a fixed framerate.*

There is another way to make a movie, however, that will give you much better quality: record your replay.

When you record an AVI movie in replay, X-Plane slows down its playback of the replay as necessary to guarantee that it can render and compress each frame at the framerate you have selected for your AVI.  If you’ve picked very high rendering settings, you’ll see X-Plane running in what appears to be slow motion while capturing an AVI in replay mode.

When you play back the AVI, motion will be in “normal time” and will be frame-perfect, even if you’ve picked a high framerate, large movie size, and heavy rendering settings.**

* This wasn’t a problem with the older QuickTime capture; QuickTime movies can have variable framerate.

** This mode was available in X-Plane 10.36 via a special button; in 10.40 it is the only way to record an AVI in replay mode. The change was made to simplify the process of making a high quality movie.

About Ben Supnik

Ben is a software engineer who works on X-Plane; he spends most of his days drinking coffee and swearing at the computer -- sometimes at the same time.

26 comments on “Making Perfect AVIs

  1. ” This wasn’t a problem with the older QuickTime capture; QuickTime movies can have variable framerate.”

    I wonder why was Quicktime dumped…

    1. We used the old QT API (it’s what there was when we wrote the code).
      There wasn’t a 64-bit QT for Windows.
      The 64-bit QT for Mac was a total rewrite of the API.
      There is no QT for Linux.

      So faced with writing new code to re-adopt a solution that was going to be 64-bit for a single platform and 30% of our users, we dumped it for AVI recording, which:
      – Runs in every OS, 64 bits and 32 bits and
      – Doesn’t require the installation of any third party components.

  2. One thing worth mention is that in order to edit this in i.e. Adobe Premiere you would need to convert the .avi files before import and edit.. Seems there is something with the encoding that does not play right, you get sound when importing but not picture. So If there is no way possible to change x-plane settings to be .mp4 I would suggest Freemake Video Converter http://www.freemake.com/free_video_converter/

    1. Have you re-checked this in -recent- betas? There was definitely a bug in AVI writing in beta 1 where the AVI files wouldn’t open on some platforms.

      I’d say file a bug, but realistically if Premiere won’t open our AVI files there is -no- way I fix that bug unless someone points out a specific technical problem.

      The issue here is that the AVI file is under-specified – there are multiple ways to write the index and a few de-facto conventions made necessary by widely prevalent buggy AVI writers a long time ago.

      Right now our AVI files work with:
      – Windows media player
      – VLC
      – Handbrake
      – QuickTime 7
      – AV/Kit
      – Chrome and Firefox

      This means a user can watch them on all platforms and has free options to convert them to other files. Past that I can only pursue compatibility problems given a technical issue (like “hey, Premiere requires the buffer size field in the RIFF header to be a power of 2”). Without that much detail, I’d have to attempt to guess/reverse-engineer the problem in Premiere’s AVI reader.

      1. There is nothing really important Ben, as the work around is pretty simple. But Premiere has the same issue with i.e. GoPro files which needs to be first exported in GoPro Studio in order to be used in Premiere. I also remember there was a issue with the avi files recorded from Fraps too, not sure how this is now.

        But nevertheless, it still easy and fast to convert before edit anyway. Better use your powers for greater and way more urgent needs within X-Plane.

  3. I’m wondering if anyone else is seeing this. When I try and record an avi from a playback it records the bottom left quadrant of the screen as an upside down movie. Yes, I’ve already filed a bug report. Yes, it’s still broken in 10.40b10.

    1. Turn off “record in the background” and this will go away. It’s a _driver bug_, and turning off the use of async capture fixes it, at some perf cost.

  4. Hi Ben, is good to know this.
    Where can found more info about reply mode? I dont know much about this module and i do not found detailed info.
    What lenght duration can reply from this reply module? Have a max or minimum?
    I see that when in reply mode play, cars are stopped, this is a bug ?
    Thank you!!

    1. I don’t know the replay max length – if it’s not in the manual, ask Austin – he coded it. It’s been in the sim for as long as I’ve used X-Plane (15 years?)

      The cars do stop – this is a _design limitation_. Basically we’re not willing to burn the memory to save the position of every single car.

    2. Thank you i know it s been in sim from time, i asked because some time i saw that can t reply the total leght of flight, and i do not investigate to much.

      About a car moving is realy crazy to save the position of every car, but as sugestion maybe manange traffic in general if the system and code allow it. something like traffic on / traffic stop. Nobody want cars in same position, but will be very fine to see cars not stoped all to take photos of your landing as in the “end of world” 🙂 .Thank you.

  5. The new AVI possibility is fine, but it doesn’t record sound. For making video’s I make use of NV Shadowplay feature, but then I see the ugly replay bar (and a mousecursor, but that seems a bug of NV). Is there a way to get around this?

    1. Right – like QT, we don’t record sound in AVI because we can’t get a “sound tap” to record via OpenAL.

      If you use an external recorder, all of the overlays will show up, including custom cursors that are “drawn” onto the sim.

      The solution is to capture sound using a third party program, use us for AVI capture, and then combine them in an editing program.

      1. The only point I can see of using shell formats like AVI is to get good synchronization of audio and video (as its name suggests), no ? AVI without an A sounds a bit bizarre. If sound is an issue, why not using h.264 in a MP4 container for video only ?
        On the other hand what about the following for OpenAL recording ?
        ——–
        ALCdevice* Device;
        ALCdevice* CaptureDevice;

        bool InitCapture()
        {
        if (alcIsExtensionPresent(Device, “ALC_EXT_CAPTURE”) == AL_FALSE)
        return false;
        CaptureDevice = alcCaptureOpenDevice(NULL, 44100, AL_FORMAT_MONO16, 44100);
        if (!CaptureDevice)
        return false;
        return true;
        }

        void ShutdownCapture()
        {
        alcCaptureCloseDevice(CaptureDevice);
        }
        ———-
        (http://loulou.developpez.com/tutoriels/openal/capture/)

        1. Mmmmm…I must admit, ALC_EXT_CAPTURE _does_ appear to be widely available now! I’ll take a look. When we -first- did QT record, ALC_EXT_capture didn’t exist.

          This won’t be for 1040 though – we’re out of time for 1040.

          1. Maybe I did read too fast, but I was triggered by the following sentence in the link of your link:

            http://kcat.strangesoft.net/openal-extensions/SOFT_loopback.txt

            “This extension allows an application to read back OpenAL’s rendered audio
            instead of having it output to an audio device on the system. Unextended
            OpenAL will output audio to an audio device, with no mechanism to allow an
            application to divert the audio somewhere else.”

            But to me it is only needed to capture the sound that is played by the speakers and there is no need to divert the audiostream to a file.

          2. This assumes that for each OS we can find a reliable way to (1) identify the underlying audio device that OpenAL is playing to and (2) then capture from it. Some audio hardware may have no facility to do this, and some hardware may have no -reliable- way to do this. The loop-back extension fixes this by routing audio directly off of OpenAL.

          3. I don’t quite see the issue, it records the INPUT to the default (because we passed NULL) device.
            This input can easily be recorded to a vector and then to disk as a .wav (or more sophisticated) sound file (this is explained with sample code in the link I provided), which can then be packed with the video stream in an AVI container.

            On the other hand I completely agree that video recording is not what should be most expected from a flight simulator…

  6. Could it be possible in the future to support encoding via hardware acceleration?
    E.g. Intel Quick Sync Video, nVidia NVENC (Shadowplay) and AMD Video Coding Engine (VCE)

  7. AVI files run at a fixed framerate

    Just feel the irresistible urge to nitpick here… AVI is “only” a container format that can have pretty much anything inside – including video track(s) encoded using a multitude of variable frame rate capable codecs. I admit that your point is valid, though; realtime *encoding* of a variable frame rate video is extremely hard.

    1. Hi Markku,

      I’m going to nitpick your nitpick! Do you mean “variable FRAMERATE” or “variable BITRATE”? The two are hugely different.

      If you mean “variable framerate”, how do you encode separate per-frame _durations_ into an AVI file? I see framerate fields in the AVI header and the ‘strh’ header, but nothing in the per-frame data or the index. If you know of a spec that indicates that this is possible, please send me a link. (If it’s an _extension_ to .avi we’d have to investigate whether it has wide support.)

      Real-time encoding of variable _framerate_ video is quite trivial _if_ your container format supports it – that’s what QuickTime did – it’s simply a matter of writing out different frame times on the meta-data of each frame.

      Writing out variable _bitrate_ video is not very hard either – both our old and new implementation do this. Here are some things that are tricky:

      – Fixed bitrate video when the codec isn’t “naturally” fixed bit-rate (like DV). This means dynamically adjusting the compression ratios to hit target bit rates dynamically and possibly re-compressing frames.
      – Variable bitrate audio.

      These are tricky because the ‘natural’ (and simple) assumption of audio and video is that audio is a fixed bytes-per-sample and video has variably sized frames (in bytes) over a fixed time period. These are also the assumptions of .avi.

      1. If you mean “variable framerate”, how do you encode separate per-frame _durations_ into an AVI file? I see framerate fields in the AVI header and the ‘strh’ header, but nothing in the per-frame data or the index.

        My comment was based on memory alone – something I should never do online, but apparently tend to do quite often. The experience I have with video encoding is already over a decade in the past, so my memory can easily fail me. And after a quick refresher on the subject, it seems my earlier comment was indeed wrong; AVI really does not support VFR, I was thinking MPEG instead 🙁

        If you know of a spec that indicates that this is possible, please send me a link. (If it’s an _extension_ to .avi we’d have to investigate whether it has wide support.)

        Of course, in theory I believe you *could* hack around this limitation by having some insanely high frame rate for the video stream and providing empty chunks for the frames you’re “skipping”. But yeah… probably not the best way to spend developer time 😀

        Have you considered using Matroska-containers? It is under a free license, players are available on virtually every platform (Windows 10 even supposedly has native support for the format baked in). And it supports VFR-streams 🙂

        1. I did not consider .mkv containers. My goal was:
          – Low time to develop video output.
          – Low complexity (e.g. not bring in a ton of other libraries).

          After a brief search of other libraries out there, I came to the conclusion that a simple AVI MJPEG recording (using libjpeg) was the best option. Users can transcode to virtually anything later.

Comments are closed.