forum

Alternative method for Youtube videos

posted
Total Posts
15
Topic Starter
IppE
While Remco32's/Jeffro's tutorial on how to create nice looking Youtube videos for osu! is fine and dandy, I'd like to present a more barebones and in my opinion more effective way of making videos for youtube. Mainly aimed at getting VPT encoding workflow simpler.

Fear not, we'll only be using lightweight freeware software (assuming you already have something to record the video with)

Required software:
Custom build of x264
Avisynth

Step 1: Preparation

For this "tutorial" to work correctly, I'm going to assume you're using Fraps to capture the video. Other recorders are fine as long as you're able to get the video open with Avisynth.

Record the video in a 16:9 resolution, that is 1280x720, 1920x1080 and so forth. To get osu! to run in 1280x720, you'll need to edit the osu!.username.cfg file located in the installation folder of osu!. Record with at least 30fps framerate, 60fps is acceptable as well but you'll need to convert that down to 30fps prior to uploading to ensure audio stays in sync (Youtube has a bad habit of messing up with framerate conversions). Make sure your game runs smoothly while recording, no one wants to watch laggy gameplay videos.

Now that you got your video recorded, lets get on the real business part.

Step 2: Avisynth script creation

Avisynth isn't your everyday video editor. It is a frameserver, this means it opens a file, decodes it, edits it on the fly and passes it onto some other program to further edit it or encode it. It also has no native interface, it works entirely on scripts. Thats not a bad thing though, this makes it lightweight and versatile. Without further ado, lets get to work.

First off, open up notepad and type in the following:
AVISource("path to video.avi")
FadeIO(30)
ConvertToYV12(matrix="Rec709")

While mostly self explanatory, I'll briefly explain what each part does:

:WORDS:
AVISource(), is a so called "source filter". It loads video and audio to the script which the rest of the script will work on. If fraps outputted the raw video in two parts, you can join them by simply stringing the commands like so: AVISource("video1.avi")++AVISource("video2.avi")

FadeIO(), a combination of the filters FadeIn() and FadeOut(). It will create a 30 frame long fade in/out for the video (30 frames on a 30fps video equals 1 second)

ConvertToYV12(), The default decoder for Fraps video likes to output the video in RGB24. x264 however (and nearly 90% of all digital videos) work in the YUV colorspace. This function converts the colorspace of the video to a variant of YUV, also known as YUV420. The Rec709 thing defines which colormatrix to use when converting from RGB to YUV, and the BT.709/Rec 709 is the HDTV standard for that.

Now your script should look something like this.

Save it as an .avs file, not .txt (save as -> format -> all files and add the .avs extension)

Step 3: x264 commandline creation

Again, open notepad. This time, type in the following:
x264 --preset veryslow --crf 20 --acodec vorbis --aquality 70 --colormatrix bt709 --output "video.mkv" input.avs

Again, I'll explain what this does:

MORE :WORDS:
x264 refers to the .exe file you recieved in the .7z that you should've downloaded from the required software link (this is a custom build of x264 including the x264-audio component we're using to make things simpler)

--preset veryslow, Defines the preset x264 will use to encode the video. Presets define the speed of the encode as their names may give out and they also define the filesize when using CRF ratecontrol. The slower the preset, the smaller the file will be (in sane limits of course), but also the slower the encode will be. veryslow and slower are the most balanced presets, but there is a good selection of presets you can pick the one that suits your needs the best. Remember, the preset does not define the quality with CRF ratecontrol.

--crf 20, Tells x264 to encode the video with a Constant Ratefactor. What it means in simpler terms is that x264 will try to keep the same relative quality through the video and the quality being an arbitrary quality of 20. The "quality scale" ranges from 0 to 51, with 0 being a lossless file and 51 being the worst quality possible. We'll want to keep the quality at somewhat high level without going overboard, so 19-21 is the range we're looking at.

--acodec vorbis, Defines the audio codec to be used by the internal audio encoding component of the custom x264 build. We're using Vorbis because it is the best one available for the time being.

--aquality 70, Defines the quality of the audio encoded. Value of 70 ends up being a ~200kbps VBR audio, which is more than enough for our needs and transparent to the source in 99% of the cases.

--colormatrix bt709, Like in the avisynth script above, defines which colormatrix to use when converting the video back to RGB upon decode.

--output "video.mkv", self explanatory, the output video you want to upload to youtube when done. Matroska is being used due to wide support of formats and low overhead for maximum efficiency.

This you shall save as a .bat file, preferrably in the same folder where the x264.exe and the avisynth scripts are located. I for example have all of this stuff in the fraps output movies folder.

Step 4: Magic time

Now that you've created the .bat file, you shall click on it. If everything went like it was supposed to, you should now see a window like this:


If not, you probably did something wrong and should double check everything.

After that is done, you can upload your video to youtube for all your friends to see!

Part 5: More magics

Once you get the hang of creating avisynth scripts and bat files for x264, you can start making long quotas of videos to encode by adding new lines to the .bat file with new command line, like so:



Feedback and help to make it easier to read is much appreciated, I'm not a master of formatting.



HURR DURR
If you for some reason want to use a newer build of x264, a 64bit x264 or just some other kind of x264 that doesn't have the built in (and not broken) audio encoding component, read on.

STUFF YOU'LL NEED:
avs2pipe (avs2pipemod probably works as well but idgaf)
MKVToolNix
oggenc2 (pick a variant that tickles you fancy)


OMG WHAT DO I DO WITH ALL THESE THINGS?

Fear not, this is still not rocket science;
avs2pipe you simply extract either the avs2pipe_gcc.exe or avs2pipe_vs.exe to the folder where you have x264 and all the other things.
MKVToolNix you install, and then move the mkvmerge.exe file from it's installation folder (C:\Program Files (x86)\MKVtoolnix by default) to the same folder as the other stuff again.
oggenc2 you also just extract to the folder mentioned above.

NOW WHAT?
You craft a new .bat file, or edit an existing one and type in the following:
avs2pipe_gcc audio input.avs > output.wav
avs2pipe_gcc video input.avs | x264 --preset veryslow --crf 20 --input-csp yuv420p --output-csp i420 --colormatrix bt709 --stdin y4m - --output "temp.mkv"
oggenc2 -q 7 --ignorelength output.wav
mkvmerge -o "video.mkv" temp.mkv output.ogg

Here I used the gcc version of avs2pipe and a 64-bit build of x264. Save the file and double click it, hopefully you see things happening.
As ~amazing~ as this is, as it allows x264 to use more RAM, it doesn't show ETA. But you don't need that anyway.

After encoding, you may want to delete the temporary output.wav, output.ogg and temp.mkv files.
thelewa
This is also known as the smart way of making youtube videos
Mara
sexy

Nice translated version right there, bro.
Aqo
Thanks a lot for this guide, going to try it starting from the next video upload.
Frizz
Been using this for a long time, works like charm =))
ychao
Very helpful. Good to know an alternative.
Amefuri Koneko
I don't get it ,what's the profit? Why go through all the trouble when you can just compress frapsed video in 5min using VirtualDub or any similar sofrware?
Valentiino

Ami Furi Koneko wrote:

I don't get it ,what's the profit? Why go through all the trouble when you can just compress frapsed video in 5min using VirtualDub or any similar sofrware?
All the trouble? If you have ever just used command line and notepad, it takes like 2-4 minutes to set it up and working

x264 is way faster and easily managable vs any of those "out"dated programs and provides much smaller and higher quality videos for youtube. (No, we all don't have 100mbps upload speeds)
Topic Starter
IppE

Valentiino wrote:

All the trouble? If you have ever just used command line and notepad, it takes like 2-4 minutes to set it up and working

x264 is way faster and easily managable vs any of those "out"dated programs and provides much smaller and higher quality videos for youtube. (No, we all don't have 100mbps upload speeds)
You can use x264 with VirtualDub as well, this just eliminates the VDub part.
Espionage724
nice guide :) i usually just use Evolve to record video and just re-encode with HandBrake
Meru
Anyone know why everytime I tried to encode it always stuck at 0.2 - 0.3%?

well... I'm following the step correctly dunno why
zertap
This deserves a bump. Awesome tutorial.
One of those is 8,75Gb video file and one 582Mb
decide yourself which is which.
Metro
Bump for awesomeness and great justice.
Frizz
Bumping due to how useful this guide is and since I need to learn using this method again.
Topic Starter
IppE
I should probably try to pack a all-in-one pack for all the needed software and stuff as well as making the avs2pipe part the main deal seeing as the last build with working internal audio encoder from JEEB is around 2 years old at this point.

Also making a wiki page instead of a thread that constantly gets pushed down might be something worth doing, we'll see.
Please sign in to reply.

New reply