From: HellGore Date: Thu, 3 Nov 2016 12:27:56 +0000 (+0100) Subject: Merge pull request #493 from dimitry-ishenko-casparcg/2.1.0 X-Git-Tag: 2.1.0_Beta1~21 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=e0d776a4c336e3d3f9d32a9bf24c1bc522966eeb;hp=181d938c6b2c4fd014bc420960e51d38c399b1e4;p=casparcg Merge pull request #493 from dimitry-ishenko-casparcg/2.1.0 [ffmpeg_producer] Constrain SEEK values --- diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index 48facf644..fe0492ade 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -441,19 +441,21 @@ public: } else if(boost::regex_match(param, what, seek_exp)) { - auto value = boost::lexical_cast(what["VALUE"].str()); + auto value = boost::lexical_cast(what["VALUE"].str()); auto whence = what["WHENCE"].str(); + auto total = file_nb_frames(); if(boost::iequals(whence, L"REL")) - { value = file_frame_number() + value; - } else if(boost::iequals(whence, L"END")) - { - value = file_nb_frames() - value; - } + value = total - value; + + if(value < 0) + value = 0; + else if(value >= total) + value = total - 1; - input_.seek(value); + input_.seek(static_cast(value)); } else if(boost::regex_match(param, what, length_exp)) {