diff --git a/src/mp4/moof.c b/src/mp4/moof.c index ede03a6..8f7ba6e 100644 --- a/src/mp4/moof.c +++ b/src/mp4/moof.c @@ -175,11 +175,11 @@ enum BufError write_tfhd( uint64_t flags = 0x0; const bool base_data_offset_present = false; const bool sample_description_index_present = false; - const bool default_sample_duration_present = true; + const bool default_sample_duration_present = false; const bool default_sample_size_present = true; const bool default_sample_flags_present = true; const bool duration_is_empty = false; - const bool default_base_is_moof = false; + const bool default_base_is_moof = true; if (base_data_offset_present) { flags = flags | 0x000001; @@ -278,10 +278,9 @@ enum BufError write_trun( err = put_u8(ptr, 0); chk_err; // 1 version bool data_offset_present = true; - bool first_sample_flags_present = false; - bool sample_duration_present = !is_audio; - bool sample_size_present = !is_audio; - bool sample_flags_present = !is_audio; + bool first_sample_flags_present = true; + bool sample_duration_present = true; + bool sample_size_present = true; { uint64_t flags = 0x0; if (data_offset_present) { @@ -296,9 +295,6 @@ enum BufError write_trun( if (sample_size_present) { flags = flags | 0x000200; } // 0x000200 sample-size-present - if (sample_flags_present) { - flags = flags | 0x000400; - } // 0x000400 sample-flags-present err = put_u8(ptr, flags >> 16); chk_err; @@ -334,10 +330,6 @@ enum BufError write_trun( err = put_u32_be(ptr, sample_info.size); chk_err; // 4 sample_size } - if (sample_flags_present) { - err = put_u32_be(ptr, sample_info.flags); - chk_err; // 4 sample_flags - } } err = put_u32_be_to_offset(ptr, start_atom, ptr->offset - start_atom); diff --git a/src/mp4/mp4.c b/src/mp4/mp4.c index e38bb3c..28b2cfe 100644 --- a/src/mp4/mp4.c +++ b/src/mp4/mp4.c @@ -99,17 +99,19 @@ enum BufError mp4_set_slice(const char *nal_data, const uint32_t nal_len, char is_iframe) { enum BufError err; - struct SampleInfo samples_info[9]; + struct SampleInfo samples_info[2]; memset(samples_info, 0, sizeof(samples_info)); samples_info[0].size = nal_len + 4; // add size of sample samples_info[0].duration = default_sample_size; samples_info[0].flags = is_iframe ? 0 : 65536; samples_info[1].size = buf_aud.offset; + samples_info[1].duration = default_sample_size * + buf_aud.offset / (aud_bitrate * 25 / 6.f); buf_moof.offset = 0; err = write_moof( &buf_moof, 0, 0, 0, default_sample_size, samples_info, - 1, samples_info + 1, buf_aud.offset / aud_framesize); + 1, samples_info + 1, 1); chk_err; buf_mdat.offset = 0;