diff --git a/src/mp4/moof.c b/src/mp4/moof.c index abd7a98..ede03a6 100644 --- a/src/mp4/moof.c +++ b/src/mp4/moof.c @@ -277,11 +277,11 @@ enum BufError write_trun( err = put_u8(ptr, 0); chk_err; // 1 version - const bool data_offset_present = true; - const bool first_sample_flags_present = false; - const bool sample_duration_present = true; - const bool sample_size_present = true; - const bool sample_flags_present = true; + 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; { uint64_t flags = 0x0; if (data_offset_present) { @@ -319,7 +319,7 @@ enum BufError write_trun( err = put_i32_be(ptr, 0); chk_err; // 4 fake data_offset } - + if (first_sample_flags_present) { err = put_u32_be(ptr, is_audio ? 0 : 33554432); chk_err; // 4 first_sample_flags diff --git a/src/mp4/moov.c b/src/mp4/moov.c index bca9f15..af1e3d7 100644 --- a/src/mp4/moov.c +++ b/src/mp4/moov.c @@ -720,10 +720,10 @@ enum BufError write_ObjectDescriptor(struct BitBuf *ptr, const struct MoovInfo * chk_err; // flags err = write_DecoderConfig(ptr, moov_info); chk_err; - err = write_TagAudioSpecificConfig(ptr, moov_info); - chk_err; err = write_SLConfigDescriptor(ptr); chk_err; + err = write_TagAudioSpecificConfig(ptr, moov_info); + chk_err; err = put_u32_le_to_offset(ptr, var_len, varint32(ptr->offset - var_len - 4)); chk_err; return BUF_OK; diff --git a/src/mp4/mp4.c b/src/mp4/mp4.c index 0281e56..e38bb3c 100644 --- a/src/mp4/mp4.c +++ b/src/mp4/mp4.c @@ -99,20 +99,17 @@ enum BufError mp4_set_slice(const char *nal_data, const uint32_t nal_len, char is_iframe) { enum BufError err; - const uint32_t samples_info_len = 1; - struct SampleInfo samples_info[2]; + struct SampleInfo samples_info[9]; 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 = 40000.f * - (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, - samples_info_len, samples_info + 1, 1); + 1, samples_info + 1, buf_aud.offset / aud_framesize); chk_err; buf_mdat.offset = 0;