Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1018)

Unified Diff: media/filters/ffmpeg_demuxer.cc

Issue 2563183002: Fix up missing timestamps in FFmpegDemuxer. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_demuxer.cc
diff --git a/media/filters/ffmpeg_demuxer.cc b/media/filters/ffmpeg_demuxer.cc
index 0c532d0edb1a84a026487497e29bdc7a5f10bb93..23de0e26c92d2ad9d604e251c3cbfff028248439 100644
--- a/media/filters/ffmpeg_demuxer.cc
+++ b/media/filters/ffmpeg_demuxer.cc
@@ -276,7 +276,8 @@ FFmpegDemuxerStream::FFmpegDemuxerStream(
is_enabled_(true),
waiting_for_keyframe_(false),
aborted_(false),
- fixup_negative_timestamps_(false) {
+ fixup_negative_timestamps_(false),
+ warned_about_missing_timestamps_(false) {
DCHECK(demuxer_);
bool is_encrypted = false;
@@ -527,7 +528,12 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
}
} else {
// If this happens on the first packet, decoders will throw an error.
- buffer->set_timestamp(kNoTimestamp);
+ // Just try zero. crbug.com/665305 .
+ if (!warned_about_missing_timestamps_) {
+ LOG(WARNING) << "No timestamp provided for initial buffer";
+ warned_about_missing_timestamps_ = true;
+ }
+ buffer->set_timestamp(base::TimeDelta());
}
if (last_packet_timestamp_ != kNoTimestamp) {
@@ -544,18 +550,27 @@ void FFmpegDemuxerStream::EnqueuePacket(ScopedAVPacket packet) {
// Fixing chained ogg is non-trivial, so for now just reuse the last good
// timestamp. The decoder will rewrite the timestamps to be sample accurate
// later. See http://crbug.com/396864.
- if (fixup_negative_timestamps_ &&
- (buffer->timestamp() == kNoTimestamp ||
+ //
+ // Whether we're fixing up timestamps or not, if we have no timestamp, then
+ // use the last timestamp instead. This can happen if bad media causes
+ // ffmpeg to fail to provide a timestamp. crbug.com/665305
+ if (buffer->timestamp() == kNoTimestamp ||
+ (fixup_negative_timestamps_ &&
buffer->timestamp() < last_packet_timestamp_)) {
+ if (!fixup_negative_timestamps_ && !warned_about_missing_timestamps_) {
liberato (no reviews please) 2016/12/12 22:24:48 "!fixup..." to prevent a warning when we wouldn't
+ LOG(WARNING) << "No timestamp provided for buffer";
+ warned_about_missing_timestamps_ = true;
+ }
buffer->set_timestamp(last_packet_timestamp_ +
(last_packet_duration_ != kNoTimestamp
? last_packet_duration_
: base::TimeDelta::FromMicroseconds(1)));
}
- // The demuxer should always output positive timestamps.
- DCHECK(buffer->timestamp() >= base::TimeDelta());
+ // The demuxer should always output non-negative timestamps. If it output
+ // no timestamp, then we should have already fixed that up.
DCHECK(buffer->timestamp() != kNoTimestamp);
+ DCHECK(buffer->timestamp() >= base::TimeDelta());
if (last_packet_timestamp_ < buffer->timestamp()) {
buffered_ranges_.Add(last_packet_timestamp_, buffer->timestamp());
« no previous file with comments | « media/filters/ffmpeg_demuxer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698