我寫的小工具 rtmp_parse.exe
使用用法如先介紹下:服務器
-sps [文件路徑] 解析 sps 數據 文件當中的內容就是純方本的hexstring: 如 42 E0 33 8D 68 05 00 5B A1 00 00 03 00 ……
-pps [文件路徑] 解析 pps 數據 文件格式同上
-rtmp [文件路徑] 解析並保存h264視頻流數據(從wireshark抓出來的hexstring)
下載地址:app
連接:https://pan.baidu.com/s/1RhRKoNqTPHLj4mrpryunDQ 密碼:v7lb tcp
解壓密碼:rtmp
ide
下載包當中包含了我抓取的wireshark的兩個例子。工具
原理以下:
ui
wireshark保存出來的文件格式規則是spa
我是基於這點來判斷是誰發給誰的數據,從而進行分析的。3d
rtmp協議:rest
07 00 00 00 00 00 2C 09 01 00 00 00 17
00
00 00 00 01 => nal頭
42 E0 33 FF E1 00 18 27 42 E0 33 8D 68 05 00 5B => sps
A1 00 00 03 00 01 00 00 03 00 3C 0F 10 7A 80
01
00 04 => pps len
28 CE 32 48 => ppsorm
解析 sps 數據,我獲得詳細的結構數據以下:
profile_idc: 66
constraint_set0_flag: 1
constraint_set1_flag: 1
constraint_set2_flag: 1
constraint_set3_flag: 0
constraint_set4_flag: 0
constraint_set5_flag: 0
reserved_zero_2bits: 0
level_idc: 51
seq_parameter_set_id: 0
chroma_format_idc: 1
residual_colour_transform_flag: 0
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: 12
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: 79
pic_height_in_map_units_minus1: 44
frame_mbs_only_flag: 1
mb_adaptive_frame_field_flag: 0
direct_8x8_inference_flag: 1
frame_cropping_flag: 0
frame_crop_left_offset: 0
frame_crop_right_offset: 0
frame_crop_top_offset: 0
frame_crop_bottom_offset: 0
vui_parameters_present_flag: 1
vui.aspect_ratio_info_present_flag: 0
vui.aspect_ratio_idc: 0
vui.sar_width: 0
vui.sar_height: 0
vui.overscan_info_present_flag: 0
vui.overscan_appropriate_flag: 0
vui.video_signal_type_present_flag: 0
vui.video_format: 0
vui.video_full_range_flag: 0
vui.colour_description_present_flag: 0
vui.colour_primaries: 0
vui.transfer_characteristics: 0
vui.matrix_coefficients: 0
vui.chroma_loc_info_present_flag: 0
vui.chroma_sample_loc_type_top_field: 0
vui.chroma_sample_loc_type_bottom_field: 0
vui.timing_info_present_flag: 1
vui.num_units_in_tick: 768
vui.time_scale: 16777219
vui.fixed_frame_rate_flag: 0
vui.nal_hrd_parameters_present_flag: 0
vui.vcl_hrd_parameters_present_flag: 0
vui.low_delay_hrd_flag: 0
vui.pic_struct_present_flag: 0
vui.bitstream_restriction_flag: 0
vui.motion_vectors_over_pic_boundaries_flag: 0
vui.max_bytes_per_pic_denom: 0
vui.max_bits_per_mb_denom: 0
vui.log2_max_mv_length_horizontal: 0
vui.log2_max_mv_length_vertical: 0
vui.num_reorder_frames: 0
vui.max_dec_frame_buffering: 0
hrd_nal.cpb_cnt_minus1: 0
hrd_nal.bit_rate_scale: 0
hrd_nal.cpb_size_scale: 0
hrd_nal.initial_cpb_removal_delay_length_minus1: 0
hrd_nal.cpb_removal_delay_length_minus1: 0
hrd_nal.dpb_output_delay_length_minus1: 0
hrd_nal.time_offset_length: 0
hrd_vcl.cpb_cnt_minus1: 0
hrd_vcl.bit_rate_scale: 0
hrd_vcl.cpb_size_scale: 0
hrd_vcl.initial_cpb_removal_delay_length_minus1: 0
hrd_vcl.cpb_removal_delay_length_minus1: 0
hrd_vcl.dpb_output_delay_length_minus1: 0
hrd_vcl.time_offset_length: 0
解析 pps 獲得以下結構數據:
pic_parameter_set_id: 4
seq_parameter_set_id: 11
entropy_coding_mode_flag: 1
pic_order_present_flag: 1
num_slice_groups_minus1: 0
slice_group_map_type: 0
slice_group_change_direction_flag: 0
slice_group_change_rate_minus1: 0
pic_size_in_map_units_minus1: 0
num_ref_idx_l0_active_minus1: 11
num_ref_idx_l1_active_minus1: 0
weighted_pred_flag: 0
weighted_bipred_idc: 1
pic_init_qp_minus26: 2
pic_init_qs_minus26: 0
chroma_qp_index_offset: 0
deblocking_filter_control_present_flag: 0
constrained_intra_pred_flag: 0
redundant_pic_cnt_present_flag: 0
_more_rbsp_data_present: 0
transform_8x8_mode_flag: 0
pic_scaling_matrix_present_flag: 0
second_chroma_qp_index_offset: 0
/* RTMP_PACKET_TYPE_... 0x00 */
#define RTMP_PACKET_TYPE_CHUNK_SIZE 0x01
/* RTMP_PACKET_TYPE_... 0x02 */
#define RTMP_PACKET_TYPE_BYTES_READ_REPORT 0x03
#define RTMP_PACKET_TYPE_CONTROL 0x04
#define RTMP_PACKET_TYPE_SERVER_BW 0x05
#define RTMP_PACKET_TYPE_CLIENT_BW 0x06
/* RTMP_PACKET_TYPE_... 0x07 */
#define RTMP_PACKET_TYPE_AUDIO 0x08
#define RTMP_PACKET_TYPE_VIDEO 0x09
/* RTMP_PACKET_TYPE_... 0x0A */
/* RTMP_PACKET_TYPE_... 0x0B */
/* RTMP_PACKET_TYPE_... 0x0C */
/* RTMP_PACKET_TYPE_... 0x0D */
/* RTMP_PACKET_TYPE_... 0x0E */
#define RTMP_PACKET_TYPE_FLEX_STREAM_SEND 0x0F
#define RTMP_PACKET_TYPE_FLEX_SHARED_OBJECT 0x10
#define RTMP_PACKET_TYPE_FLEX_MESSAGE 0x11
#define RTMP_PACKET_TYPE_INFO 0x12
#define RTMP_PACKET_TYPE_SHARED_OBJECT 0x13
#define RTMP_PACKET_TYPE_INVOKE 0x14
/* RTMP_PACKET_TYPE_... 0x15 */
#define RTMP_PACKET_TYPE_FLASH_VIDEO 0x16
最後看一下,從wireshark當中導出的視頻截圖: