Log in

View Full Version : .ts -> x264


Siulas
6th February 2006, 20:10
I have .ts movie ~15gb and i realy want to encode it to x264.Can anyone suggest me some guides?or software which are you using?I read here a lot,but realy could't find the best way how to encode from transport stream to x264,maybe someone can write short tutorial,or something like that?i really appreaceate your help,thanks.

bond
6th February 2006, 20:22
directshowsource via avisynth -> feed the .avs to x264 cli

Siulas
6th February 2006, 21:18
thanks for help,but what i should do with sound?will x264 meGui will do everything for me,and i will have no problems with it?and what are you thinking about dgmpgdec ? maybe i should beter use it,instead of avisynth[i don't know how to use it]?

Eeknay
7th February 2006, 22:49
Run the .ts through dgindex and frameserve using AviSynth (mpeg2source("blah.d2v")), then just use MeGUI and the HQ-Slowest profile at a reasonable bitrate (or calculate if you're aiming for DVD-R size).

As for sound, either leave it as AC3 and throw everything into a MKV (using MKVMergeGUI), or encode to AAC and mux into an MP4 (BeLight + MP4Box).

fuxor123
11th February 2006, 15:26
I also do transport stream encodes with DGIndex but I'm not quite sure if the output is okey...
Can someone take a look at this piece of my d2v file and tell me if this is normal or am I doing something wrong?

f00 1 0 10831829432 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10832211824 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10832597412 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10832979240 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10833362572 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10833741768 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10834128108 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10834509748 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10834889132 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10835267388 0 0 f0 f0 d0 f0 f0 e0 f0 f0 e0 f0 f0 e0 f0 f0 e0
f00 1 0 10835613120 0 0 f0 f0 d0 f0 f0 e0 ff

FINISHED 0.00% FILM

The whole file looks like this and in the end i get 0.00% film.
Is that normal with transport streams?

Revgen
11th February 2006, 16:56
It may be better to ask this particular question in the DGIndex forum.

Guest
11th February 2006, 17:21
I also do transport stream encodes with DGIndex but I'm not quite sure if the output is okey...
Can someone take a look at this piece of my d2v file and tell me if this is normal or am I doing something wrong?The whole file looks like this and in the end i get 0.00% film.
Is that normal with transport streams? It just means that particular stream does not contain soft pulldown via RFF flags. It may still be film if it is hard telecined. You have to examine the served video to determine whether it is hard-telecined film or interlaced video.

woah!
11th February 2006, 22:33
i run mine through VideoReDo to edit it first if needed,then save to mpeg with i feed to DGIndex. the audio is then there to do whatever i wnat with it.

wiak
3rd May 2006, 07:46
check out http://nwgat.net/ guides :)

morph166955
4th May 2006, 05:55
mencoder -ofps 30000/1001 -oac mp3lame -lameopts preset=insane -ovc lavc -lavcopts vcodec=mpeg2video:threads=4:mbd=1:keyint=5:psnr:vbitrate=8000 -vf softskip,scale=720:-2 -o Fixed-ts.avi Input.ts

you may wanna change that around a little, but its the bulk of it. just please realize what this is doing and why i wrote it this way. Im currently writing some software for *nix that takes a .tp stream and converts it, strips commercials, and stuff. this is the profile im using now to fix the hdtv stream. please note, im dropping the framerate from 60fps to 30fps (thats what softskip helps with...i find it works better then decimate for some reason), scalling it down to 720:-2 (the -2 autosizes it). 8000kbit/s maintains the bitrate pulled down by the stream (it can be lower then the 19mbit/s that it comes in at because im scalling it down enough...the bpp is actually higher in my encode then the original so i dont think your going to get any better). the mbd and keyint stuff are a little hardcore but thats because im doing ALOT of searching through the stream and having software interprit whats comming out so i like the ability to be able to be that accurate in the stream.

tweak as you may want...but it works. ive thus far tested it on everything from a 720p recording of house and lost to a 480i recording of family guy (i reduced the scale to scale=-2:480 for that...no sense in blowing up the image right). also note i am running it into a 2 channel mp3 audio track from the ac3 that its comming with. the preset=insane option locks it in at a 320kbps bitrate which to me is plenty enough.

hope that helps

MrTroy
4th May 2006, 09:56
mencoder -ofps 30000/1001 -oac mp3lame -lameopts preset=insane -ovc lavc -lavcopts vcodec=mpeg2video:threads=4:mbd=1:keyint=5:psnr:vbitrate=8000 -vf softskip,scale=720:-2 -o Fixed-ts.avi Input.ts
Except he asked for h264...

Plus if it's a movie, chances are good that it's hard pulled-down. Your mencoder command line suggests encoding at 30000/1001 fps, but if it's really telecine material that's just a waste of bits. Better IVTC it first.

CruNcher
4th May 2006, 13:34
@Siulas

mediacoder.sourceforge.net

morph166955
4th May 2006, 17:28
Except he asked for h264...

Plus if it's a movie, chances are good that it's hard pulled-down. Your mencoder command line suggests encoding at 30000/1001 fps, but if it's really telecine material that's just a waste of bits. Better IVTC it first.

very very very true...i guess i forgot to type the second half of my post. oops.

The reason i do that to the ts stream first is because i cant stand trying to manipulate an already disfunct ts stream (i consider all ts streams disfunct due to there lack of ability to search properly in them). From my experience lately doing rips from my fusion5hdtv usb the software i use either stores hd data as 720p (it seems to downconvert 1080i to 720p internally before storing) or sd at 480i (actually it seems to store it at 720x480 and then put an aspect ratio in to bump it to 720x576...i find the 576 number slightly odd since im ntsc and not pal but w/e). due to the 720p nature of it, ive noticed that everything has already been upconverted to 60fps. On my computer, after slicing out commercials and doing the audio on mp3lame preset standard instead of insane, 720p @60fps in x264 is too much data for the video to play properly, it lags and just doesnt work. (just to note, my computer is a P4 3.2 hyperthread with 2gig ram playing over a gbps network connection and locally). 30fps is pushing it at 720p so i have been scaling down my movies to a 720x? size depending on the cropping done.

Remember, this is an INTERIM step that i elect to do. after this step i would run it through mencoder again doing a one pass x264 encode using crf between 18 and 26 depending on the image (maybe as high as 16 if i really wanted to preserve it, 18 does the trick normally though). you can also at this point encode it down to the 24000/1001 or w/e frame rate you want. since my software is "stupid" as to it being a movie or a show i figured 30fps was a reasonable number to begin with and then on the encoding passes the user can set an output fps if they want.

For the mencoder pass...heres an example of what ive been using to do the encode:

mencoder House.mpeg2video-FINAL.avi -af volnorm=2:.40 -oac mp3lame -lameopts preset=standard -ovc x264 -x264encopts crf=22:psnr:8x8dct:4x4mv:mixed_refs:b_pyramid:frameref=10:weight_b:me=3:bframes=3:subq=6:brdo:bime:nofast_pskip -o H-264-720x406-30fps-softskip-keyint30-keymin1.avi 2>&1 | tr "^M" "\\n"

for the newbie who doesnt know what all that does...heres a breakdown

-af volnorm=2:.40
Normalizes the volume. The first # (2) tells it to take multiple samples to calculate a good range. the second (.40) "Sets the target amplitude as a fraction of the maximum for the sample type (default: 0.25)" (from the mplayer manual). I use the .40 over the default .25 because i like the volume of my stuff to be a little higher then .25 produces. setting the first # to 1 does work also but i find 2 is a more linear adjustment to the volume for obvious reasons


-oac mp3lame -lameopts preset=standard
i use the lame mp3 codec to handle the audio. I find that there is little reason to maintain the 5.1ch AC3 thats comming over the high def. Most stereo recievers today have the ability to create the center and rear channels from a 2 channel audio stream and in all reality most people play these on computers with crappy $30 speakers anyway so why store that much more info. preset=standard gives you a VBR between 170 and 210. the preset=insane i do on my first pass gives you a CBR of 320.


-ovc x264
set x264 as the codec


-x264encopts crf=22:psnr:8x8dct:4x4mv:mixed_refs:b_pyramid:frameref=10:weight_b:me=3:bframes=3:subq=6:brdo:bime:nofast_pskip
ok heres the long one. crf=22, read up on crf, wont go into it here. psnr has it output psnr info at the end...very very very useful! no reason not to put it in. 8x8dct, 4x4mv, mixed_refs, b_pyramid, weight_b, brdo, bime, nofast_pskip are options i prefer to have in there for my encode...use what you will. frameref=10...some say thats a little high, i kinda like it. go down to 5-6 if you think thats too high. me=3 is also personal pref...but most use this also. bframes=3...again...personal pref but used by most. subq=6...this tells it to use rate-distortion. subq=5 is the default, and 7 is "insane" mode which really does NOTHING for the final product and in my book is useless unless your doing some really really really really high quality encodes for perm storage.



-o H-264-720x406-30fps-softskip-keyint30-keymin1.avi
output to that file...duh

2>&1 | tr "^M" "\\n"
this is a little trick for the unix people who like to log what mencoder does and not have a hastle with it. the 2>&1 BEFORE the pipe makes sure mencoder dumps everything to stdout. the tr command then does a fun trick. it takes all the ^M characters which normally do the carriage return and has them output as newlines, that way each frame is on a new line. NOTE!!!: you CANT just type in ^ M as two characters...THIS WONT WORK. use CTRL+V CTRL+M at a prompt OR CTRL+Q CTRL+M inside of emacs should you be writing a script. This will output the proper character. some sample output when doing the tr trick:

Pos: 0.0s 1f (10%) 0.00fps Trem: 0min 0mb A-V:0.000 [0:0]
Pos: 0.1s 2f (10%) 0.00fps Trem: 0min 0mb A-V:0.003 [0:0]
Pos: 0.1s 3f (10%) 0.00fps Trem: 0min 0mb A-V:0.007 [0:0]
Pos: 0.1s 4f (10%) 0.00fps Trem: 0min 1mb A-V:0.010 [0:0]
Pos: 0.2s 5f (10%) 0.00fps Trem: 0min 1mb A-V:0.013 [0:0]
Pos: 0.2s 6f (10%) 0.00fps Trem: 0min 2mb A-V:0.017 [0:0]


Notice how nice that looks and how easy that is to read! It also fixes it if you wanna pipe that to a while loop like i do for use in a script (my software interprits mencoders output durring an encode to display more "quiet" data to the user)

I hope that helps out more. again, remember that my mpeg2video pass is a personal thing i do so that i can skip around inside the video using things like -ss which you may notice doesnt work at all on a -ts stream (ive noticed that its at times more then 3 minutes off!) simply due to the nature of how the ts stream is created.

Hope this helps...if anyone has any questions feel free to ask ill try to answer them to my fullest (theres no such things as stupid questions! if you dont understand...ASK)

morph166955
4th May 2006, 17:32
forgot one thing you may want...

mplayer/mencoder man page:
http://www.mplayerhq.hu/DOCS/man/en/mplayer.1.html

the more indepth manual:
http://www.mplayerhq.hu/DOCS/HTML/en/index.html

the x264 sections of the above manual:
http://www.mplayerhq.hu/DOCS/HTML/en/video-codecs.html#codec-x264
http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-x264.html

MrTroy
4th May 2006, 20:24
Remember, this is an INTERIM step that i elect to do. after this step i would run it through mencoder againI understand why you elect to do this, but re-encoding it so many times results in visible quality loss.

Remember the .ts already is a compressed file, so your first step is actually the second time it's being encoded.

morph166955
4th May 2006, 23:43
very true...but that is also the reason im encoding at a bitrate that is over 2000kbit/s higher then what the input is at. i have thus far done 3 full .ts to x264 hd encodings and i have yet to see any noticable degrade in image. i have done frame dumps of several areas of each and minus the fact that its scaled down from the original, the final product is just as clear and crips as the original was. luckily since im really only doing two passes (yes...theres a third pass in there when its taken from raw to .ts but theres nothing i can do about that) and my settings for the first are insanely high quality its thus far not been an issue for me.