Iznogood
25th January 2011, 13:02
A) Why this post?
Since it seems that Megui has several restrictions I wanted to encode directly with x264.exe and xvid_encraw.exe for quite some time now, but for say real I had just no clue how to begin with.
I'm totally aware that there are a bunch of better batch-scripts out there, but: for non-programmers they are really hard to understand and modify the way some noob like me wants to.
So with much help of sneaker_ger (even if he maybe not really be aware of it) I finally managed to get what I wanted (well, there is one problem left and I hope you can help me troubleshooting) and this in a manner any other may understand it and can simple adjust it to his own encoding settings.
B) Needed stuff
- x264
- eac3to
- mp4box
- xvid_encraw
- lame
- ffmpeg
- your original videofiles (in the example below "video.mkv") and your corresponding avisynthscripts ("video.avs")
If you worked so far like me with Megui you'll find pretty all of it in C:\Programs\Megui\tools. The only thing missing is eac3.to.
C) Creating the batch file
First open your Editor (I don't know if it works with Notepad since it seems Notepad is saving some things like " in a way that won't work with batch files) save it as videoencode.bat and copy/paste the following text:
@ECHO OFF
C:\Programs\Videoencodingtools\x264\x264 --pass 1 --bitrate 1500 --ref 5 --direct auto --b-adapt 2 --partitions p8x8,b8x8,i8x8,i4x4
--subme 8 --me umh --sar 1:1 --stats "C:\MyVideos\Temp\mp4\video.log" --output NUL "C:\MyVideos\video.avs"
C:\Programs\Videoencodingtools\x264\x264 --pass 2 --bitrate 1500 --ref 5 --direct auto --b-adapt 2 --partitions p8x8,b8x8,i8x8,i4x4
--subme 8 --me umh --stats "C:\MyVideos\Temp\mp4\video.log" --sar 1:1 --output "C:\MyVideos\Temp\mp4\video.264" "C:\MyVideos\video.avs"
C:\Programs\Videoencodingtools\eac3to\eac3to.exe "C:\MyVideos\video.mkv" "C:\MyVideos\Temp\mp4\audiostream.aac" -quality=0.5
C:\Programs\Videoencodingtools\Megui\tools\mp4box\mp4box -add C:\MyVideos\Temp\mp4\video.264:fps=23.976 -add C:\MyVideos\Temp\mp4\audiostream.aac C:\MyVideos\video-muxed.mp4
ECHO Y | DEL C:\MyVideos\Temp\mp4\*.*
C:\Programs\Videoencodingtools\xvid_encraw\xvid_encraw -pass1 "C:\MyVideos\Temp\video.log" -qtype 0 -nopacked
-bvhq -max_bframes 1 -threads 4 -i "C:\MyVideos\video.avs" -o NUL
C:\Programs\Videoencodingtools\xvid_encraw\xvid_encraw -pass2 "C:\MyVideos\Temp\video.log" -bitrate 1000 -qtype 0 -nopacked -bvhq
-max_bframes 1 -imin 1 -bmin 1 -pmin 1 -threads 4 -i "C:\MyVideos\video.avs" -avi "C:\MyVideos\Temp\videostream.avi"
C:\Programs\Videoencodingtools\ffmpeg\ffmpeg -i C:\MyVideos\video.mkv -vn -f wav - | C:\Programs\Videoencodingtools\lame\lame.exe -m j -b 128 -q 2 - C:\MyVideos\Temp\audiostream.mp3
C:\Programs\Videoencodingtools\ffmpeg\ffmpeg -i C:\MyVideos\Temp\videostream.avi -vcodec copy -i C:\MyVideos\Temp\audiostream.mp3 -acodec copy -f avi C:\MyVideos\video-muxed.avi
ECHO Y | DEL C:\MyVideos\Temp\XVid\*.*
C:\Windows\system32\shutdown.exe -s -t 60 -c "PC will shutdown in 1 minute"
EXIT
Save it after adjusting the paths, input and output filenames and specification of your own settings for x264.exe and xvid_encraw. This is only an example, so just make it better :P.
Every time you want to encode something rightclick on videoencode.bat and [edit] it. Don't click on [open] since this will only start running the batch.
D) Explanations
The example above will create from the original video.mkv with the corresponding video.avs first an h.264/aac-mp4 and then from the same file a XVid/mp3-avi and then shutdown your pc (I wanted this for batch-encoding over night. If you don't want it, delete this line). On a sidenote: "ECHO Y" won't work if your language settings aren't english. So e.g. for german OS you have to replace it with "ECHO J" (J stands for "Ja"). This will delete the workfiles in your temp directory. If you're just erasing it because you don't know your the syntax of your language settings it maybe you'll be asked for every file to overwrite it. In this case just give every workfile another name (e.g. video1.log, video2.log, etc.). Only important if you want to encode more than one file.
Principally you can now just copy/paste the part you need as often as you want, so if you want to encode three different mkvs to avi, just erase the first five lines and copy the XVid-part two more times (don't forget to change the names of the avisynth-scripts and original videofilenames, though). So have fun testing and playing around with it.
D) Problem [solved]
The problem of changing framerate of video by muxing at the mp4-encode could be solved by adding :fps=23.976 to the mp4box-command.
Since it seems that Megui has several restrictions I wanted to encode directly with x264.exe and xvid_encraw.exe for quite some time now, but for say real I had just no clue how to begin with.
I'm totally aware that there are a bunch of better batch-scripts out there, but: for non-programmers they are really hard to understand and modify the way some noob like me wants to.
So with much help of sneaker_ger (even if he maybe not really be aware of it) I finally managed to get what I wanted (well, there is one problem left and I hope you can help me troubleshooting) and this in a manner any other may understand it and can simple adjust it to his own encoding settings.
B) Needed stuff
- x264
- eac3to
- mp4box
- xvid_encraw
- lame
- ffmpeg
- your original videofiles (in the example below "video.mkv") and your corresponding avisynthscripts ("video.avs")
If you worked so far like me with Megui you'll find pretty all of it in C:\Programs\Megui\tools. The only thing missing is eac3.to.
C) Creating the batch file
First open your Editor (I don't know if it works with Notepad since it seems Notepad is saving some things like " in a way that won't work with batch files) save it as videoencode.bat and copy/paste the following text:
@ECHO OFF
C:\Programs\Videoencodingtools\x264\x264 --pass 1 --bitrate 1500 --ref 5 --direct auto --b-adapt 2 --partitions p8x8,b8x8,i8x8,i4x4
--subme 8 --me umh --sar 1:1 --stats "C:\MyVideos\Temp\mp4\video.log" --output NUL "C:\MyVideos\video.avs"
C:\Programs\Videoencodingtools\x264\x264 --pass 2 --bitrate 1500 --ref 5 --direct auto --b-adapt 2 --partitions p8x8,b8x8,i8x8,i4x4
--subme 8 --me umh --stats "C:\MyVideos\Temp\mp4\video.log" --sar 1:1 --output "C:\MyVideos\Temp\mp4\video.264" "C:\MyVideos\video.avs"
C:\Programs\Videoencodingtools\eac3to\eac3to.exe "C:\MyVideos\video.mkv" "C:\MyVideos\Temp\mp4\audiostream.aac" -quality=0.5
C:\Programs\Videoencodingtools\Megui\tools\mp4box\mp4box -add C:\MyVideos\Temp\mp4\video.264:fps=23.976 -add C:\MyVideos\Temp\mp4\audiostream.aac C:\MyVideos\video-muxed.mp4
ECHO Y | DEL C:\MyVideos\Temp\mp4\*.*
C:\Programs\Videoencodingtools\xvid_encraw\xvid_encraw -pass1 "C:\MyVideos\Temp\video.log" -qtype 0 -nopacked
-bvhq -max_bframes 1 -threads 4 -i "C:\MyVideos\video.avs" -o NUL
C:\Programs\Videoencodingtools\xvid_encraw\xvid_encraw -pass2 "C:\MyVideos\Temp\video.log" -bitrate 1000 -qtype 0 -nopacked -bvhq
-max_bframes 1 -imin 1 -bmin 1 -pmin 1 -threads 4 -i "C:\MyVideos\video.avs" -avi "C:\MyVideos\Temp\videostream.avi"
C:\Programs\Videoencodingtools\ffmpeg\ffmpeg -i C:\MyVideos\video.mkv -vn -f wav - | C:\Programs\Videoencodingtools\lame\lame.exe -m j -b 128 -q 2 - C:\MyVideos\Temp\audiostream.mp3
C:\Programs\Videoencodingtools\ffmpeg\ffmpeg -i C:\MyVideos\Temp\videostream.avi -vcodec copy -i C:\MyVideos\Temp\audiostream.mp3 -acodec copy -f avi C:\MyVideos\video-muxed.avi
ECHO Y | DEL C:\MyVideos\Temp\XVid\*.*
C:\Windows\system32\shutdown.exe -s -t 60 -c "PC will shutdown in 1 minute"
EXIT
Save it after adjusting the paths, input and output filenames and specification of your own settings for x264.exe and xvid_encraw. This is only an example, so just make it better :P.
Every time you want to encode something rightclick on videoencode.bat and [edit] it. Don't click on [open] since this will only start running the batch.
D) Explanations
The example above will create from the original video.mkv with the corresponding video.avs first an h.264/aac-mp4 and then from the same file a XVid/mp3-avi and then shutdown your pc (I wanted this for batch-encoding over night. If you don't want it, delete this line). On a sidenote: "ECHO Y" won't work if your language settings aren't english. So e.g. for german OS you have to replace it with "ECHO J" (J stands for "Ja"). This will delete the workfiles in your temp directory. If you're just erasing it because you don't know your the syntax of your language settings it maybe you'll be asked for every file to overwrite it. In this case just give every workfile another name (e.g. video1.log, video2.log, etc.). Only important if you want to encode more than one file.
Principally you can now just copy/paste the part you need as often as you want, so if you want to encode three different mkvs to avi, just erase the first five lines and copy the XVid-part two more times (don't forget to change the names of the avisynth-scripts and original videofilenames, though). So have fun testing and playing around with it.
D) Problem [solved]
The problem of changing framerate of video by muxing at the mp4-encode could be solved by adding :fps=23.976 to the mp4box-command.