PDA

View Full Version : Transcoding H.264 .RAW to x264


oddball
6th November 2006, 01:19
I have a BBC HD test stream and I need to transcode it to x264 or XviD. However using TSConverter to demux the video and audio leaves me with an AC3 file (Fine easy enough) and a .RAW video file. But I do not know how to open and transcode that.

akupenguin
6th November 2006, 01:27
Transcoding H.265 .RAW to x264
First you wait a few years until H.265 is invented...

oddball
6th November 2006, 01:54
Can't seem to edit the thread title. But can anyone answer my question?

Blue_MiSfit
6th November 2006, 04:34
The RAW file can probably be muxed into an MP4 with MP4box. Then you can mux this mp4 with the ac3 into an MKV using mkvtoolnix/mkvmergegui.

Akupenguin's humorous response just pointed out a little typo :)
H.264 not H.265 :P

~MiSfit

oddball
6th November 2006, 12:57
I don't want to remux it. It's too big! I want to transcode it to something a bit more manageable and that my PC can playback (Lowly AMD XP 3200 here can't handle full AVC). I would like to transcode it to x264 if at all possible.

DarkZell666
6th November 2006, 13:25
Mencoder works great for your purpose :


mencoder yourrawh264.ts -vf pp=lb,scale=640:480 -oac mp3lame -lameopts br=160:cbr -ovc x264 -x264encopts crf=18:bframes=3 -o your_x264+mp3_encoded_version.avi


You can safely remove the "pp=lb," if your source isn't interlaced (but I bet it is :p).

Edit: get the latest build that suits you here >> http://esby.free.fr/CelticDruid/mirror/mplayer/

oddball
6th November 2006, 14:36
That works great! However I do not wish to reencode the audio. If I take out portions I think are to do with the audio I get an error. I just want to encode the video to x264 avi so I can mux an ac3 track afterwards. Also the only other thing is the scale. If I want to leave it at original scale do I enter the scale manually or remove some options?

EDIT: OK found the -nosound option. But what if I do not want to scale it down and do not know the original resolution (Being lazy here)? :)

Sharktooth
6th November 2006, 14:45
x264 is already h.264 and you dont need AVI to use AC3. Infact storing h.264 in AVI is not fully supported and may cause playback problems. Use MKV instead.
If the file is too big, just re-encode it using one of the x264 GUIs available and mux the result into MKV with the AC3 track.

DarkZell666
6th November 2006, 15:50
You can safely remove the ",scale=640:480" part, and use "-oac copy" instead of "-oac mp3lame -lameopts br=160:cbr", which will leave you the audio soundtrack untouched (if there's any).

However, if you don't downscale, I'm afraid the filesize won't be that much smaller (I don't know at what resolution h264 streams are produced, are they really HD or are they still SD for the moment ?) and the whole procedure will be a bit useless, imho.

mencoder is also capable of ouputing .mkv if you set the output filename extension to .mkv (e.g: -o whatever.mkv) ;)

oddball
6th November 2006, 16:20
OK thanks that helps a lot! :)

Sharktooth
6th November 2006, 16:31
BTW to edit the thread title go to the first post. Click the Edit button and then click the Go Advanced button.
Now you can change the title... and save the changes.

bond
7th November 2006, 21:16
Mencoder works great for your purpose :


mencoder yourrawh264.ts -vf pp=lb,scale=640:480 -oac mp3lame -lameopts br=160:cbr -ovc x264 -x264encopts crf=18:bframes=3 -o your_x264+mp3_encoded_version.avi


You can safely remove the "pp=lb," if your source isn't interlaced (but I bet it is :p).

Edit: get the latest build that suits you here >> http://esby.free.fr/CelticDruid/mirror/mplayer/it will be better to reencode in ffmpeg, as ffmpeg can reencode just like mencoder but can output to .mp4, which you then can remux without troubles to native mkv, which is not possible easily with a mencoder avi file...

oddball
7th November 2006, 22:46
Mencoder to mkv seems to work fine (Except it is dying part way through on one .TS file I have for some reason). The above command line for Mencoder is a single pass though is it not? What about 2 or 3 pass? I must admit it looks great so if it's single pass I am not usre 2 pass is needed.

P.S. if a mod wishes to merge this and the other thread in HD feel free.

EDIT: I originally tried ffmpeg but the output was all blocky no matter what the min and max bitrate I set. It looked like rubbich compared to what I was getting with Mencoder. Mencoder looked very good. Mind you ffmpeg I was outputting XviD and probably had the scaling incorrect. This is far more difficult than it should be.

Hmm. I cannot seem to get 2 pass working.

oddball
8th November 2006, 00:08
it will be better to reencode in ffmpeg, as ffmpeg can reencode just like mencoder but can output to .mp4, which you then can remux without troubles to native mkv, which is not possible easily with a mencoder avi file...

Can you illiterate on the command line to encode to x264 and rescale the video to 960x720 from 1440x1080 whilst outputting an MP4 file using ffmpeg?

I love it when people make these great suggestions but do not tell you HOW to do it ;)

DarkZell666
8th November 2006, 14:18
For 2-pass :
Set bitrate to whatever looks nice for you (1000, 1500 ... you try ^^)

mencoder raw_video.h264 -vf pp=lb,scale=960:720 -nosound -ovc x264 -x264encopts pass=1:bframes=3 -o NUL

mencoder raw_video.h264 -vf pp=lb,scale=960:720 -nosound -ovc x264 -x264encopts pass=2:bitrate=700:bframes=3 -o video.mkv


"-o NUL" is for first pass since the 1st pass only gathers stats about the source.
Specifying a bitrate for 1st pass is also useless for the same reason :)

Feel free to remove the ":bframes=3" stuff, you can also add ":turbo=1" for the 1st pass to make it faster.

CRF is only a 1-pass quality mode, so it obviously doesn't like being told to do 2-pass :p

@bond: in fact mencoder can output to mp4 too using "-of lavf -lavfopts format=mp4" (and naming the output file to something.mp4 :p). But this restricts the usage of bframes (which is quite a shame).
ex:
mencoder raw_video.h264 -vf pp=lb,scale=960:720 -nosound -ovc x264 -x264encopts pass=1:bframes=0 -o NUL

mencoder raw_video.h264 -vf pp=lb,scale=960:720 -nosound -ovc x264 -x264encopts pass=2:bitrate=700:bframes=0 -of lavf -lavfopts format=mp4:i_certify_that_my_video_stream_does_not_use_b_frames -o video.mp4


@oddball: lol, don't go bashing bond like that :p ffmpeg and mencoder both have a very complete (and more exhausting than exhautive xD) manual where all the options are explained.
Go practice your reading a bit ;)

oddball
8th November 2006, 15:56
Hehe yeah I was just being sarcastic.

bond
8th November 2006, 22:33
@bond: in fact mencoder can output to mp4 too using "-of lavf -lavfopts format=mp4" (and naming the output file to something.mp4 :p). But this restricts the usage of bframes (which is quite a shame).many tools produce .mp4 files. does this mean that the mp4 files are 100% spec compliant? no :p

.mp4 files created with x264cli and ffmpeg when encoding with x264 are spec compliant

Can you illiterate on the command line to encode to x264 and rescale the video to 960x720 from 1440x1080 whilst outputting an MP4 file using ffmpeg?

I love it when people make these great suggestions but do not tell you HOW to do it ;)yeah, and i love it when people cross post about their problem, and then flame those who want to help them

oddball
12th November 2006, 18:43
DarkZell666 is there any way to get 2 pass to work with -oac copy? I tried it with a .ts file using '-oac copy' instead of '-nosound' (I tried on both passes and -nosound on the first pass but it makes no difference) and it bombs with an error. If not I will have to mux the AC3 in afterwards.

TS file format detected.
VIDEO MPEG2(pid=1502) AUDIO A52(pid=1505) NO SUBS (yet)! PROGRAM N. 0
TS_PARSE: COULDN'T SYNC
MPEG: FATAL: EOF while searching for sequence header.
Video: Cannot read properties.

Exiting...

EDIT: Nevermind it seems it does not like the raw TS file. Probably due to the PID's. I used TSReader to mux to an MPG and it works on that. Although I am still getting some 'couldn't sync' errors as it encodes. Hmm.