我一开始就用这个标题/参数损坏了视频流。
[sps]
00 00 00 01
67 64 00 2A AD 84 01 0C 20 08 61 00 43 08 02 18 40 10 C2 00 84 2B 50 3C 01 13 F2 C2 00 00 03 00 02 00 00 03 00 79 08
[pps]
68 EE 3C B0
我试图找出实际值,但我没有。
有人知道其他字节代表什么吗?
我想知道如何计算视频尺寸(宽 x 高)。
最佳答案
干得好:
### Sequence Parameter Set
profile_idc 100
constraint_set0_flag 0
constraint_set1_flag 0
constraint_set2_flag 0
constraint_set3_flag 0
level_idc 42
seq_parameter_set_id 0
chroma_format_idc 1
// TODO: ...
// TODO: ...
num_ref_frames 1
gaps_in_frame_num_value_allowed_flag 1
pic_width_in_mbs_minus1 119
pic_height_in_map_units_minus1 67
frame_mbs_only_flag 1
direct_8x8_inference_flag 1
frame_cropping_flag 1
frame_crop_left_offset 0
frame_crop_right_offset 0
frame_crop_top_offset 0
frame_crop_bottom_offset 4
vui_parameters_present_flag 1
// TODO: ...
### Picture Parameter Set
pic_parameter_set_id 0
seq_parameter_set_id 0
entropy_coding_mode_flag 1
num_slice_groups_minus1 0
// TODO: ...
它是 1920x1080 的视频:您基本上解析出每个规范的值,然后按照这篇文章中的描述计算尺寸:Fetching the dimensions of a H264Video stream
具体来说:
width = ((pic_width_in_mbs_minus1 + 1) * 16)
- (frame_crop_left_offset + frame_crop_right_offset) * 2
height= (2 - frame_mbs_only_flag) * ((pic_height_in_map_units_minus1 + 1) * 16)
- (frame_crop_top_offset + frame_crop_bottom_offset) * 2
让你
120 * 16
来自 68 * 16 - 8
(假设 4:2:0 颜色采样)。2014-10-10 更新 :我是从编辑/评论中提出来的:
The conversion from field to frame
(2 - frame_mbs_only_flag)
is applied to the clipping region as well. The x2 for subWidthC and subHeightC is only for Color sampling 4:2:0. 4:4:4, 4:2:2, and Monochrome use x1 for one or both of the x2s.
关于video - 如何使用H.264流中的SPS、PPS信息计算视频尺寸,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21774212/