X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fproducer%2Finput%2Finput.cpp;h=8f62f748e6d1d98a4380d90a65d7c77d8008010e;hb=705cc3c6529b5fd82918d65b693e02919406cd94;hp=d8f5bf0df9480f42022b4783f4a36e79697e853c;hpb=9415fa7899ee71d8f6befb0d5678b923fed44009;p=casparcg diff --git a/modules/ffmpeg/producer/input/input.cpp b/modules/ffmpeg/producer/input/input.cpp index d8f5bf0df..8f62f748e 100644 --- a/modules/ffmpeg/producer/input/input.cpp +++ b/modules/ffmpeg/producer/input/input.cpp @@ -41,6 +41,7 @@ #include #include +#include #include #include #include @@ -349,11 +350,18 @@ struct input::implementation : boost::noncopyable } auto stream = format_context_->streams[default_stream_index_]; - auto codec = stream->codec; - auto fixed_target = (target*stream->time_base.den*codec->time_base.num)/(stream->time_base.num*codec->time_base.den)*codec->ticks_per_frame; - THROW_ON_ERROR2(avformat_seek_file(format_context_.get(), default_stream_index_, std::numeric_limits::min(), fixed_target, std::numeric_limits::max(), 0), print()); + auto fps = read_fps(*format_context_, 0.0); + + THROW_ON_ERROR2(avformat_seek_file( + format_context_.get(), + default_stream_index_, + std::numeric_limits::min(), + static_cast((target / fps * stream->time_base.den) / stream->time_base.num), + std::numeric_limits::max(), + 0), print()); + auto flush_packet = create_packet(); flush_packet->data = nullptr; flush_packet->size = 0;