关于pps 和 sps 有两种方法传给播放器
一、发送SDP方式。
- 参数 sprop-parameter-sets 就是 pps sps 的base64转换码,中间用"," 隔开。
二、当有客户加入组播时发送
- 因为pps 和 sps相同 ,不会影响 到原来已连接上的 客户端 。
三、每个I_Frame 前加上
SDP中的H.264的SPS和PPS串,包含了初始化H.264解码器所需要的信息参数,包括编码所用的profile,level,图像的宽和高,deblock滤波器等。
由于SDP中的SPS和PPS都是BASE64编码形式的,不容易理解。例如:
sps中的内容为:
Z0LgFNoFglE=
pps中的内容为:
aM4wpIA=
最终解析的到的结果为:
Start dumping SPS:
profile_idc = 66
constrained_set0_flag = 1
constrained_set1_flag = 1
constrained_set2_flag = 1
constrained_set3_flag = 0
level_idc = 20
seq_parameter_set_id = 0
chroma_format_idc = 1
bit_depth_luma_minus8 = 0
bit_depth_chroma_minus8 =0
seq_scaling_matrix_present_flag= 0
log2_max_frame_num_minus4 =0
pic_order_cnt_type = 2
log2_max_pic_order_cnt_lsb_minus4= 0
delta_pic_order_always_zero_flag= 0
offset_for_non_ref_pic =0
offset_for_top_to_bottom_field= 0
num_ref_frames_in_pic_order_cnt_cycle= 0
num_ref_frames = 1
gaps_in_frame_num_value_allowed_flag= 0
pic_width_in_mbs_minus1 =21
pic_height_in_mbs_minus1 =17
frame_mbs_only_flag = 1
mb_adaptive_frame_field_flag =0
direct_8x8_interence_flag =0
frame_cropping_flag = 0
frame_cropping_rect_left_offset= 0
frame_cropping_rect_right_offset= 0
frame_cropping_rect_top_offset= 0
frame_cropping_rect_bottom_offset= 0
vui_parameters_present_flag =0
Start dumping PPS:
pic_parameter_set_id = 0
seq_parameter_set_id = 0
entropy_coding_mode_flag =0
pic_order_present_flag =0
num_slice_groups_minus1 =0
slice_group_map_type = 0
num_ref_idx_l0_active_minus1 =0
num_ref_idx_l1_active_minus1 =0
weighted_pref_flag = 0
weighted_bipred_idc = 0
pic_init_qp_minus26 = 0
pic_init_qs_minus26 = 0
chroma_qp_index_offset =10
deblocking_filter_control_present_flag= 1
constrained_intra_pred_flag =0
redundant_pic_cnt_present_flag= 0
transform_8x8_mode_flag =0
pic_scaling_matrix_present_flag= 0
second_chroma_qp_index_offset =10
/
这里需要特别提一下这两个参数
pic_width_in_mbs_minus1 = 21
pic_height_in_mbs_minus1 =17
分别表示图像的宽和高,以宏块(16x16)为单位的值减1
因此,实际的宽为 (21+1)*16 = 352
使用RTSP传输H264的时候,需要用到sdp协议描述,其中有两项:Sequence Parameter Sets (SPS) 和Picture Parameter Set (PPS)需要用到,那么这两项从哪里获取呢?答案是从H264码流中获取.在H264码流中,都是以"0x00 0x00 0x01"或者"0x00 0x00 0x00 0x01"为开始码的,找到开始码之后,使用开始码之后的第一个字节的低5位判断是否为7(sps)或者8(pps), 及data[4] & 0x1f == 7 || data[4] & 0x1f == 8.然后对获取的nal去掉开始码之后进行base64编码,得到的信息就可以用于sdp. sps和pps需要用逗号分隔开来.