VirtualDub: save direct to MP4 (Fraps to YouTube) with external encoders

raffriff

Moderator
Staff member
Site Contributor
#1
Sometimes with AVI videos uploaded to YouTube, the audio gets cut off early. Uploading as MP4 seems to help. MP4+H.264+AAC is one of YouTube's recommended formats.

Here's one way to get VirtualDub to create MP4's directly, instead of remuxing with another program. Remuxing is easier but takes more time.

Using VirtualDub external encoders is difficult at first. I have tried to make this as easy to follow as possible, and I hope you find it helpful. Please let me know how this works if you try it! You need VirtualDub version 1.10 or higher to get the "external encoders" feature.

This has been tested with:
VirtualDub (32-bit) version 1.10.2 (June 03 2012) and 1.10.3 (Dec 27, 2012)
Nero AAC version 1.5.4.0 (Feb 18 2010)

x264 (32bit, 8bit-depth) version 0.125.2200 (May 23 2012) & 0.129.2245 (Jan 10 2013)
MP4Box version 0.4.6 (March 2, 2011) and 0.5.0 (May 25, 2012)

UPDATE: 22-Jun-2013: using ffmpeg as an external encoder - see post #28.

UPDATE: 12-Dec-2013: using batch files with an external encoders - see post #46.

Thanks to the VirtualDub forum:

INSTALLATION:
  1. copy all the text in the "code" box below and save anywhere as "fraps2.vdprof"
    (or download from Dropbox)
    .
  2. VirtualDub Options menu, External Encoders, Import, "fraps2.vdprof"
    .
  3. search program folders for "neroAacEnc.exe" (you may have it already);if not found, download it from the link above
    1. Options menu, External encoders, Encoders tab
    2. Click on "A nero aac q035," Edit
    3. Update Program location by browsing to neroAacEnc.exe.
    4. Hit OK.
      .
  4. search program folders for "x264.exe" (you may have it already);if not found, download it from the link above
    1. Same as before, go to the Encoders tab
    2. Click on "V x264 r18," Edit
    3. Update Program location by browsing to x264.exe.
    4. Hit OK
      .
  5. search program folders for "MP4Box.exe" (you may have it already);if not found, download it from the link above
    1. Same as before, go to the Encoders tab
    2. Click on "M mp4box," Edit
    3. Update Program location by browsing to MP4Box.exe.
    4. Hit OK
USAGE:
  1. source video:
    • file name must not have any "#" characters; it confuses MP4Box
    • must have an audio track
      • a silent track is OK
      • use Audio from another file if required
      • recommend stereo, 16 bit, 44100 or 48000 Hz; if not, encode may fail mysteriously.
  2. VirtualDub Video menu, Color Depth, Output format =
    "24 bit RGB (888)" or "32 Bit RGB (888)"
    (others may work too; these have been tested)
  3. VirtualDub File menu, Save as Avi.. right-click file name, copy
  4. VirtualDub File menu, Export-> Using external encoder
    (or
    File menu, Queue batch operation-> Export using external encoder)
    1. Select "mp4 x264+aac (fraps2)" as your Encoder Set
    2. optional: paste file name copied in step 3 (why? see post #31)
    3. file extension must be "mp4"
    4. file name must not have any "#" characters
    5. hit Save
NOTE:

If working with Rec.709 video, keep it in YUV color space if possible. This can be done by staying in fast recompress mode if you don't need filters, or using only YUV filters. In the Filters dialog box, check "show image formats" and try to avoid using filters that convert the source to RGB.

Converting RGB to Rec.601 for external encoders.
  • Source = RGB or YUV-709 upsampled to RGB (many VfW and DirectShow decoders do this)
  • Full processing mode
  • Filter 1: Convert Format 4:2:0 YV12 Rec.709
  • Filter 2: Alias Format color=Rec.601, range=no change
  • for x264.exe, use VUI flags --colorprim bt709 --transfer bt709 --colormatrix bt709
Save as "fraps2.vdprof" (see Installation step 1)
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": "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": "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": "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
            }
        }
    }
}
Update 12 Apr 2013 version "#3a" - updated description to be more accurate
Update 21 Jun 2013 version "#3b" - replace description with "mp4" and simplified instructions
Update 17 July 2013 version 2 - simplified instructions again (no more editing the .vdprof file)
Update 11 August 2013 - removed tune=zerolatency
Update 13 August 2013 - YUV mode
Update 02 September 2013 - Converting to Rec.601
 
Last edited:
#2
Hey

I have done all the instructions in this post, but when I go to export I get the message

CLI: unable to launch video encoder: the system can not find the path specified.

I honestly don't know where I went wrong?
 

raffriff

Moderator
Staff member
Site Contributor
#4
Hey
I have done all the instructions in this post, but when I go to export I get the message
CLI: unable to launch video encoder: the system can not find the path specified.
I honestly don't know where I went wrong?
Check the file paths:
find & modify "C:\\<whatever>\\x264.exe" (etc) to point to the actual file locations.

Do you mind explaining how to do this whole process as a batch operation? I'm not sure if it's done the same way as your old guide with this process.
Thanks again!
Resh, yes it works! File, Queue batch operation, Export with external encoder.
 
#5
Thanks for the reply! I was actually hoping for the kind of quick batch operation that retains filename, etc. similar to what happens when encoding without external encoders. Saves a lot more time than having to drag a file into VirtualDub, queue for batch export, type a name with .mp4, etc. and so on.

Still very glad I can do this though! I've actually been using most of your FRAPS to YouTube settings for archiving and further editing in Premiere Pro since it still has great quality with smaller file sizes. Compared to something like your ARCHIVE & INTERMEDIATE CLIPS settings which have considerably larger file sizes compared to your For YouTube settings. If you have any other recommended settings that I might have missed that would be better suited for my purposes, I would love to hear from you!

Thanks again very much!
 

raffriff

Moderator
Staff member
Site Contributor
#6
Pro tip: when saving, select Save as AVI but don't hit OK - just select, right-click & copy the file name that Virtualdub gives you. Then cancel, Export & paste the name, remembering to add ".mp4"
 
#7
Hey raffriff, my friend pointed me to this forum when he told me my files are pretty big and that i could lower it by close to a gig. Anyways i dont see the option external encoders
i use virtual dub to compress my videos using x264xfw without any audio compression and 40min-50 min files end up being 2gb or so. I dont really mind except it just makes the upload take longer which is a hassle with bad upload speeds here in aus. I also upload the videos at 1080P, i have screenshots of the settings i use too if it can help you help me.
 

raffriff

Moderator
Staff member
Site Contributor
#8
Hi Major, external encoding is still more difficult to use, and most times encoding in VirtualDub the normal way is fine. I've written about x264 settings in detail in my thread Fraps to YouTube with H.264. I just made a new post about file size there:
Some people have mentioned that the resulting output file is too big. OK, here's how the recommended settings affect output file size in x264 and x264vfw
  • preset=veryfast (fast encoding) or medium (slow encoding but 20% smaller)
  • fast decode=ON (seems to help YouTube compatibility) or OFF (makes file about 10% smaller)
  • rate control=Single pass, CRF
  • ratefactor =16 (excellent quality) to as high as 19 (good quality, 50% smaller file)
  • check "VirtualDub hack" in your x264vfw options in using VirtualDub
  • optional: add the following in Extra commands for best color (more here):
    --colormatrix bt709
  • Compressing the audio [as explained in Raffriff's awesome VirtualDub tutorial] makes the file another 10% smaller.
So choosing all the "smaller file" options above should make a big difference. It's worth a try, although I personally prefer not using them - and living with a larger file.
You can play with the encoding parameters with the external encoding method too; in "fraps1.vdprof" above, find...
"commandArguments": "--crf 19 --preset veryfast ...
...and adjust as needed. This is left as an exercise (you are on your own!)
 
Last edited:
#9
Hi Major, external encoding is still more difficult to use, and most times encoding in VirtualDub the normal way is fine. I've written about x264 settings in detail in my thread Fraps to YouTube with H.264. I just made a new post about file size there:


You can play with the encoding parameters with the external encoding method too; in "fraps1.vdprof" above, find...
"commandArguments": "--crf 19 --preset veryfast ...
...and adjust as needed. This is left as an exercise (you are on your own!)
Damn lol, well i will post my screenshots of my current settings (you might have to zoom in but it should be good)
audi i dont have a compression for in vdub. I would like to keep video quality as it is when im currently compressing its mainly audio im concerned about as well, and trying to save as mp4 with it but like i said i cant do step 5 because i cant see the option for it in my version of vdub which is 1.9.11
 

Attachments

Last edited by a moderator:
#11
Major, you are getting off the topic of this thread, which is about using external encoders with VirtualDub - not about the details of H.264 settings or audio compression.

I talk all about H.264 settings and their tradeoffs in:
Fraps to YouTube using H.264 / x264vfw

I explain how to set up audio compression (what to download, etc) in:
RaffRiff's 'awesome' VirtualDub tutorial
i apologize for that. i might give this a try in the future, for now the way im doing it just seems to do the trick and is simple enough i guess
i pretty much just followed this guide but its a couple years old now
 

raffriff

Moderator
Staff member
Site Contributor
#14
You need VirtualDub version 1.10 or higher to get the "external encoders" feature. Sorry, I should have made that more clear! (fixed)
 

raffriff

Moderator
Staff member
Site Contributor
#16
You need to get VirtualDub 1.10 or higher to work with this feature. Also I recommend the 32-bit version of VirtualDub, as there are more filters (video effects) available for it. I haven't tested the settings described in the top post with 64-bit, and I don't plan to.

Again, let me emphasize that working with external encoders is not very easy. If it's too frustrating and you need your video in MP4 format, try remuxing instead, as I describe here. It's easy and fast (50-100 fps)
 
#18
You need to get VirtualDub 1.10 or higher to work with this feature. Also I recommend the 32-bit version of VirtualDub, as there are more filters (video effects) available for it. I haven't tested the settings described in the top post with 64-bit, and I don't plan to.

Again, let me emphasize that working with external encoders is not very easy. If it's too frustrating and you need your video in MP4 format, try remuxing instead, as I describe here. It's easy and fast (50-100 fps)
Also why is working with external encoders not easy? Seems to be decompressing just fine.
 

raffriff

Moderator
Staff member
Site Contributor
#19
Question why is the video and audio settings uncompressed in your guide, but audio set to 44.1 and 128k? Most use 48k...
I find uncompressed audio to be more compatible, especially with YouTube and video editors - any case where the file must be read and re-compressed. Uncompressed audio is not supported in MP4, so you must use MP3 or AAC compression. AAC is better.

I don't recall recommending 44.1kHz audio; I say, following YouTube's advice, to leave it at the original sampling rate, whether that's 44100 or 48000, as there is always a slight quality loss in the conversion process (nowadays, very slight indeed). Some video editing programs will convert to 48000 - and 48000 *is* better if you are doing processing like speed adjustment.

The sample rate on the Fraps video depends on the game and your sound card - Fraps copies the audio & video bits just as they come from the computer.

Why 128k? I dunno - it's good enough. Actually now I'm using 192k for AAC and 256k for MP3.

Also why is working with external encoders not easy? Seems to be decompressing just fine.
If it's easy for you, great. It's not easy for everyone.
 
#20
I find uncompressed audio to be more compatible, especially with YouTube and video editors - any case where the file must be read and re-compressed. Uncompressed audio is not supported in MP4, so you must use MP3 or AAC compression. AAC is better.

I don't recall recommending 44.1kHz audio; I say, following YouTube's advice, to leave it at the original sampling rate, whether that's 44100 or 48000, as there is always a slight quality loss in the conversion process (nowadays, very slight indeed). Some video editing programs will convert to 48000 - and 48000 *is* better if you are doing processing like speed adjustment.

The sample rate on the Fraps video depends on the game and your sound card - Fraps copies the audio & video bits just as they come from the computer.

Why 128k? I dunno - it's good enough. Actually now I'm using 192k for AAC and 256k for MP3.

If it's easy for you, great. It's not easy for everyone.
*****EDIT**** - Hmm somethings wrong I looked at the details of the video file and the audio is 89kbps, Video seems fine at 15000kbps~ Any ideas why the audio messed up? The original fraps audio is 1536kbps.



Yeah I went into your code and changed 44100 to 48000 and 128 to 192, I record both sound and my voice at 48k

Took me about 34 minutes to do the encoding for a 38 minute video, not bad. :)
It was 80.7gb before it is now 3.96gb.

Do you have any filters you can recommend?
 
Top