diff --git a/trunk/src/kernel/srs_kernel_mp4.cpp b/trunk/src/kernel/srs_kernel_mp4.cpp index 6cb93ffc66..fed0541b50 100644 --- a/trunk/src/kernel/srs_kernel_mp4.cpp +++ b/trunk/src/kernel/srs_kernel_mp4.cpp @@ -3319,6 +3319,9 @@ int SrsMp4SampleManager::load_trak(map& tses, SrsCodecF // For each chunk offset. for (uint32_t ci = 0; ci < stco->entry_count; ci++) { + // The sample offset relative in chunk. + uint32_t sample_relative_offset = 0; + // Find how many samples from stsc. SrsMp4StscEntry* stsc_entry = stsc->on_chunk(ci); for (uint32_t i = 0; i < stsc_entry->samples_per_chunk; i++) { @@ -3326,12 +3329,13 @@ int SrsMp4SampleManager::load_trak(map& tses, SrsCodecF sample->type = tt; sample->index = (previous? previous->index+1:0); sample->tbn = mdhd->timescale; + sample->offset = stco->entries[ci] + sample_relative_offset; uint32_t sample_size = 0; if ((ret = stsz->get_sample_size(sample->index, &sample_size)) != ERROR_SUCCESS) { return ret; } - sample->offset = stco->entries[ci] + sample_size * i; + sample_relative_offset += sample_size; SrsMp4SttsEntry* stts_entry = NULL; if ((ret = stts->on_sample(sample->index, &stts_entry)) != ERROR_SUCCESS) { diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index c5452ea08c..173f807c2e 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -2602,33 +2602,44 @@ int srs_human_print_rtmp_packet4(char type, uint32_t timestamp, char* data, int ndiff = (int)(srs_utils_time_ms() - pre_now); } + char sbytes[40]; + if (true) { + int nb = srs_min(8, size); + int p = 0; + for (int i = 0; i < nb; i++) { + p += snprintf(sbytes+p, 40-p, "0x%02x ", (uint8_t)data[i]); + } + } + uint32_t pts; if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) { - srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, ndiff=%d, diff=%d, size=%d, DecodeError", - nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, ndiff, diff, size + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, ndiff=%d, diff=%d, size=%d, DecodeError, (%s)", + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, ndiff, diff, size, sbytes ); return ret; } if (type == SRS_RTMP_TYPE_VIDEO) { - srs_human_trace("Video packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d, %s(%s,%s)", + srs_human_trace("Video packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d, %s(%s,%s), (%s)", nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, pts, ndiff, diff, size, srs_human_flv_video_codec_id2string(srs_utils_flv_video_codec_id(data, size)), srs_human_flv_video_avc_packet_type2string(srs_utils_flv_video_avc_packet_type(data, size)), - srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size)) + srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size)), + sbytes ); } else if (type == SRS_RTMP_TYPE_AUDIO) { - srs_human_trace("Audio packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d, %s(%s,%s,%s,%s)", + srs_human_trace("Audio packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d, %s(%s,%s,%s,%s), (%s)", nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, pts, ndiff, diff, size, srs_human_flv_audio_sound_format2string(srs_utils_flv_audio_sound_format(data, size)), srs_human_flv_audio_sound_rate2string(srs_utils_flv_audio_sound_rate(data, size)), srs_human_flv_audio_sound_size2string(srs_utils_flv_audio_sound_size(data, size)), srs_human_flv_audio_sound_type2string(srs_utils_flv_audio_sound_type(data, size)), - srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size)) + srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size)), + sbytes ); } else if (type == SRS_RTMP_TYPE_SCRIPT) { - srs_human_trace("Data packet id=%"PRId64"/%.1f/%.1f, type=%s, time=%d, ndiff=%d, diff=%d, size=%d", - nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, ndiff, diff, size); + srs_human_trace("Data packet id=%"PRId64"/%.1f/%.1f, type=%s, time=%d, ndiff=%d, diff=%d, size=%d, (%s)", + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, ndiff, diff, size, sbytes); int nparsed = 0; while (nparsed < size) { int nb_parsed_this = 0; @@ -2644,8 +2655,8 @@ int srs_human_print_rtmp_packet4(char type, uint32_t timestamp, char* data, int srs_freepa(amf0_str); } } else { - srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%#x, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d", - nb_packets, pi, gfps, type, timestamp, pts, ndiff, diff, size); + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%#x, dts=%d, pts=%d, ndiff=%d, diff=%d, size=%d, (%s)", + nb_packets, pi, gfps, type, timestamp, pts, ndiff, diff, size, sbytes); } return ret;