From 6284495c607f75d43cbb5238f714645967fc1679 Mon Sep 17 00:00:00 2001 From: Dimitry Ishenko Date: Sun, 26 Jun 2016 09:38:24 -0400 Subject: [PATCH] [ffmpeg_producer] Add relative and "from end" seeking --- modules/ffmpeg/producer/ffmpeg_producer.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) 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)) { -- 2.39.2