aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-05-18 20:27:04 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-05-18 21:16:36 +0200
commitb0322e4a9e326f41e0214abb0083fe9eb7407460 (patch)
treef30cf4b13cf43492588b2776694305ac473b0bd3
parentb012bd50685e1b952da20662af8d89f73ecdc49b (diff)
downloadffmpeg-b0322e4a9e326f41e0214abb0083fe9eb7407460.tar.gz
ffmpeg_opt: Compensate for DTS/PTS difference in seeking when its based on DTS
Fixes Ticket4554 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg_opt.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 5731299ddd..a8d433eac1 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -927,7 +927,20 @@ static int open_input_file(OptionsContext *o, const char *filename)
/* if seeking requested, we execute it */
if (o->start_time != AV_NOPTS_VALUE) {
- ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, timestamp, 0);
+ int64_t seek_timestamp = timestamp;
+
+ if (!(ic->iformat->flags & AVFMT_SEEK_TO_PTS)) {
+ int dts_heuristic = 0;
+ for (i=0; i<ic->nb_streams; i++) {
+ AVCodecContext *avctx = ic->streams[i]->codec;
+ if (avctx->has_b_frames)
+ dts_heuristic = 1;
+ }
+ if (dts_heuristic) {
+ seek_timestamp -= 3*AV_TIME_BASE / 23;
+ }
+ }
+ ret = avformat_seek_file(ic, -1, INT64_MIN, seek_timestamp, seek_timestamp, 0);
if (ret < 0) {
av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3f\n",
filename, (double)timestamp / AV_TIME_BASE);