Mix Guides‎ > ‎

Encoding on Command Line

who?
- people who like to learn encoding on cli or command prompt
- windows os (operating system) user
- basic familiarity with windows command prompt 
- already have familiarity with encoding especially extracting the audio of the source and muxing with mkvmergeGUI

what?
- you need the following:
  x264 -> http://x264.nl/
  ffmpeg -> http://ffmpeg.zeranoe.com/builds/ (get the static builds and when you extracted it look for the ffmpeg.exe on "bin" folder)
- next step is to put all x264.exe, ffmpeg.exe, neroAacEnc.exe, neroAacDec.exe, neroAacTag.exe
  on a directory for this example will put them all to "C:\" directory

how?
- ok lets start ill only give you the ways that i know and the easiest/basics ways for me
  and note that as far as i know there is no proper order on adding the commands 
  put your source video file and extracted source audio (you can use MkvCleaver or MkvExtractGUI-2 for audio extracting) on C:\ directory too
  go to command prompt and go to dir C:\ and type this 

  note: myoutfile.mkv and myinputfile.mkv are just examples so you have to name this entries with your souce video located on C:\

  for CRF encoding:
 
x264 --preset veryslow --tune animation --crf 27 --vf resize:704,400 -o "myoutfile.mkv" "myinputfile.mkv"
  or if you want to change aq mode to 2 then use the following it has the command --aq-mode 2 
x264 --preset veryslow --tune animation --crf 27 --aq-mode 2 --vf resize:704,400 -o "myoutfile.mkv" "myinputfile.mkv"

  for 2-pass encoding:
  first pass (type the following and press enter)
x264 --preset veryslow --tune animation --pass 1 --slow-firstpass --bitrate 300 --aq-mode 2 --vf resize:640,360 -o "myoutfile.mkv" "myinputfile.mkv"
  second pass (type the following and press enter this is not thesame as first pass because of the 
command --pass 2 is not --pass 1 as the first pass)
x264 --preset veryslow --tune animation --pass 2 --slow-firstpass --bitrate 300 --aq-mode 2 --vf resize:640,360 -o "myoutfile.mkv" "myinputfile.mkv"
  for audio encoding 
  since neroAacEnc only inputs audio in WAV format we have to first use ffmpeg and here is how
ffmpeg -i x.aac x.wav
  where x.aac is your source audio so in this example you got aac and x.wav is the output
  now you got the WAV file its time to encode it on NeroAacEnc like this
neroAacEnc -2pass -br 40000 -if <input file> -of <output file>
  the -br option is on bits per second not kilobits per second so thats why 40000 value is in bits or its 40kbps
  and alternative way to encode audio is to use piping think of piping as making the commands all in one line like this
ffmpeg -i input.aac -f wav - | neroAacEnc -ignorelength -q 0.2 -if - -of output.aac
  or you can encode with vorbis audio too using ffmpeg only (my favorite method)
ffmpeg -i inputaudio.aac -acodec libvorbis -aq -1.0 outputaudio.ogg

  then after you got the video and audio just mux them through mkvmergeGUI then thats it your done!!!

References?
-  if you want/need to know (more) the settings 
or go to command prompt and type this
x264 --help
or for full help type this
x264 --fullhelp>thisIsIt.txt
where thisIsIt.txt will contain the full help file so ye you can even name thisIsIt.txt as another name like Hoorray.txt
and after this just open the thisIsIt.txt file using wordpad to view it on a formatted way unlike viewing with notepad

  nero aac -> see the readme.txt 
  or go to command prompt and type this 
neroAacEnc -help
 or if you want to save the help file to a txt file then just enter in the command prompt
neroAacEnc -help>thisIsIt.txt
    
Tricks?
- ok if you know batch files you know you can just make a bat file like EncodeThis.bat and it has the commands inside that bat file like this
x264 --preset veryslow --tune animation --crf 27 --aq-mode 2 --vf resize:704,400 -o "myoutfile.mkv" "myinputfile.mkv"
ffmpeg -i x.aac -f wav - | neroAacEnc -2pass -br 40000 -if - -of x.aac
  in this way you can save yourself from typing a lot on the command prompt and just edit the bat file like a text file and just put the bat file on the directory that the encoding softwares resides in this case C:\ and after that just double click the bat file to run the commands

ok thats it your done!