Skip to content

Commit

Permalink
MDAT boxes retain valid and extractible MP3 frames, MOOF boxes are in…
Browse files Browse the repository at this point in the history
… cause
  • Loading branch information
wberube committed Aug 13, 2024
1 parent 9f76866 commit 693cfe1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
12 changes: 6 additions & 6 deletions src/mp4/moof.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/mp4/moov.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/mp4/mp4.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 693cfe1

Please sign in to comment.