Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d1fe10cd authored by James Dong's avatar James Dong Committed by Android (Google) Code Review
Browse files

Merge "Fix initial 0 duration video sample in the recorded videos"

parents bdbe6939 2c8e8508
Loading
Loading
Loading
Loading
+12 −8
Original line number Diff line number Diff line
@@ -1172,6 +1172,9 @@ void MPEG4Writer::Track::addOneStssTableEntry(size_t sampleId) {
void MPEG4Writer::Track::addOneSttsTableEntry(
        size_t sampleCount, int32_t duration) {

    if (duration == 0) {
        LOGW("%d 0-duration samples found: %d", sampleCount);
    }
    SttsTableEntry sttsEntry(sampleCount, duration);
    mSttsTableEntries.push_back(sttsEntry);
    ++mNumSttsTableEntries;
@@ -2001,9 +2004,6 @@ status_t MPEG4Writer::Track::threadEntry() {
            mTrackDurationUs = timestampUs;
        }

        mSampleSizes.push_back(sampleSize);
        ++mNumSamples;
        if (mNumSamples > 2) {
        // We need to use the time scale based ticks, rather than the
        // timestamp itself to determine whether we have to use a new
        // stts entry, since we may have rounding errors.
@@ -2013,6 +2013,10 @@ status_t MPEG4Writer::Track::threadEntry() {
            ((timestampUs * mTimeScale + 500000LL) / 1000000LL -
                (lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);

        mSampleSizes.push_back(sampleSize);
        ++mNumSamples;
        if (mNumSamples > 2) {

            // Force the first sample to have its own stts entry so that
            // we can adjust its value later to maintain the A/V sync.
            if (mNumSamples == 3 || currDurationTicks != lastDurationTicks) {