Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 Encoder GUIs

Reply
 
Thread Tools Search this Thread Display Modes
Old 18th May 2008, 23:42   #1  |  Link
Puu
Registered User
 
Join Date: Aug 2007
Posts: 1
Batch file to encode x264 movies

hello
I have got the following settings:

Quote:
--pass 3 --bitrate 5500 --stats ".stats" --min-keyint 20 --ref 10 --mixed-refs --bframes 16 --b-pyramid --bime --weightb --direct temporal --subme 7 --trellis 2 --analyse all --8x8dct --qpmin 3 --ratetol 4 --qcomp 0.7 --b-bias 1 --me esa --merange 30 --threads 2 --thread-input --progress --no-psnr --no-ssim --output "output" "input"
I'd like to implement them into a batch file to encode x264 files. The bad thing is just, that i dont have any idea how the encoding works, so i have no idea what the batch file has to look like.

Would be great if someone of you could help me here.

Greets
Puu
Puu is offline   Reply With Quote
Old 20th May 2008, 06:24   #2  |  Link
refulgentis
Registered User
 
Join Date: Apr 2008
Posts: 56
Quote:
Originally Posted by Puu View Post
hello
I have got the following settings:



I'd like to implement them into a batch file to encode x264 files. The bad thing is just, that i dont have any idea how the encoding works, so i have no idea what the batch file has to look like.

Would be great if someone of you could help me here.

Greets
Puu
from another forum I'm on, using mplayer to pipe video to x264:
Quote:
Originally Posted by deebo
Not meant to be exhaustive in any way, I was just testing some encoding on linux since i have a spare dualcore server.
It worked fine, cant tell the difference to average windows avisynth based encode, and as a bonus my desktop
computer is no longer at 100% cpu 24/7

I'll try to do some of that SH magic and make the script a bit interactive (naturally its easier to do some other stuff
on windows, like bitrate calculations with evodemux etc methods). Like source, codec types, fps, etc parameters!

Heres a simple sh script i use to encode

Quote:
[pre]
#!/bin/sh

#source for pass 1
mplayer -really-quiet -demuxer lavf -vc ffvc1 -nosound -fps 23.976 -sws 10 \
-vf crop=1912:1072,scale=1280:720 -vo yuv4mpeg:file=video.y4m video.EVO &

#x264 for pass 1
x264 --pass 1 --bitrate XXXX --stats ".stats" --bframes 3 --b-pyramid --direct auto \
--deblock -3:-3 --subme 1 --analyse none --me dia --threads auto --cqmfile "prestige.cfg" \
--progress --no-psnr --no-ssim --output /dev/null video.y4m

#source for pass 2
mplayer -really-quiet -demuxer lavf -vc ffvc1 -nosound -fps 23.976 -sws 10 \
-vf crop=1912:1072,scale=1280:720 -vo yuv4mpeg:file=video.y4m video.EVO &

#x264 for pass 2
x264 --pass 2 --bitrate XXXX --stats ".stats" --ref 5 --mixed-refs --no-fast-pskip \
--bframes 3 --b-pyramid --b-rdo --bime --weightb --direct auto --deblock -3:-3 --subme 7 \
--analyse all --8x8dct --trellis 1 --aq-strength 0.3 --me umh --threads auto \
--cqmfile "prestige.cfg" --progress --no-psnr --no-ssim --output encode.mkv video.y4m
[/pre]
What do you need?
- mplayer (build it yourself to get all the fancy features)
- x264 (i built it myself to get the adaptive quants patch)

What do you need to do?
- create a sandbox for your encodes "mkdir /whatever/wherever"
- create a named pipe for mplayer output where x264 can read from
Quote:
[pre]
# mkfifo video.y4m
[/pre]
Setup mplayer pipe output
- find out how to decode your source with mplayer, im using a .evo so i need a specific demuxer "-demuxer lavf", the .evo contains vc1 so i need the wvc1 codec "-vc ffvc1"
- set fps "-fps 23.976"
- set output, x264 accepts yuv2 or yuv4mpeg so we use "-vo yuv4mpeg:file=video.y4m" so mplayer decodes to the fifo pipe we created
- filter how you see fit, in the example i crop 4 pixels from every direction "-vf crop=1912:1072" with a software spline scaler "-sws10", and i also scale the resulting video to 720 ",scale=1280,720"
-- (note that by default the crop filter crops around the edges, you can set the crop point with "crop=1912:1072:x:y" where x and y are the coordinates, see manual for more info)
-- see manual for more video filter info

Setup x264
- do it like you would in windows, nothing to it

NOTE! you have to output the video twice to the pipe, once for each pass as each pass exhausts the pipe. mplayer just plays the video into the pipe

Leave any tips and criticism in the thread!
refulgentis is offline   Reply With Quote
Old 20th May 2008, 06:25   #3  |  Link
refulgentis
Registered User
 
Join Date: Apr 2008
Posts: 56
here's one I use in os x, using mencoder
Quote:
#!/bin/sh

(( number= $# ))


for (( i = 0; i < $number; i++ ))
do
mencoder "$1" -of rawvideo -vf harddup -mc 0 -noskip -oac faac -ovc x264 -x264encopts crf=23:bframes=3:subq=5:me=umh:threads=4:cabac=0:level=31:ref=1:vbv-maxrate=4500:vbv-bufsize=2000 -o "$1".264 && mencoder "$1" -of rawaudio -vf harddup -mc 0 -noskip -ovc copy -oac faac -faacopts mpeg=4:br=128bject=2 -channels 2 -srate 48000 -o "$1".aac && mp4box -add "$1".aac#audio -add "$1".264#video -inter 0 -fps 23.976 "/Volumes/500/Source media/Conversions/mp4box.mp4" && ffmpeg -i "/Volumes/500/Source media/Conversions/mp4box.mp4" -y -vcodec copy -acodec copy "$1".mp4 && rm "/Volumes/500/Source media/Conversions/mp4box.mp4" && rm "$1".264 && rm "$1".aac
shift
done
this dumps video without any attempt to sync to x264, then dumps audio without any attempt to sync to faac. both files are placed in the directory of the original file, and have the same filename except .264 or .aac placed at the end.

then, mp4box muxes them, and then I pass the resulting mp4 back through ffmpeg. mp4box doesn't seem to write proper information for quicktime to understand the video files, and I can't get ffmpeg to mux my raw .264s properly.

this is perfect if you need itunes/quicktime compatible MP4s, and nearly every other situation doesn't work in special cases (ffmpeg can't decode mkvs with attachments properly and has segmentation faults often, mp4creator does something else odd that I can't remember). this situation works with everything i've thrown at it so far, but I haven't gotten too exotic yet, just .264 in avis or mkvs.

Last edited by refulgentis; 20th May 2008 at 06:31.
refulgentis is offline   Reply With Quote
Reply

Tags
batch, encoding, implement, settings, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 16:05.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.