Skip to content

Commit

Permalink
Workaround for negative PTS values in video files.
Browse files Browse the repository at this point in the history
In some videos uploaded from cameras, the first frame in presentation order
is not the first frame in decode order. The metadata correctly records this.
However, FFmpeg is adjusting timestamps so that the first frame in decode
order is at time 0. As a result, the first frame in presentation order has
a negative timestamp, which produces an error.

The workaround is to pass "advanced_editlist=0" in the demuxer options.
This avoids the problem until FFmpeg fixes it properly.

BUG=723537
TEST=tested locally with example from comment #6 in the bug

(cherry picked from commit 916a829)
TBR=jrummell@chromium.org

Change-Id: I2b515dff06da2930339592ff4e84ec69da635c91
Reviewed-on: https://chromium-review.googlesource.com/526752
Commit-Queue: John Rummell <jrummell@chromium.org>
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#477887}
Reviewed-on: https://chromium-review.googlesource.com/546916
Reviewed-by: Chrome Cunningham <chcunningham@chromium.org>
Cr-Commit-Position: refs/branch-heads/3112@{#457}
Cr-Branched-From: b6460e2-refs/heads/master@{#474897}
  • Loading branch information
chcunningham committed Jun 23, 2017
1 parent 2e98fb8 commit 0b47983
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion media/filters/ffmpeg_glue.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,17 @@ bool FFmpegGlue::OpenContext() {
// destruction path to avoid double frees.
open_called_ = true;

// Pass "advanced_editlist=0" in the demuxer options.
// TODO(jrummell): Remove this when we support post-decode discard.
// https://crbug.com/723537.
AVDictionary* dict = nullptr;
av_dict_set(&dict, "advanced_editlist", "0", 0);

// By passing nullptr for the filename (second parameter) we are telling
// FFmpeg to use the AVIO context we setup from the AVFormatContext structure.
const int ret =
avformat_open_input(&format_context_, nullptr, nullptr, nullptr);
avformat_open_input(&format_context_, nullptr, nullptr, &dict);
av_dict_free(&dict);

// If FFmpeg can't identify the file, read the first 8k and attempt to guess
// at the container type ourselves. This way we can track emergent formats.
Expand Down

0 comments on commit 0b47983

Please sign in to comment.