View Full Version : MP4 : Impossible to append an x264 video to a similar x264 track in an mp4 file
t3g
4th October 2007, 01:32
Hello,
I encode credits separately to save size (usually a 50kbps x264 encode provides perfect quality), because else x264 uses the same bitrate as the video (~1000kbps) which is overkill.
I encode with Avidemux both movie and credits using the same resolution, fps and encode options, except for the bitrate. Avidemux saves them as mp4, and for each file the container only has 1 track, the video (I add audio/subtitles at the end).
However, when I use MP4Box to append the credits to the movie, with :
MP4Box Movie.mp4 -cat Credits.mp4 -out Movie2.mp4
or
MP4Box Movie.mp4 -cat Credits.mp4
or
MP4Box Movie.mp4 -cat Credits.mp4 -out Movie2.mp4 -keepsys
I get the error :
Appending file Credits.mp4
No suitable destination track found - creating new one (type vide)
Saving to Movie.mp4: 0.500 secs Interleaving
And the resulting files ends up with 2 video tracks.
Can somebody please tell me what I'm doing wrong?
I can't use Avidemux to append the files, because the resulting mp4 are always garbled, producing artifacts when skipping.
foxyshadis
4th October 2007, 14:40
You have to encode with a different SPS/PPS, which avidemux doesn't give you the option of doing. So at least the credits will have to be done over the commandline (or any gui with custom commandline capability, since no gui gives access to those values either).
t3g
4th October 2007, 18:22
Thanks for the reply.
I've googled for SPS/PPS, but I'm still a bit lost. Which SPS/PPS should I chose to encode my credits with? Also, is there a how-to that covers SPS/PPS or is x264 documentation accessible enough without a technical background (no problem for the command line, but understanding the doc will be hard if it's just describing a specification)?
foxyshadis
5th October 2007, 01:10
All you have to do is add --sps-id x to any x264 commandline. Anything from 0-31 is legal iirc, 0 being default (so don't reuse it). A once-over of other x264 commands is available (http://mewiki.project357.com/index.php/Video_configuration_dialog/X264_Configuration), although it doesn't list the affected command-line options.
t3g
5th October 2007, 21:15
All you have to do is add --sps-id x to any x264 commandline. Anything from 0-31 is legal iirc, 0 being default (so don't reuse it). A once-over of other x264 commands is available (http://mewiki.project357.com/index.php/Video_configuration_dialog/X264_Configuration), although it doesn't list the affected command-line options.
However, I don't have any clue about what number I should use for the credits. From what you say, I understand both movie and credits are encoded with the default --sps-id 0 , thus causing the problem with MP4Box. Should I use --sps-id 1 when I reencode the credits, or is it more complicated?
foxyshadis
5th October 2007, 21:37
They're entirely arbitrary, use whatever strikes your fancy. 1 works fine. Oh, and make sure you have a recent mp4box build, older ones didn't support SPS/PPS segments.
Adub
5th October 2007, 22:36
One other alternative is to use MeGUI and the zone options that pop up when a avisynth script is loaded. I have set both the intro and credits to a totally different quant. using that handy feature.
Plus you don't need to go and join the files afterwards. Much less hassle.
t3g
6th October 2007, 01:26
One other alternative is to use MeGUI and the zone options
MeGUI is Windows-only (unless I'm mistaken), but yes, I can do that with mencoder/x264. However, I still have a lot of DVDs encoded without the video for the credits, because I only discovered recently that they're perfect at 50kbps (usually adding only 2Mo to the file).
t3g
7th October 2007, 18:39
They're entirely arbitrary, use whatever strikes your fancy. 1 works fine. Oh, and make sure you have a recent mp4box build, older ones didn't support SPS/PPS segments.
I tried encoding my credits with sps-id=1, but to no avail.
Here is the command line for encoding the credits
mencoder fin.mpg -vf crop=720:544:0:16 -ofps 25 -nosound -of rawvideo -o credits.264 -ovc x264 -x264encopts bitrate=65:bframes=16:b-pyramid:ref=15:pass=2:partitions=all:8x8dct:direct=temporal:weightb:me=umh:merange=64:subme=7:b-rdo:mixed-refs:bime:trellis=1:no-fast-pskip:no-dct-decimate:nr=0:fps=25:sps-id=1
However, when I do MP4Box Movie.mp4 -cat credits.mp4 -out MovieCredits.mp4
I get the same error :
Appending file credits.mp4
No suitable destination track found - creating new one (type vide)
I've got version 4.2 of GPAC - I didn't see anything in 4.4 changelog about sps/pps.
Thanks
bond
7th October 2007, 18:51
sps-id=1 is propably the default, try sps-id=2
t3g
7th October 2007, 20:35
sps-id=1 is propably the default, try sps-id=2
I just did, but it's the same result. I really wonder what the problem is - especially since people editing videos will sometimes want to cut/append them, and I don't think it'll work if they have to reencode the files - especially since reencoding an existing x264 video only leads to a loss of quality.
With vobs like I have, it's ok, but if the source is already an x264 video, that will never work.
bond
7th October 2007, 20:59
hm
extract both avc streams to .264, run h264_parse from mpeg4ip over the .264 files and post the results here
t3g
8th October 2007, 09:25
extract both avc streams to .264, run h264_parse from mpeg4ip over the .264 files and post the results here
Here is the first part of the output for the credits (whole output is 1.2Mo, see attached 7z) :
h264_parse credits_track1.h264 > credits
h264_parse - mpeg4ip version 1.6
Nal length 29 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 2
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 0
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
Here for the movie (whole output is 35Mo, 1.2Mo 7z but too big to attach):
h264_parse movie_track1.h264 > movie
h264_parse - mpeg4ip version 1.6
Nal length 29 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 0
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 1
aspect_ratio_idc:1
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
Thanks
bond
13th October 2007, 11:29
one has an aspect ratio set and the otherone doesnt
make sure you use the same ar options for both and try again
t3g
15th October 2007, 12:24
make sure you use the same ar options for both and try again
The problem is the same, even with no AR set for both movies, or with both movies having the same AR.
Here are the first parts of both files, with no AR set:
Credits :
h264_parse - mpeg4ip version 1.6
Nal length 29 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 2
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 0
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
Movie:
h264_parse - mpeg4ip version 1.6
Nal length 28 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 0
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 0
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
The only difference it "Nal length 29" and "Nal length 28", second line of each output - but I don't have any clue about its relevance (and, of course, seq parameter set id)
t3g
15th October 2007, 14:35
I did another test making sure the credits encoding options were the same as for the movie (movie was encoded with Avidemux, credits with mencoder) mencoder fin.mpg -vf crop=720:544:0:16 -ofps 25 -nosound -of rawvideo -o credits.264 -ovc x264 -x264encopts bitrate=70:bframes=15:b-pyramid:ref=16:pass=2:partitions=all:8x8dct:direct=temporal:weightb:me=umh:merange=64:subme=7:b-rdo:mixed-refs:bime:trellis=1:no-fast-pskip:no-dct-decimate:nr=0:fps=25:sps-id=1
The first past with mencoder has exact same option, except for pass=1 of course :)
This time, I'm quoting the output when both have a same AR set (instead of none).
Output for credits:
h264_parse - mpeg4ip version 1.6
Nal length 34 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 1
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 1
aspect_ratio_idc:255
sar_width: 576
sar_height: 405
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
Movie :
h264_parse - mpeg4ip version 1.6
Nal length 33 start code 4 bytes
ref 3 type 7 Sequence parameter set
profile: 100
constaint_set0_flag: 0
constaint_set1_flag: 0
constaint_set2_flag: 0
constaint_set3_flag: 0
level_idc: 51
seq parameter set id: 0
chroma format idx: 1
bit depth luma minus8: 0
bit depth chroma minus8: 0
Qpprime Y Zero Transform Bypass flag: 0
Seq Scaling Matrix Present Flag: 0
log2_max_frame_num_minus4: 5
pic_order_cnt_type: 0
log2_max_pic_order_cnt_lsb_minus4: 6
num_ref_frames: 16
gaps_in_frame_num_value_allowed_flag: 0
pic_width_in_mbs_minus1: 44 (720)
pic_height_in_map_minus1: 33
frame_mbs_only_flag: 1
derived height: 544
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
vui_parameters_present_flag: 1
aspect_ratio_info_present_flag: 1
aspect_ratio_idc:255
sar_width: 576
sar_height: 405
overscan_info_present_flag: 0
video_signal_info_present_flag: 0
chroma_loc_info_present_flag: 0
timing_info_present_flag: 1
num_units_in_tick: 1
time_scale: 50
fixed_frame_scale: 1
nal_hrd_parameters_present_flag: 0
vcl_hrd_parameters_present_flag: 0
pic_struct_present_flag: 0
motion_vectors_over_pic_boundaries_flag: 1
max_bytes_per_pic_denom: 0
max_bits_per_mb_denom: 0
log2_max_mv_length_horizontal: 11
log2_max_mv_length_vertical: 11
num_reorder_frames: 2
max_dec_frame_buffering: 16
Further in the output, there's this:
Credits string is ".E....H..,. .#..x264 - core 54 - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=7 brdo=1 mixed_ref=1 me_range=64 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 chroma_qp_offset=0 threads=1 nr=0 decimate=0 mbaff=0 bframes=15 b_pyramid=1 b_adapt=1 b_bias=0 direct=2 wpredb=1 bime=1 keyint=250 keyint_min=25 scenecut=40 rc=2pass bitrate=70 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."
Movie string is ".E....H..,. .#..x264 - core 54 svn-esportato - H.264/MPEG-4 AVC codec - Copyleft 2005 - http://www.videolan.org/x264.html - options: cabac=1 ref=16 deblock=1:0:0 analyse=0x3:0x133 me=umh subme=7 brdo=1 mixed_ref=1 me_range=64 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 chroma_qp_offset=0 threads=1 nr=0 decimate=0 mbaff=0 bframes=15 b_pyramid=1 b_adapt=1 b_bias=0 direct=2 wpredb=1 bime=1 keyint=250 keyint_min=25 scenecut=40 rc=2pass bitrate=1013 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."
Only differences is "core 54"/"core 54 svn-esportato" which might refer to the version of x264 used, and Avidemux using comas where mencoder uses dots (in "qcomp=0,60"/"qcomp=0.60" and "cplxblur=20,0 qblur=0,5 ip_ratio=1,40 pb_ratio=1,30."/"cplxblur=20.0 qblur=0.5 ip_ratio=1.40 pb_ratio=1.30.")
I'm wondering : has anyone used MP4Box -cat option with any success?
bond
15th October 2007, 20:47
ok, last try
try to encode the credits with exactly the same options as the movie (so, no different spsids, exactly the same encoder binary used...)
and post both the sps and pps of both streams, maybe a different pps causes this
t3g
16th October 2007, 01:09
ok, last try
try to encode the credits with exactly the same options as the movie (so, no different spsids, exactly the same encoder binary used...)
That's what I did at first (before starting this thread :) )
I encoded the credits with Avidemux, using the same options (except for the bitrate, since that's the whole point of it).
However, your post gave me an idea - I just appended the credits to a copy of them - so the 2 files were exactly the same, except for the name, and it works. If I do the same with the whole movie and its copy, it works too - but the time is messed up, VLC nly shows 1:50' but still plays the second movie after that.
So it's definitely not necessary to have a different sps/pps - and there's no proof it works when they are different (though I wouldn't understand what would be the problem with having them different).
I'd still like to know what makes it impossible for MP4Box to append the credits to the movie - I can't imagine the option has much use if it's so fussy.
In the next few days, I'll try reencoding the credits with Avidemux again, using different options (even with a bitrate equivalent to the movie's). Meanwhile, if you have other suggestions, I'm all ears.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.