divx encoding
mini-HOWTO DIVX Encoding Ekdosh 1
Gia Linux kai alla POSIX susthmata me ti xrhsh tou mencoder/mplayer.
contact:  admin at www0 dot org


Glwssario:

MPlayer == Media Player gia linux kai alles unix platformes. Ypostirizei sxedon ola ta gnwsta codecs.
Mencoder == Encoder/video manipulator pou erxetai mazi me to mplayer, periexetai sto idio tarball.
FFmpeg == Sullogh codecs gia video streams kai videos. Periexei ektos twn allwn, ena ipsilhs poiothtas mpeg 4 codec. (sta tarball tou mplayer, oxi sto cvs)
DivX == mpeg4 avi video
Lame == Mp3 encoder upshlhs poiothtas gia unix susthmata.
Multipass Encoding = H diadikasia opou arxika o encoder mazeuei plhrofories se ena log gia ti poluplokothta tou video wste argotera na kanei kaluterh xrhsh tou bitrate. Noeitai h xrhsh tou mono se Variable Bitrate encoding.
divx4linux/divx5linux == To gnwsto mpeg 4 codec/decodec apo to divx.com.
Scaling == Epanaka8orismos diastasewn tou video se pixels.
Bitrate == `Bit Rate'. Metrietai se kbit/sec gia mp3 kai DivX>4 me 1kbit=1000bit(oxi 1024)
fps == Frames per Second, h taxutita allaghs twn frames kinoumenhs eikonas ana deuterolepto.


* Protinoume na ftasete os to telos oste na kanete 3-PASS encoding ektos kai an 8elete na teleiosete polu grhgora, mias kai oxi mono prosferei anwterhs poiothtas apotelesma alla kai sto prwto pass 8a dw8ei me polu kalh akribia (poly kalhterh apo ekeinh twn "divx bitrate calculators") to bitrate gia 650, 700 kai 800 Mbyte CDs ean kanete encoding ena megalo video p.x. dvd tainia).

Periexomena:





Quickstart - Kapoia paradeigmata

* Xwris ti xrhsh me8odwn pou perigrafontai parakatw


Tupikh grammh mencoder:


mencoder INPUT.mpg -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1200 -oac mp3lame -lameopts vbr=3:abr=128:q=0:aq=0  -vop scale -zoom -xy 512 -o OUTPUT.avi


To parapanw 8a parei to INPUT.mpg (to opoio mporei na einai otidhpote mpori na peksei to mplayer, p.x. ena mpeg/asf/mov/ram:-) kai 8a kanei divx me to FFmpeg divx codec sta 1200kbit/sec. Tautoxrona 8a kanei mp3(vbr) hxo sta 128kbit/sec meso bitrate kanontas scaling sta 512x(automatos upologismos ths deuterhs diastashs). To OUTPUT.avi einai to teliko video.

* H mp3 upostiriksh sto mencoder (an deite oti den leitourgei) perigrafetai parakatw sto keimeno.


DVD rip:

mencoder -dvd 1 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1200 -oac mp3lame -lameopts vbr=3:abr=128:q=0:aq=0  -vop scale -zoom -xy 512 -o OUTPUT.avi

To idio
me to prwto alla anti gia ena arxeio video paizoume amesa thn DVD suskeuh (pou einai symlinked sto /dev/cdrom). Prwto title (1) tou dvd. Me -slang el mporoume an dwsoume thn ellinikh glwssa stous upotitlous. Me -alang el mporoume na dwsoume thn ellinikh glwssa ston hxo.

Xwris encoding hxou:

mencoder INPUT.mpg -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=1200 -oac copy -vop scale -zoom -xy 512 -o OUTPUT.avi


To idio me to proto alla de ginetai kammia epeksergasia tou hxou.

Xwris encoding video:

mencoder INPUT.mpg -ovc copy -oac mp3lame -lameopts vbr=3:abr=128:q=0:aq=0 -o OUTPUT.mpg


To idio me to prwto alla de ginetai epekserasia ths eikonas.


Eisagwgika:


To paron keimeno, enw kuriws anaferetai se DivX encoding, sth pragmatikothta mporei na xrisimopoiithei gia opoiodhpote codec sto megalutero meros tou. O logoi pou me ekanan na to grapsw me anafora to DivX codec, htan duo. O kosmos auto sinithos zhtaei, kai deuteron kata proswpikh mou apopsh einai o logikoteros dromos authn thn epoxh gia to meso xrhsth. Einai ektenws diadedomeno kai tautoxrona prosferei anwterhs poiothtas encoding se sxesh me to ka8ieromeno prin liga xronia mpeg1(vcd). Akoma kai to mpeg2(dvd) den einai oti kalutero gia to xrhsth pou 8elei na "xoresei" se ena CD h' estw se duo, mia suni8ismenh tainia.

To keimeno graftike me skopo na diabastei ws to telos. Eksalou einai arketa mikro gia na mh to kataferei kapoios:-> O logos pou to leo auto sthrizetai sto oti to telos tou anaferei ton kata th gnwmh mou protinomeno tropo encoding(3-PASS) gia anwterhs poiothtas apotelesma kai tautoxrona swsto upologismo tou  bitrate gia ton xrhsth pou prepei na "kapsei" se CD to apotelesma. Epishs, gia na xrhsimopoii8ei swsta ekeinh h me8odos prepei o xrhsths hdh na kserei tis epimerous epiloges/leptomereies gia thn poiothta hxou kai eikonas pou prepei na efarmosei kai gia auto to logo protinw na diabasete olo to keimeno mias kai den periexei perita pragmata. Einai ola kata th gnwmh mou ta elaxista pou prepei kapoios na gnwrizei gia na kanei mia aksiopreph douleia. Gia perissotera mporeite na sumbouleutite kat'arxhn to man tou mplayer kai fusika, ta DOCS:-)


Ti xreiazomaste:


Ti den xreiazomaste:



Egkatastash tou mplayer/mencoder


Prota apo ola, egkathistoume to mplayer apo source tarball an de to exoume hdh. To idio paketo periexei to mencoder.

http://www.mplayerhq.hu

Akolouthame prosektika tis installation odhgies sto:

http://www.mplayerhq.hu/DOCS

einai shmantiko na akolou8hsete tis odhgies egkatastashs oste na exete pros8eta opws upostiriksh win32 codecs kai gui gia ton player.

Oi programmatistes tou mplayer lene oti mono me gcc 2.95.x tha ginei swsto compile.

An exete rpm-based dianomh me 2.96.x h' 3.x gcc, kai sas fainetai golgothas na allaksete ekdosh, tote diabaste to minima pou tha emfanistei sto ./configure peri --disable-gcc-checking kai lalala.

  Prostheta:


An thelete na kanete encoding se mp3 hxo (kati to opoio protinetai gia tis perissoteres periptoseis) tha prepei na exete to lame kai to devel paketo tou prin kanete compile to mplayer. Th stigmh pou grafetai to keimeno, to mplayer protinei lame mono apo cvs h' sigkekrimena to 3.89 beta. Simbouleutite to site tous an thelete na eiste sigouroi(mplayerhq.hu). Na to tonisoume pws den xreiazetai mono to binary, alla kai ta headers tou lame wste na ginei swsta to compile to mplayer/mencoder gia upostiriksh mp3 encoding.

An theloume na baloume to closed-source divx encoder - h' alliws divx4linux kai divx5linux - pame sto divx.com kai to katebazoume, to kanoume tar zxvf kai to egkathistoume me to install.sh pou periexei PRIN kanoume compile to mplayer.

To open source divx encoder, to ffmpeg (h' alliws libavcodec h' lavc) periexetai sto mplayer opote DEN xreiazetai na to baloume ksexwrista prin to compile.

Gia na douleuoume me windows codecs kai alla codecs opws to neo Quicktime(Sorenson) codec, diabazoume tis odigies egkatastashs tou mplayer. To paron keimeno einai peran tetoion leptomereiwn.

Pantos, gia na mporeite na kanete tupika pragmata pou den emperiexoun mp3 audio kai win32 codecs to default tarball arkei se olous.

Shmeiosh
:
To mencoder tha kanei allages/encoding se divx/encoding se mpeg1/klp klp, se otidhpote mporei to mplayer na doulepsei. An kati mporeite na to "peksete" me to mplayer shmainei pws mporeite na to kanete kai divx h' genika na tou kanete manipulation me to mencoder. An exete hdh mplayer tha kserete profanws pws leitourgei. Gia thn akribia, otidipote xrisimopoiite san input sto mplayer einai kai to input tou mencoder. p.x. an paizoume to prwto title enos DVD me "mplayer -dvd 1", h arxh twn parametrwn tou mencoder tha einai "mencoder -dvd 1". Toso apla.


Paradeigmata Encoding:


Xrhsimopoiontas to Divx4linux apo to divx.com:


mencoder INPUT.mpg -o OUTPUT.avi -oac copy -ovc divx4 -divx4opts br=800:q=5

To parapanw, me bitrate 800kbit kai quality 5(=highest), paragei divx avi. To INPUT.mpg mporei na einai *otidhpote* anagnwrizei to mplayer. Apo asf twn windows kai vcd, mexri ena allo divx (pou de mas aresei alla prepei na to allaksoume).

Ypologisths Divx Bitrate:


To parakatw _den_ 8a xreiastei sth periptosh tou 3-PASS encoding mias kai sth periptwsh ekeinh, to prwto pass 8a mas dwsei me polu kalhterh akribia apo ena ypologisth bitrate, to sosto noumero.

Divx4 bitrate calculator


Xrhsimopoiontas to open source FFmpeg DivX codec.


Me to mencoder leitourgei kalutera kai dexetai perissotera options.

mencoder INPUT.mpg -o OUTPUT.avi -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=800 -oac copy

Auto tha kanei oti kai to prohgoumeno paradeigma, alla me ti xrhsh tou FFmpeg (h' alliws libavcodec h' lavc).

DVD Ripping


Mporoume polu apla na kanoume rip ena DVD me to mencoder/mplayer:-)

mplayer -dumpstream -dvd 1 - dumpfile out.stream


To out.stream mporei argotera na xrisimopoiithei san input tou mencoder.


Sth periptwsh twn dvd.


Anti gia INPUT.mpg (dld ena arxeio) mporoume gia thn eukolia mas na xrhsimopoiisoume -dvd 1 p.x. opou "1" bazoume to ton arithmo tou "title" pou theloume.

Me -slang el mporoume an dwsoume thn ellinikh glwssa stous upotitlous.
Me -alang el mporoume na dwsoume thn ellinikh glwssa ston hxo.


mp3 Audio sto divx

Gia na exoume mp3 audio sto divx (kati to opoio protinoume anepifilakta gia na exoume mikrotera megethh arxeiwn) prepei na xrisimopoiisoume anti gia '-oac copy', to opoio kanei amesh antigrafh tou hdh uparxontos audio sto neo arxeio (p.x. an kanoume dvd tha kanei amesh eggrafh tou 448kbit ac3 hxou), xrisimopoioume -oac mp3lame

To -oac mp3lame tha akousei stis parametrous tou -lameopts

-lameopts vbr=3:abr=128:q=0:aq=0


To parapanw kanei encoding me VBR (variable bitrate) mp3 audio kai average bitrate ta 128kbit/sec

-lameopts cbr:br=128:q=0:aq=0


Auto tha kanei encoding me CBR (constant bitrate) mp3 audio kai stathero bitrate ta 128kbit/sec

Shmantiko: Ta docs th stigmh pou grafetai auto to keimeno (sumbouleutite ta gia neotera) epimenoun pws den leitourgei to paragomeno apo to mencoder CBR mp3 audio se windows players. MONO to VBR(variable bitrate). To kako einai pws genika poloi player tha duskoleutoun na paiksoun akoma kai VBR swsta. To mplayer tha doulepsei me to CBR (kai to VBR fusika) pou paragetai apo to mencoder outos h' allws gi'ayto mh biastite na upothesete oti tha paizei se olous tous players. Sumbouleutite to mplayer.hu gia neotera panw sto thema.


Eisagwgh Ypotitlwn

An exoume sth dia8esh mas tous upotitlous enos video - sth periptosh twn DVD deite to analogo meros - mporoume na tous perasoume me thn -sub

p.x. -sub lotr3.sub

Oi upotitloi gia na leitourgoun apaitoun mia extra ergasia. Na exoume egkatasthsei grammatoseires sugkekrimena gia to mplayer.

Edw 8a breite duo paketa pou periexoun ta Comic Sans kai Garamond gia ellhnika sto mplayer. Douleuoun apsoga kai gia ta agglika opote de 8a xreiastite alla paketa:

Local build:
Garamond:
http://www0.org/garamond-iso-8859-7.tar.bz2

Apo ton Steve Stavropoulo sto upatras.gr:
Comic Sans:
http://master.math.upatras.gr/~steve/mplayer.iso8859-7.font.tar.bz2

H egkatastash einai aplh, aposumpiezoume ena apo ta dio (tar jxpvf) kai to topo8etoume sto ~/.mplayer/font

Meta apo auto mporoume me thn -sub opos eipame parapanw na dwsoume ena arxeio upotitlon kai me to plhktro "o" na allaksoume to view tou time, seek klp thn wra ths anaparagwghs.

Cropping - Afairesh twn maurwn grammwn

An theloume na "kopsoume" tis maures grammes apo ena video kanoume ta ekshs:

a) Detection, briskoume automata pou einai oi grammes:


mplayer INPUT.mpg/-dvd x -vop cropdetect

b) Encoding, kanoume paste to "350:176:2:32"(oi arithmoi einai paradeigma) pou tha mas dwsei to a) sth grammh entolhs tou mencoder:

-vop crop=350:176:2:32


Kopsimo video
se kommatia

Mporoume polu apla na kopsoume ena video se kommatia ka8orizontas arxikh kai telikh 8esh tou video.

kanontas -ovc copy kai -oac copy pername to video sto -o OUTPUT.avi xwris extra encoding:-)

Paradeigmata arxikou shmeiou anaparagwghs:

-ss 34
             (deuterolepta)
-ss 01:10:00 
-sb 1234567         (bytes)
-sb 700mb

Paradeigmata telikou shmeio anaparagwghs:

-endpos 34         
(deuterolepta)
-endpos 01:14:32  
-endpos 700mb

Paradeigmata:

mencoder ETOIMO-OUTPUT.avi -ovc copy -oac copy -endpos 700mb -o CD1.avi

(gia na ftiaksoume ena CD 700MB apo thn arxh)

h'
mencoder ETOIMO-OUTPUT.avi -ovc copy -oac copy -ss 01:10:00 -endpos 01:15:00 -o  VIDEO_CLIP1.avi

(gia ena clip 5 lepton)



Scalling - Ka8orismos diastasewn:


Einai ena -vop option pou mas epitrepei na ka8orisoume tis diastaseis tou telikou apotelesmatos se pixels.

Aplo scalling:


-vop scale=624:352
(protinomeno gia widescreen dvd->divx (16:9))

Ypologismos depth mesw width se sxesh me to input:


-vop scale -zoom -xy 352



Xrhsh diaforetikou fps


Me tin -ofps mporoume na dwsoume ti timh tou Frames Per Second(fps).

p.x. -ofps 23

shmeiosh:
Auto _PREPEI_ na dw8ei sth periptwsh analaswmenou fps (asf, merika mov) kai progressive mpeg arxeia.


Epibolh tou Aspect Ratio:


Efarmozetai mono me th xrhsh tou FFmpeg divx4 codec. Douleuei mono me to mplayer kai pi8anon alla players pou douleuoun me to FFmpeg.

To Aspect Ratio sta video einai polu shmantiko an de 8eloume na blepoume "travigmena" ta video kai 8eloume na krathsoume to arxiko scale.

H xrhsh tou einai polu aplh, gia paradeigma se ena DVD me Anamorphic Widescreen diabazoume sto pisw meros tou koutiou (h' hdh kseroume:->) pws einai 16x9.

Etsi, sta options tou FFmpeg 8a xrisimopoiisoume:

-lavcopts aspect=16.0/9.0  
+ oti alla options exoume kata nou.

shmeiosh:
An kanoume swsto scale, de xreiazetai na epibaloume to Aspect Ratio.


Multipass Encoding
:

Noeitai mono se Variable Bitrate videos. Sth periptosh tou multipass encoding o encoder arxika mazeuei plhrofories gia to en logo video sxetika me th poluplokothta tou se ena .log arxeio. Me th xrhsh ekeinou tou log arxeiou argotera, o encoder 8a mporei na upologisei poly kalytera ti bitrate na xrisimopoiei ana pasa stigmh kata ti diarkia tou telikou encoding. Εtsi, enw se mia tupikh periptosh encoding oi titloi telous kai oi "arges" skhnes 8a epernan ena shmantiko meros tou bitrate, sto multipass encoding ena shmantiko meros ekeinou tou "xamenou" merous data 8a xrisimopoii8ei se skhnes me megaluterh poluplokothta, ara kai me megaluteres apaithseis se bitrate. Sto single-pass encoding, o encoder mporei na gnwrizei mono to ti exei sumbei "prin", diladi den exei mia sunolikh optikh stis leptomereies toy video.


3-PASS encoding (protinomeno):

To 3-PASS encoding sto mencoder douleuei se 3 stadia(hallo mr obvious). Sto prwto kanei encoding ton hxo kai tautoxrona dinei me _polu_ kalh akribia to bitrate pou 8a eprepe na xrisimopoiisoume gia mia megalh tainia analoga me to mege8os twn cd pou isws prepei na xrisimopoiisoume.

Pass 1:


mencoder -dvd 1 -ovc frameno -o frameno.avi -oac mp3lame -lameopts vbr=3:abr=64:q=0:aq=0

sto paradeigma einai to proto title enos dvd, hxos me to lame, VBR, 64bits/sec, high quality klp. Ta options auta ta ka8orizoume analoga me oti eixame pei prin kai fusika diabazontas to man.

8a parax8ei:
  • ena arxeio me titlo frameno.avi pou 8a periexei mono ton hxo kai
  • 8a ginei probolh twn protinomenwn bitrate gia 650, 700 kai 800 Mbyte.

shmeiosh:
Akoma kai an kanoume -oac copy (aplo copy toy hxou), pali 8a exoume to idio apotelesma.

Pass 2:


mencoder -dvd 1 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vhq:vpass=1:vbitrate=629 -o OUTPUT.avi

Kai edw, ta options ka8orizontai analoga me oti eipame prin me shmantikh diafora oti sto -lavcopts prepei na pros8esoume to vpass=1

8a parax8ei:
  • to .log arxeio sxetika me tis plhrofories ths poluplokothtas tou video to opoio 8a xrisimopoii8ei sto epomeno stadio
  • to OUTPUT.avi
Pass 3:

 mencoder -dvd 1 -oac copy -ovc lavc -lavcopts vcodec=mpeg4:vhq:vpass=2:vbitrate=629 -o OUTPUT.avi

Opws prin, me option, vpass=2

To OUTPUT.avi 8a einai to teliko mas video:->


Gui Mencoder Frontend

Epese sth prosoxh mou ena arketa doulemeno gui mencoder frontend gia osous den antexoun th consola kai 8eloun ena grafiko periballon gia th xrhsh toy mencoder. Sigoura, oso ekselisete o mencoder to sigkekrimeno frontend 8a prepei na akolou8a tis ekselikseis tou kai de kserw akoma kai tora kata poso epitrepei polles apo tis epiloges pou uparxoun sth dia8esh mas sth konsola. Episis einai sigoura ligotero sta8ero apo to "plain console" kai pi8anotata na einai xronoboro gia th diadikasia tou encoding/manipulation an laboume upopsin mas oti einai kai grammeno me QT gia KDE.

Anyway, arketa to e8apsa:-)

Gia osous xreiazontai to kmencoder, to link einai
http://sourceforge.net/projects/kmencoder


FAQ - Sinithismenes Erwthseis



E: Les gia -vop lala -vop lolo, pws 8a perasw kai tis dio epiloges stin idia grammh;
A: Oi epiloges sto mencoder mporoun na diaxwristoun me ena ":", p.x. -lavcopts vcodec=mpeg4:vhq:vbitrate=1000

E: Ftanei ti poiothta twn windows sto Divx encoding;
A: To pi8anotero einai oti ti ksepernaei:-> Kanontas xrhsh enos UNIX leitourgikou san background, exeis megaluteres pi8anothtes na ginei swsta h douleia kai xwris kolhmata. Epishs h olh diadikasia ginetai taxutera mias kai o X server einai axrhstos kai exeis ena programma gia oles tis douleies (mencoder), gegonos to opoio kanei akoma taxuterh thn olh diadikasia. Telos, mporeis na xrisimopoiiseis kai to klasiko divx.com codec alla kai to open source tou FFmpeg.

E: Tin ora pou kanw encoding mporw na kanw kati allo sto PC;
A: Fusika, autos o mu8os/pragmatikothta pou epikratei sta windows oti den prepei na kaneis tipota sto pc ekeinh thn wra, edw den uparxei. Mporeis na kaneis oti 8es tautoxrona.

E: Exw akousei pws an de kanw rip to DVD 8a katastrafei h suskeuh me to kairo. Einai ali8ia;
A: Den exw dei kati tetoio akoma. Epishs, me tis nees CPU, h diadikasia tou encoding de 8a parei panw apo merikes ores (to polu). Se sizitiseis tou mplayer anaferetai pws h f8ora pou prokaleitai apo ena rip se sxesh me th f8ora tou encoding 8a einai telika h idia.

E: De bariesai na grafeis mini-HOWTO;
A: Oxi, to grafw kai gia na mh ksexnaw o idios th diadikasia:p

E: Ela paradeksou to, to kaneis gia na to paikseis mourh
A: Les blakeies:p

E: De 8a katebeis sabbaro bradu;
A: Mpaa.. 8a dw kana divx

E: E, kane kammia douleia
A: Molis ekana:->

fateswarm@my:~£