Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
16th August 2009, 12:31 | #1 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 720
|
Matching encoding options to concatenate streams
I'm trying to edit a H264 video stored in a MP4 container to replace a short sequence by one of my own. I use ffmpeg with libx264 to encode my new sequence. I use mp4box to split the original video into segments and concatenate them with the new sequence.
I encounter some difficulties during the concatenation. I read on this thread that the streams need to use exactly the same encoding options. However I don't know the options set to generate the source video. I ran h264_parse on both versions of the sequence I want to replace and obtained the following differences (full dump of the sps and pps sections at the end of the post): Code:
Sequence parameter set: [orig] level_idc: 41 [mine] level_idc: 40 [orig] num_ref_frames: 4 [mine] num_ref_frames: 6 [orig] time_scale: 48000 [mine] time_scale: 48002 [orig] num_reorder_frames: 1 max_dec_frame_buffering: 4 [mine] num_reorder_frames: 2 max_dec_frame_buffering: 6 Picture parameter set: [orig] pic_init_qp_minus26: -5 [mine] pic_init_qp_minus26: 0 Any help appreciated. ______ Code:
*** Original *** 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: 41 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: 4 gaps_in_frame_num_value_allowed_flag: 0 pic_width_in_mbs_minus1: 79 (1280) pic_height_in_map_minus1: 44 frame_mbs_only_flag: 1 derived height: 720 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: 1001 time_scale: 48000 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: 1 max_dec_frame_buffering: 4 Nal length 10 start code 4 bytes ref 3 type 8 Picture parameter set pic_parameter_set_id: 0 seq_parameter_set_id: 0 entropy_coding_mode_flag: 1 pic_order_present_flag: 0 num_slice_groups_minus1: 0 num_ref_idx_l0_active_minus1: 0 num_ref_idx_l1_active_minus1: 0 weighted_pred_flag: 0 weighted_bipred_idc: 2 pic_init_qp_minus26: -5 pic_init_qs_minus26: 0 chroma_qp_index_offset: -2 deblocking_filter_control_present_flag: 1 constrained_intra_pred_flag: 0 redundant_pic_cnt_present_flag: 0 transform_8x8_mode_flag: 1 pic_scaling_matrix_present_flag: 0 second_chroma_qp_index_offset: 4294967294 [...] *** Mine *** 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: 40 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: 6 gaps_in_frame_num_value_allowed_flag: 0 pic_width_in_mbs_minus1: 79 (1280) pic_height_in_map_minus1: 44 frame_mbs_only_flag: 1 derived height: 720 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: 1001 time_scale: 48002 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: 6 Nal length 9 start code 4 bytes ref 3 type 8 Picture parameter set pic_parameter_set_id: 0 seq_parameter_set_id: 0 entropy_coding_mode_flag: 1 pic_order_present_flag: 0 num_slice_groups_minus1: 0 num_ref_idx_l0_active_minus1: 0 num_ref_idx_l1_active_minus1: 0 weighted_pred_flag: 0 weighted_bipred_idc: 2 pic_init_qp_minus26: 0 pic_init_qs_minus26: 0 chroma_qp_index_offset: -2 deblocking_filter_control_present_flag: 1 constrained_intra_pred_flag: 0 redundant_pic_cnt_present_flag: 0 transform_8x8_mode_flag: 1 pic_scaling_matrix_present_flag: 0 second_chroma_qp_index_offset: 4294967294 [...] Last edited by cretindesalpes; 16th August 2009 at 12:38. |
16th August 2009, 17:47 | #3 | Link | ||
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 720
|
Quote:
Quote:
|
||
16th August 2009, 18:42 | #5 | Link |
Registered User
Join Date: May 2004
Location: Finland
Posts: 102
|
That is if the video was encoded with x264. For other encoders it only tells what profile video is, if cabac was used, reframes bitrate and aspect ratio. I don't know, are there other free video tools that collect the info from the video stream itself?
|
16th August 2009, 19:45 | #7 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 720
|
Thank you for your replies.
I almost got the job done:
|
16th August 2009, 20:06 | #10 | Link | |
Registered User
Join Date: Mar 2008
Posts: 118
|
Quote:
Also, how do global headers factor into this? Should you (and how do you) rewrite the MKV or MP4 headers after concatenating like this...remux it using MKVtoolnix? (I heard some time ago that MKVmerge only read the first part of a concatenated stream, but that may have changed.) |
|
16th August 2009, 22:14 | #13 | Link |
͡҉҉ ̵̡̢̛̗̘̙̜̝̞̟̠͇̊̋̌̍̎̏̿̿
Join Date: Feb 2009
Location: No support in PM
Posts: 720
|
I had to switch to x264.exe to use --sps-id, because I couldn't find the equivalent function in ffmpeg. But the SPS-ID trick doen't impress mp4box, which still identifies the tracks as different and doesn't want to concatenate them. Finally I could set the right pic_init_qp_minus26 value by using --qp 21 and made mp4box happy.
|
16th August 2009, 22:18 | #14 | Link | |
x264 developer
Join Date: Sep 2005
Posts: 8,666
|
Quote:
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|