Raffriff's awesome VirtualDub tutorial

Discussion in 'Video Encoding' started by raffriff, Oct 27, 2011.

  1. Thanks a lot for making this post; it helped out a lot. When I first started using Fraps I noticed the files were huge in size so I looked up a video on YouTube to try and help me make them smaller. The video told me to use an Xvid MPEG-4 codec in VirtualDub and that seemed to work fine. Reading your post has helped a lot; the files are still being compressed and the process doesn't take nearly as long.

    Thanks again, great post!
     
  2. I seem to've run in a bit of a problem. I'm now compressing my videos in the way you describe in this post, but, when I try to import those video files into Adobe Premiere Pro CS6, an error message comes up saying "Unsupported format or damaged file". I can import any other video file just fine except for the ones I've compressed as you've described.

    I know this post is pretty old, but I'd love it if you could help me out.
     
  3. raffriff

    raffriff Moderator Staff Member Site Contributor

    >I know this post is pretty old
    Yeah, but it's still relevant I hope, and it's being kept up-to-date.

    You don't want to compress the files and then edit them - editing will be sluggish and quality will be poor. Open the Fraps files directly in Premiere.
     
  4. If I don't compress them though, Premiere takes ages loading all the files in properly which can set me back a whole day. Up to now, I've been compressing them and editing them into videos and they seem to have turned out alright. I was hoping this method would cut down on time significantly and up the quality to make the videos look more presentable.

    Am I to understand that this method of compressing is for the sole purpose of storing video files and not using them in videos? I'd be alright with that, it'd only mean I'd have to go back to my original method and redo some video capturing.
     
  5. Thalmor Wizard

    Thalmor Wizard Moderator Staff Member Site Contributor

    Never compress Fraps videos twice, quality is lost if you do this. For Fraps videos, compress them only once, so don't do this:
    Fraps -> VirtualDub -> Premiere -> Handbrake -> YouTube
    By the time it reaches youtube, quality will have been lost from all the re-encodes. Since you have Premiere, do this:
    Fraps -> Premiere -> Handbrake -> YouTube

    If you have a good enough PC, Premiere should be able to handle it fine. I have Premiere Elements and have no trouble handling Fraps videos on a PC with 8GB RAM.
     
    raffriff likes this.
  6. You guys seem to know what you're talking about and I'm really new to video editing so I'll listen to you on this and try to make a few videos without compressing the videos in VirtualDub first. I do have a strong PC and am only reluctant to try because I do work with hours of footage. I'll stop fighting you both and give it a try; I'll be sure to post my experience afterwards.

    Thank you both for the quick replies!
     
  7. raffriff

    raffriff Moderator Staff Member Site Contributor

    You can use VirtualDub in "Direct Stream Copy" mode to pre-select the footage you want to use in Premiere.
    • Video menu, Direct stream copy
    • Audio Menu, Direct stream copy
    • Scroll to first frame, {Home} (first frame of a scene you want to use in Premiere)
    • Scroll to last frame, {End}
    • Save as AVI
    • Scroll to next scene, repeat
    It's very fast, and no quality is lost, as there is no re-compression.
     
  8. raffriff

    raffriff Moderator Staff Member Site Contributor

    Re: slow Premiere, it's a bit off topic in this thread, but Google it; one of the main things is setting up your Media Cache on a fast hard drive.
     
  9. Thanks, you guys have given me plenty of reasons not to complain.

    My hard drive is 1.76TB in size and it currently only has room for 682 more GB; I am getting a removable hard drive soon unto which I'll dump big files such as my Steam folder (which is about 300 GB in size) as well as some other big folders which should leave lots of room left for my C drive. I also hear that, if you film your video files to a different hard drive than the one that holds your Fraps folder (or something like that), that this makes for a smoother time while filming. I'm not a very wasteful person when it comes to files on the PC, but I must admit it's rather clogged.

    Thanks for the tip, I hadn't thought to try and fix the issue; I thought it was just my PC not being able to keep up or something.
     
  10. Earlier this week I made 4 videos in total without compressing the footage with the Xvid codec in VirtualDub. No complications were met and I was happy with the results. Thank you both for bringing this information to light as it did help me out and will help me out in the future.
     
    Thalmor Wizard and raffriff like this.
  11. Hi raffriff,

    first off let me thank you for the time and effort you put into writing this tutorial. I used to recode my video files using avidemux, which unfortunately seems to have serious issues with fraps recordings. So looking for alternatives I've landed here at your VirtualDub tutorial. I've followed the instructions so far but when I try to export the file I receive an error message: "VirtualDub Error - The audio encoding process has prematurely exited with an error code of 1 (00000001). Check log for possible messages."

    I 'have to say that, contrary to the requirements listed by you in the tutorial, I'm forced to use NeroAAC 1.5.1 instead of 1.5.4 simply because Ahead Software doesn't seem to offer the 1.5.4 download anymore. Could this be the reason for the error? Do you know any ways to run the encoding using NeroAAC 1.5.1?

    Cheers norritt
     
  12. raffriff

    raffriff Moderator Staff Member Site Contributor

    Hi norritt, I'm glad this is helpful to you. "Error code 1" can be almost anything. Could you please post the log file ?
    1. View menu, View Log; right-click, Clear
    2. Try the encode again, and when you get the error message...
    3. View menu, View Log; right-click, Copy
    4. Paste the log in your reply. Please use the Code [<>] button for readability.
     
  13. Alright here is the log output:

    Code:
    [*] AVI: Opening file "Z:\fraps\movies\penumbra 2013-09-16 00-37-14-55.avi"
    
    [i] AVI: OpenDML hierarchical index detected on stream 0.
    
    [i] AVI: OpenDML hierarchical index detected on stream 1.
    
    [*] Beginning dub operation.
    
    [i] Dub: Input (decompression) format is: RGB888.
    
    [i] Dub: Output (compression) format is: YUV420.
    
    [i] AudioEnc: ERROR: could not open AAC encoder
    
    [i] AudioEnc: *************************************************************
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  Nero AAC Encoder                                        *
    
    [i] AudioEnc: *  Copyright 2009 Nero AG                                  *
    
    [i] AudioEnc: *  All Rights Reserved Worldwide                            *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  Package build date: Feb 18 2010                          *
    
    [i] AudioEnc: *  Package version:    1.5.4.0                              *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  See -help for a complete list of available parameters.  *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *************************************************************
    
    [i] VideoEnc: raw [info]: 1920x1080p 0:0 @ 30/1 fps (cfr)
    
    [i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3
        FastShuffle SSE4.2 AVX
    
    [i] VideoEnc: x264 [info]: profile High, level 4.0
    
    [i] VideoEnc:                                                               
    
    [i] Mux: Cannot find H264 start code
    
    [i] Mux: Error importing E:\fraps\vdub_test1.mp4.264: BitStream Not Compliant
    
    [E] Error: The audio encoding process has prematurely exited with an error
        code of 1 (00000001). Check the log for possible error messages.
    
    [*] Ending operation.
    
    
     
  14. raffriff

    raffriff Moderator Staff Member Site Contributor

    > Cannot find H264 start code
    > Error importing E:\fraps\vdub_test1.mp4.264: BitStream Not Compliant
    Look like the problem *may* be with x264, not NeroAAC. Could you give us your x264.exe version and the command line you are using?

    > The audio encoding process has prematurely exited with an error code of 1 (00000001)
    Note error messages don't always point to the real cause. It's very common for the temp files to be missing, mislocated or misnamed.
     
    Last edited: Sep 16, 2013
  15. I'm using the the version x264 0.129.2245 you linked in your tutorial (MD5 hash: 1c84c07ed01e58684a80714a2ea73bd6). I'm using the "fraps2.vdprof" also from you tutorial and havent modiefied the command lines (except pointing to the correct binary paths on my system).

    The re-exported version of the imported fraps2.vdprof looks like this:

    [P.S. I should also mention VirtualDub Version is 1.10.3 32Bit Build 35390]

    Code:
    {
        "description": "VirtualDub external encoder profile collection",
        "externalEncoders": {
            "sets": {
                "mp4 x264+aac (fraps2)": {
                    "videoEncoder": "V x264 r18",
                    "audioEncoder": "A nero aac q035",
                    "multiplexer": "M mp4box",
                    "description": "mp4",
                    "extension": "mp4",
                    "processPartial": true,
                    "useOutputAsTemp": false
                }
            },
            "profiles": {
                "A nero aac q035": {
                    "name": "A nero aac q035",
                    "program": "C:\\Program Files (x86)\\VirtualDub\\NeroAAC\\win32\\neroAacEnc.exe",
                    "commandArguments": "-q 0.35 -ignorelength -if - -of \"%(tempaudiofile)\"",
                    "outputFilename": "%(outputname).aac",
                    "type": 1,
                    "inputFormat": 1,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": true,
                    "bypassCompression": true,
                    "predeleteOutputFile": true
                },
                "M mp4box": {
                    "name": "M mp4box",
                    "program": "C:\\Program Files (x86)\\GPAC\\MP4Box.exe",
                    "commandArguments": "-add \"%(tempvideofile)\" -add \"%(tempaudiofile)\" \"%(outputname)\" -fps %(fps)",
                    "outputFilename": "",
                    "type": 2,
                    "inputFormat": 0,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": true,
                    "bypassCompression": false,
                    "predeleteOutputFile": true
                },
                "V x264 r18": {
                    "name": "V x264 r18",
                    "program": "C:\\Program Files (x86)\\VirtualDub\\x264\\x264.exe",
                    "commandArguments": "--crf 19 --preset veryfast --demuxer raw --input-res %(width)x%(height) --fps %(fpsnum)/%(fpsden) --colormatrix bt709 -o \"%(tempvideofile)\" -",
                    "outputFilename": "%(outputname).264",
                    "type": 0,
                    "inputFormat": 0,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": true,
                    "bypassCompression": false,
                    "predeleteOutputFile": true
                }
            }
        }
    }
    
    P.S.: I tried both Video -> Color depth -> Output format -> 24bit RGB (888) and 32bit RGB (888)
     
  16. raffriff

    raffriff Moderator Staff Member Site Contributor

    Thanks for anticipating my next questions. I'm mystified on this one.

    OK, first checking the Nero issue:
    I download Nero 1.5.1 and...the version info on neroAacEnc.exe shows 1.5.4 :confused:
    Comparing to my existing (v 1.5.4) neroAacEnc.exe, it's identical, byte for byte.
    Changelog.txt also shows current version as 1.5.4.
    So the Web page is wrong, and the Zip file is named incorrectly - the update should be called "1.5.4"

    Next, to find out if the temporary video & audio files are being created properly, I made a new encoder set with no muxer...so after encoding, you should have "<file>.mp4.aac" and "<file>.mp4.264" in your output folder. The audio file should be playable, but the video file may not - I got only a few scrambled frames. MediaInfo should be read the usual information though - codec, bitrate, resolution, duration etc
    Code:
    {
        "description": "VirtualDub external encoder profile collection",
        "externalEncoders": {
            "sets": {
                "NULL MUX x264 r18 +aac": {
                    "videoEncoder": "V x264 r18",
                    "audioEncoder": "A nero aac q03",
                    "multiplexer": "",
                    "description": "mp4",
                    "extension": "mp4",
                    "processPartial": true,
                    "useOutputAsTemp": false
                }
            }
        }
    } 
     
    Last edited: Sep 17, 2013
  17. Thanks for helping out =)

    Yep that's it the zip on the server is named incorrectly. After installation the file is versioned 1.5.4 on my system as well.

    Actually I dont. Even without the muxer I get a single mp4 file of 30KB size. To be sure I even deleted the old profile so the NULL MUX is the only one left.

    This is this log:
    Code:
    [*] AVI: Opening file "Z:\fraps\movies\FlashPlayerPlugin_11_8_800_168
        2013-09-16 02-57-15-73.avi"
    
    [i] AVI: OpenDML hierarchical index detected on stream 0.
    
    [i] AVI: OpenDML hierarchical index detected on stream 1.
    
    [*] Beginning dub operation.
    
    [i] Dub: Input (decompression) format is: RGB888.
    
    [i] Dub: Output (compression) format is: YUV420.
    
    [i] AudioEnc: ERROR: could not open AAC encoder
    
    [i] AudioEnc: *************************************************************
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  Nero AAC Encoder                                        *
    
    [i] AudioEnc: *  Copyright 2009 Nero AG                                  *
    
    [i] AudioEnc: *  All Rights Reserved Worldwide                            *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  Package build date: Feb 18 2010                          *
    
    [i] AudioEnc: *  Package version:    1.5.4.0                              *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *  See -help for a complete list of available parameters.  *
    
    [i] AudioEnc: *                                                          *
    
    [i] AudioEnc: *************************************************************
    
    [i] VideoEnc: raw [info]: 1920x1080p 0:0 @ 30000/1001 fps (cfr)
    
    [i] VideoEnc: x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3
        FastShuffle SSE4.2 AVX
    
    [i] VideoEnc: x264 [info]: profile High, level 4.0
    
    [i] VideoEnc: 1 frames: 9.62 fps, 8315.84 kb/s
    
    [i] VideoEnc:                                                      
    
    [i] VideoEnc:                                                              
    
    [i] VideoEnc: x264 [info]: frame I:1    Avg QP:18.50  size: 33961
    
    [i] VideoEnc: x264 [info]: mb I  I16..4: 63.5% 31.0%  5.6%
    
    [i] VideoEnc: x264 [info]: 8x8 transform intra:31.0%
    
    [i] VideoEnc: x264 [info]: coded y,uvDC,uvAC intra: 27.9% 18.7% 2.1%
    
    [i] VideoEnc: x264 [info]: i16 v,h,dc,p: 70% 19%  7%  3%
    
    [i] VideoEnc: x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 26% 30%  2%  3%
        2%  4%  2%  5%
    
    [i] VideoEnc: x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 28% 13%  4%  4%
        4%  6%  4%  5%
    
    [i] VideoEnc: x264 [info]: i8c dc,h,v,p: 73% 11% 15%  1%
    
    [i] VideoEnc: x264 [info]: kb/s:8142.50
    
    [i] VideoEnc: encoded 1 frames, 9.62 fps, 8315.84 kb/s
    
    [E] Error: The audio encoding process has prematurely exited with an error
        code of 1 (00000001). Check the log for possible error messages.
    
    [*] Ending operation.

    There is one funny thing (at least its funny to me) maybe I'm interpreting the log incorrectly but it says " Dub: Output (compression) format is: YUV420.". Shouldn't this be "24bit RGB(888)?. I triple checked that I had selected the correct video output format it's definitly set to "24bit RGB(888)".

    One more thing: What is the correct setting for Video -> Compression. I left the default which is "Uncompressed RGB/YCbCr". But there is also an Option "Fraps Video Decompressor", which from the semantics kinda makes sense for Fraps recordings. I tried that one too just for the sake of it - didn't change anything though.
     
  18. raffriff

    raffriff Moderator Staff Member Site Contributor

    Ah, now we see this:
    >AudioEnc: ERROR: could not open AAC encoder

    Currently VirtualDub doesn't show us the entire log, only the most recent events - which is annoying when the first non-fatal error happens, then a bunch of other things happen, and when the final, fatal error occurs it's been scrolled off the top of the log.

    More later...
     
  19. raffriff

    raffriff Moderator Staff Member Site Contributor

    We won't see any error messages if the log is filled with useless chatter. With a few changes we can have a much quieter log:
    • MP4Box: add -quiet to the command line; it should be the first option.
    • x264: add --quiet --no-progress to the command line, anywhere before the final -o option.
    • NeroAAC: disable Redirect standard error to log.
    Hopefully these changes will not quiet the log so much that it hides any actual error messages. If they do, revert one change at a time.

    But wait, there's more...for better error reporting, we can wrap our executable in batch files; this lets us send extra debugging info to the log.

    Here's a batch file that wraps the muxer MP4Box. Please save the code below somewhere (such as your VirtualDub folder) as M-mp4-mp4box.bat. To call it, use a copy of your regular V-dub MP4Box muxer and set the program location to this file instead of to MP4Box.exe. Make sure you call it with the following arguments in order:
    "%(tempvideofile)" "%(tempaudiofile)" %(fps) "%(outputname)"

    Note you will need to update the CONFIGURATION SECTION below
    Code:
    @echo off
    
    ::** CONFIGURATION SECTION **
    set mp4box="C:\<path>\MP4Box.exe"
    ::** END CONFIGURATION SECTION **
    
    @echo **** MUXING: MP4Box ***********
    
    if (%1)==() goto BADARG
    if (%2)==() goto BADARG
    if (%3)==() goto BADARG
    if (%4)==() goto BADARG
    
    if not exist %1 goto BADARG
    if not exist %2 goto BADARG
    
    if /I (%~x4) neq (.mp4) goto BADEXT
    
    @echo %time%
    @echo on
    %mp4box% -quiet -add %1 -add %2 %4 -fps %3
    @echo off
    @echo %time%
    if %ERRORLEVEL% geq 1 goto DUMPARGS
    exit 0
    
    :BADARG
    @echo MUXER ERROR: BAD OR MISSING ARGUMENT
    goto DUMPARGS
    
    :BADEXT
    @echo MUXER ERROR: OUTPUT FILE EXTENSION NOT .MP4
    goto DUMPARGS
    
    :DUMPARGS
    @echo USAGE video-src-path audio-src-path fps output-path
    @echo video-src = %1
    @echo audio-src = %2
    @echo fps = %3
    @echo output = %4
    exit 1
    

    Here's another batch file to wrap NeroAAC. Please save it as A-nero-aac.bat.
    You need to add some new encoder command arguments:
    0.35 %(channels) %(audioprecision) %(samplingrate) "%(tempaudiofile)"
    The first argument is "quality," (see here for an explanation) and can be set as you please.

    The batch file will now exit with an error message if the number of channels, bit width (precision) or sample rate are illegal. I don't know exactly what values are legal for Nero, so I guessed ;)

    Again, you will need to update the CONFIGURATION SECTION
    Code:
    @echo off
    
    ::** CONFIGURATION SECTION **
    set nero_aac="C:\<path>\neroAacEnc.exe"
    ::** END CONFIGURATION SECTION **
    
    @echo **** AUDIO: NeroAAC ***********
    
    ::** USAGE q-factor %(channels) %(audioprecision) %(samplingrate) output-path
    if (%1)==() goto BADARG
    if (%2)==() goto BADARG
    if (%3)==() goto BADARG
    if (%4)==() goto BADARG
    if (%5)==() goto BADARG
    
    if %1 leq 0 goto BADARG
    if %1 gtr 1 goto BADARG
    if %2 leq 0 goto BADARG
    if %2 gtr 8 goto BADARG
    if %3 lss 16 goto BADARG
    if %3 gtr 128 goto BADARG
    if %4 lss 44100 goto BADARG
    if %4 gtr 96000 goto BADARG
    
    @echo %time%
    @echo on
    %nero_aac% -q %1 -ignorelength -if - -of %5
    @echo off
    @echo %time%
    if %ERRORLEVEL% geq 1 goto DUMPARGS
    exit 0
    
    :BADARG
    @echo AUDIO ERROR: BAD OR MISSING ARGUMENT
    goto DUMPARGS
    
    :DUMPARGS
    @echo USAGE q-factor channels bitwidth samplingrate output-path
    @echo q-factor = %1
    @echo channels = %2
    @echo bitwidth = %3
    @echo samplingrate = %4
    @echo output = %5
    exit 1

    I'll leave x264.exe to another time. OK now, here is a new encoder set with all these changes included. Save as <anything>.vdprof and import as explained here. Once all this is done, the log should be much more helpful :cool:
    Code:
    {
        "description": "VirtualDub external encoder profile collection",
        "externalEncoders": {
            "sets": {
                "mp4 bat x264 r18 709 +aac (quiet)": {
                    "videoEncoder": "V x264 r18 709 (quiet)",
                    "audioEncoder": "A bat nero aac q035 (quiet)",
                    "multiplexer": "M bat mp4box",
                    "description": "mp4",
                    "extension": "mp4",
                    "processPartial": true,
                    "useOutputAsTemp": false
                }
            },
            "profiles": {
                "A bat nero aac q035 (quiet)": {
                    "name": "A bat nero aac q035 (quiet)",
                    "program": "C:\\<path>\\A-nero-aac.bat",
                    "commandArguments": "0.35 %(channels) %(audioprecision) %(samplingrate) \"%(tempaudiofile)\"",
                    "outputFilename": "%(outputname).aac",
                    "type": 1,
                    "inputFormat": 1,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": false,
                    "bypassCompression": true,
                    "predeleteOutputFile": true
                },
                "V x264 r18 709 (quiet)": {
                    "name": "V x264 r18 709 (quiet)",
                    "program": "C:\\<path>\\x264.exe",
                    "commandArguments": "--quiet --no-progress --crf 18 --preset veryfast --demuxer raw --input-res %(width)x%(height) --fps %(fpsnum)/%(fpsden) --colorprim bt709 --transfer bt709 --colormatrix bt709 -o \"%(tempvideofile)\" -",
                    "outputFilename": "%(outputname).264",
                    "type": 0,
                    "inputFormat": 0,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": true,
                    "bypassCompression": false,
                    "predeleteOutputFile": true
                },
                "M bat mp4box": {
                    "name": "M bat mp4box",
                    "program": "C:\\<path>\\M-mp4-mp4box.bat",
                    "commandArguments": "\"%(tempvideofile)\" \"%(tempaudiofile)\" \"%(outputname)\" %(fps)",
                    "outputFilename": "",
                    "type": 2,
                    "inputFormat": 0,
                    "checkReturnCode": true,
                    "logStdout": true,
                    "logStderr": true,
                    "bypassCompression": false,
                    "predeleteOutputFile": true
                }
            }
        }
    }
    
    EDIT 17 Sep 2013 - add neroaac batch wrapper.
    EDIT 17 Sep 2013 - added input validation to neroaac batch wrapper.
    EDIT 19 Sep 2013 - added some explanation
    EDIT 20 Sep 2013 - revised neroaac max bitwidth
     
    Last edited: Sep 20, 2013
  20. raffriff

    raffriff Moderator Staff Member Site Contributor

    Returning to the problem at hand,
    >AudioEnc: ERROR: could not open AAC encoder
    I wonder if there is some kind of permissions problem. Anyway, the batch file wrappers above should help.
     

Share This Page