Skip to content

Commit

Permalink
Continuing to fix audio on MP4 containers
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 13, 2024
1 parent 011cebc commit 9f76866
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/mp4/moof.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ enum BufError write_trun(
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;
{
uint64_t flags = 0x0;
if (data_offset_present) {
Expand All @@ -295,6 +296,9 @@ 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;

Expand Down Expand Up @@ -330,6 +334,10 @@ 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);
Expand Down
3 changes: 2 additions & 1 deletion src/mp4/mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ enum BufError mp4_set_slice(const char *nal_data, const uint32_t nal_len,
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 = 1152 * buf_aud.offset / aud_framesize;
samples_info[1].duration = 40000.f *
(buf_aud.offset / (aud_bitrate * 25 / 6.f));

buf_moof.offset = 0;
err = write_moof(
Expand Down

0 comments on commit 9f76866

Please sign in to comment.