From: Dimitry Ishenko Date: Sun, 26 Jun 2016 13:38:24 +0000 (-0400) Subject: [ffmpeg_producer] Add relative and "from end" seeking X-Git-Tag: 2.1.0_Beta1~40^2 X-Git-Url: https://git.sesse.net/?p=casparcg;a=commitdiff_plain;h=6284495c607f75d43cbb5238f714645967fc1679 [ffmpeg_producer] Add relative and "from end" seeking --- diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index a77994896..634e4dd62 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -391,7 +391,7 @@ public: std::future call(const std::vector& params) override { static const boost::wregex loop_exp(LR"(LOOP\s*(?\d?)?)", boost::regex::icase); - static const boost::wregex seek_exp(LR"(SEEK\s+(?\d+))", boost::regex::icase); + static const boost::wregex seek_exp(LR"(SEEK\s+(?(\+|-)?\d+)(\s+(?REL|END))?)", boost::regex::icase); static const boost::wregex length_exp(LR"(LENGTH\s+(?\d+)?)", boost::regex::icase); static const boost::wregex start_exp(LR"(START\\s+(?\\d+)?)", boost::regex::icase); @@ -409,8 +409,19 @@ public: } else if(boost::regex_match(param, what, seek_exp)) { - auto value = what["VALUE"].str(); - input_.seek(boost::lexical_cast(value)); + auto value = boost::lexical_cast(what["VALUE"].str()); + auto whence = what["WHENCE"].str(); + + if(boost::iequals(whence, L"REL")) + { + value = file_frame_number() + value; + } + else if(boost::iequals(whence, L"END")) + { + value = file_nb_frames() - value; + } + + input_.seek(value); } else if(boost::regex_match(param, what, length_exp)) {