Skip to content

Commit

Permalink
mp4: VLC and quicktime player compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
suzp1984 committed Sep 30, 2024
1 parent 652cdef commit ad6a185
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion trunk/src/app/srs_app_dvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,29 @@ srs_error_t SrsDvrPlan::on_video(SrsSharedPtrMessage* shared_video, SrsFormat* f
if (!dvr_enabled) {
return err;
}


// skip any SEI type nalus
if (format->vcodec->id == SrsVideoCodecIdAVC) {
for (int i = 0; i < format->video->nb_samples; ++i) {
SrsSample* sample = &format->video->samples[i];
SrsAvcNaluType avc_nalu_type;

if ((err = SrsVideoFrame::parse_avc_nalu_type(sample, avc_nalu_type)) != srs_success) {
return srs_error_wrap(err, "parse avc nalu_type");
}

if (avc_nalu_type == SrsAvcNaluTypeSEI) {
return err;
}
}
}

// quicktime player compatible: skip the packet without any nalu.
if (!format->is_avc_sequence_header() && format->video->nb_samples == 0) {
srs_warn("skip video segment has empty samples and is not sequence header.");
return err;
}

if ((err = segment->write_video(shared_video, format)) != srs_success) {
return srs_error_wrap(err, "write video");
}
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/kernel/srs_kernel_mp4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5696,7 +5696,7 @@ srs_error_t SrsMp4Encoder::initialize(ISrsWriteSeeker* ws)

ftyp->major_brand = SrsMp4BoxBrandISOM;
ftyp->minor_version = 512;
ftyp->set_compatible_brands(SrsMp4BoxBrandISOM, SrsMp4BoxBrandISO2, SrsMp4BoxBrandMP41);
ftyp->set_compatible_brands(SrsMp4BoxBrandISOM, SrsMp4BoxBrandISO2, SrsMp4BoxBrandAVC1, SrsMp4BoxBrandMP41);

int nb_data = ftyp->nb_bytes();
std::vector<char> data(nb_data);
Expand Down

0 comments on commit ad6a185

Please sign in to comment.