Skip to content

Commit

Permalink
Исправлена ошибка в вычислении длительностей фрагментов.
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene-k committed Dec 7, 2010
1 parent f974a60 commit 15ad955
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mp4frag/mp4frag.cc
Expand Up @@ -34,6 +34,7 @@ using namespace boost::system;
void generate_fragments(std::vector<Fragment>& fragments, boost::shared_ptr<mp4::Context>& ctx, double timestep) {
double limit_ts = timestep;
double now;
double timebase = 0;
unsigned nsample = 0;
fragments.clear();

Expand All @@ -45,6 +46,10 @@ void generate_fragments(std::vector<Fragment>& fragments, boost::shared_ptr<mp4:
now = si->timestamp();

if ( si->_video && si->_keyframe && now >= limit_ts ) {
if ( fragments.size() ) {
fragments.back()._duration = now - timebase;
timebase = now;
}
fragments.push_back(Fragment());
samplelist = &(fragments.back()._samples);
limit_ts = now + timestep;
Expand All @@ -57,6 +62,9 @@ void generate_fragments(std::vector<Fragment>& fragments, boost::shared_ptr<mp4:
fragments.back()._duration += now;
fragments.back()._totalsize += si->_sample_size + 11 + (si->_video ? 5 : 2) + 4;
}
if ( fragments.size() ) {
fragments.back()._duration = ctx->duration() - timebase;
}
}


Expand Down

0 comments on commit 15ad955

Please sign in to comment.