PDA

View Full Version : How to resompress only a part of x264 video?


Hauru
25th February 2007, 11:48
Hi,

I need to recompress a small part of x264 video. It seems that some or all x264 parameters must be the same as it was set during
compression of the original.

Is it possible to find these parameters out or to make a new recompressed part somehow compatible with the rest?

Thanks.

neuron2
25th February 2007, 14:21
If it was made with x264.exe, then the encoding parameters are stored right at the start of the file in the first SEI slice. You can open the file with a hex editor, or even some text editors.

Hauru
25th February 2007, 15:25
Fine. Thank you, indeed, they are saved as a plain text. I could not suppose that.

x264 - core 45 svn-468 - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:-3:0 analyse=0x3:0x133 me=umh subme=5 brdo=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 chroma_qp_offset=0 slices=2 nr=0 bframes=2 b_pyramid=1 b_adapt=1 b_bias=0 direct=3 wpredb=1 bime=1 keyint=250 keyint_min=25 scenecut=40 rc=2pass bitrate=3005 r
atetol=1.0 rceq='blurCplx^(1-qComp)' qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40 pb_ratio=1.30

But it would be also interestiong to know which parameters (such as bitrate) you can change without braking decoding of the rest. For example, can i take more ref. frames?

orbitlee
25th February 2007, 15:49
All of these x264 encoding parameters(in text format) will be converted into H.264 SPS and PPS parameters(in binary format). If for any reason you want to change any parameters, you should add --sps-id, which will generate a different SPS/PPS, so the decoding of the rest frames will not fail.

--sps-id, to allow concatenating streams with different settings

Hauru
25th February 2007, 22:55
Many thanks for your proposals, but i could not get them work.

1. The first way was to reencode a part with exactly the same parameters as the original. So, i got the same old version of x264 and used these options. After compression i have muxed both parts with mkvmerge. The result - the second part has problems with playback.

d:\video\x264-v468\x264 --pass 1 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --bframes 2 --b-pyramid --direct auto --filter -3,0 --subme 1 --analyse none --me dia --threads 2 --progress --no-psnr --output NUL "M:\Ep2\HD_recompress_test.avs"

d:\video\x264-v468\x264 --pass 2 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --ref 2 --mixed-refs --bframes 2 --b-pyramid --bime --weightb --direct auto --filter -3,0 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --me umh --threads 2 --progress --no-psnr --output "M:\Ep2\HD_recompress_test.mkv" "M:\Ep2\HD_recompress_test.avs"

2. The second way. Here i have taken a new version that supports this --sps-id flag. All parameters are almost the same except of "--sps-id 1". Both parts were muxed with mkvmerge. The result - the second part will be not played at all.

d:\video\x264\tools\x264\x264 --pass 1 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --bframes 2 --b-pyramid --direct auto --filter -3,0 --subme 1 --analyse none --me dia --threads 2 --progress --no-psnr --output NUL "M:\Ep2\HD_recompress_test.avs"

d:\video\x264\tools\x264\x264 --pass 2 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --ref 2 --mixed-refs --bframes 2 --b-pyramid --bime --weightb --direct auto --filter -3,0 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --me umh --threads 2 --progress --no-psnr --sps-id 1 --output "M:\Ep2\HD_recompress_test.mkv" "M:\Ep2\HD_recompress_test.avs"

Where is the mistake?
Or do somedoby know the *right* way?

Thanks to all.

bond
25th February 2007, 23:11
did you tell mkvmerge to append the two streams so that not simply a mkv with two seperate video streams is created?

if yes, its maybe a mkvmerge bug. try appending the two streams with mp4box

if that also doesnt work run h264_parse from mpeg4ip on both streams and post the results here

Hauru
26th February 2007, 02:22
mp4box also can not concatenate them. It produces two separate video streams.

Here please find info gained with h264_parse -
http://rapidshare.com/files/18308250/info.rar.html

Thanks.

Hauru
11th March 2007, 00:45
I have taken the same version of x264 and tried to find exactly the same parameters as in the first SEI slice, but without success. Please can somebody check them if they are correct.

Encoding parameters:

d:\video\x264-v468\x264 --pass 1 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --bframes 2 --b-pyramid --direct auto --filter -3,0 --subme 1 --analyse none --me dia --threads 2 --progress --no-psnr --output NUL "M:\Ep2\HD_recompress_test.avs"

d:\video\x264-v468\x264 --pass 2 --bitrate 2695 --stats "M:\Ep2\HD_recompress_test.stats" --ref 2 --mixed-refs --bframes 2 --b-pyramid --bime --weightb --direct auto --filter -3,0 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --me umh --threads 2 --progress --no-psnr --output "M:\Ep2\HD_recompress_test.mkv" "M:\Ep2\HD_recompress_test.avs"

Parameters from SEI:

x264 - core 45 svn-468 - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:-3:0 analyse=0x3:0x133 me=umh subme=5 brdo=0 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 chroma_qp_offset=0 slices=2 nr=0 bframes=2 b_pyramid=1 b_adapt=1 b_bias=0 direct=3 wpredb=1 bime=1 keyint=250 keyint_min=25 scenecut=40 rc=2pass bitrate=3005 ratetol=1.0 rceq='blurCplx^(1-qComp)' qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 cplxblur=20.0 qblur=0.5 ip_ratio=1.40 pb_ratio=1.30