]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/ffmpeg_producer.cpp
Merge pull request #444 from dimitry-ishenko-casparcg/scrub
[casparcg] / modules / ffmpeg / producer / ffmpeg_producer.cpp
index 5f2b995eba61bd22458c23f0e634ada24cd43016..79b68d9f4ed59127bbf2960416fbefb69e9e3a1f 100644 (file)
@@ -282,12 +282,12 @@ public:
                                           // therefore no seeking should be necessary for the first frame.
                {
                        input_.seek(file_position > 1 ? file_position - 2: file_position).get();
-                       boost::this_thread::sleep(boost::posix_time::milliseconds(40));
+            boost::this_thread::sleep_for(boost::chrono::milliseconds(40));
                }
 
                for (int i = 0; i < NUM_RETRIES; ++i)
                {
-                       boost::this_thread::sleep(boost::posix_time::milliseconds(40));
+            boost::this_thread::sleep_for(boost::chrono::milliseconds(40));
 
                        auto frame = render_frame();
 
@@ -307,7 +307,7 @@ public:
                                {
                                        CASPAR_LOG(trace) << print() << L" adjusting to " << adjusted_seek;
                                        input_.seek(static_cast<uint32_t>(adjusted_seek) - 1).get();
-                                       boost::this_thread::sleep(boost::posix_time::milliseconds(40));
+                    boost::this_thread::sleep_for(boost::chrono::milliseconds(40));
                                }
                                else
                                        return frame.first;
@@ -392,7 +392,7 @@ public:
        std::future<std::wstring> call(const std::vector<std::wstring>& params) override
        {
                static const boost::wregex loop_exp(LR"(LOOP\s*(?<VALUE>\d?)?)", boost::regex::icase);
-               static const boost::wregex seek_exp(LR"(SEEK\s+(?<VALUE>\d+))", boost::regex::icase);
+               static const boost::wregex seek_exp(LR"(SEEK\s+(?<VALUE>(\+|-)?\d+)(\s+(?<WHENCE>REL|END))?)", boost::regex::icase);
                static const boost::wregex length_exp(LR"(LENGTH\s+(?<VALUE>\d+)?)", boost::regex::icase);
                static const boost::wregex start_exp(LR"(START\\s+(?<VALUE>\\d+)?)", boost::regex::icase);
 
@@ -410,8 +410,19 @@ public:
                }
                else if(boost::regex_match(param, what, seek_exp))
                {
-                       auto value = what["VALUE"].str();
-                       input_.seek(boost::lexical_cast<uint32_t>(value));
+                       auto value = boost::lexical_cast<uint32_t>(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))
                {