]> git.sesse.net Git - casparcg/blob - modules/ffmpeg/producer/ffmpeg_producer.cpp
Changed copyright header in all files, and added it in some files where it was missing.
[casparcg] / modules / ffmpeg / producer / ffmpeg_producer.cpp
1 /*\r
2 * Copyright 2013 Sveriges Television AB http://casparcg.com/\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\r
5 *\r
6 * CasparCG is free software: you can redistribute it and/or modify\r
7 * it under the terms of the GNU General Public License as published by\r
8 * the Free Software Foundation, either version 3 of the License, or\r
9 * (at your option) any later version.\r
10 *\r
11 * CasparCG is distributed in the hope that it will be useful,\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 * GNU General Public License for more details.\r
15 *\r
16 * You should have received a copy of the GNU General Public License\r
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #include "../stdafx.h"\r
23 \r
24 #include "ffmpeg_producer.h"\r
25 \r
26 #include "../ffmpeg_error.h"\r
27 #include "../ffmpeg.h"\r
28 #include "ffmpeg_params.h"\r
29 \r
30 #include "muxer/frame_muxer.h"\r
31 #include "input/input.h"\r
32 #include "util/util.h"\r
33 #include "audio/audio_decoder.h"\r
34 #include "video/video_decoder.h"\r
35 \r
36 #include <common/env.h>\r
37 #include <common/utility/assert.h>\r
38 #include <common/utility/param.h>\r
39 #include <common/diagnostics/graph.h>\r
40 \r
41 #include <core/monitor/monitor.h>\r
42 #include <core/video_format.h>\r
43 #include <core/producer/frame_producer.h>\r
44 #include <core/producer/frame/frame_factory.h>\r
45 #include <core/producer/frame/basic_frame.h>\r
46 #include <core/producer/frame/frame_transform.h>\r
47 \r
48 #include <boost/algorithm/string.hpp>\r
49 #include <boost/assign.hpp>\r
50 #include <boost/timer.hpp>\r
51 #include <boost/foreach.hpp>\r
52 #include <boost/filesystem.hpp>\r
53 #include <boost/range/algorithm/find_if.hpp>\r
54 #include <boost/range/algorithm/find.hpp>\r
55 #include <boost/regex.hpp>\r
56 \r
57 #include <tbb/parallel_invoke.h>\r
58 \r
59 #include <limits>\r
60 #include <memory>\r
61 #include <queue>\r
62 \r
63 namespace caspar { namespace ffmpeg {\r
64 \r
65                                 \r
66 struct ffmpeg_producer : public core::frame_producer\r
67 {\r
68         core::monitor::subject                                                                          monitor_subject_;\r
69         const std::wstring                                                                                      filename_;\r
70 \r
71         FFMPEG_Resource                                                                                         resource_type_;\r
72         \r
73         const safe_ptr<diagnostics::graph>                                                      graph_;\r
74         boost::timer                                                                                            frame_timer_;\r
75                                         \r
76         const safe_ptr<core::frame_factory>                                                     frame_factory_;\r
77         const core::video_format_desc                                                           format_desc_;\r
78 \r
79         std::shared_ptr<void>                                                                           initial_logger_disabler_;\r
80 \r
81         input                                                                                                           input_; \r
82         std::unique_ptr<video_decoder>                                                          video_decoder_;\r
83         std::unique_ptr<audio_decoder>                                                          audio_decoder_; \r
84         std::unique_ptr<frame_muxer>                                                            muxer_;\r
85 \r
86         const double                                                                                            fps_;\r
87         const uint32_t                                                                                          start_;\r
88         const uint32_t                                                                                          length_;\r
89         const bool                                                                                                      thumbnail_mode_;\r
90 \r
91         safe_ptr<core::basic_frame>                                                                     last_frame_;\r
92         \r
93         std::queue<std::pair<safe_ptr<core::basic_frame>, size_t>>      frame_buffer_;\r
94 \r
95         int64_t                                                                                                         frame_number_;\r
96         uint32_t                                                                                                        file_frame_number_;\r
97                 \r
98 public:\r
99         explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, FFMPEG_Resource resource_type, const std::wstring& filter, bool loop, uint32_t start, uint32_t length, bool thumbnail_mode, const std::wstring& custom_channel_order, const ffmpeg_params& vid_params)\r
100                 : filename_(filename)\r
101                 , resource_type_(resource_type)\r
102                 , frame_factory_(frame_factory)         \r
103                 , format_desc_(frame_factory->get_video_format_desc())\r
104                 , initial_logger_disabler_(temporary_disable_logging_for_thread(thumbnail_mode))\r
105                 , input_(graph_, filename_, resource_type, loop, start, length, thumbnail_mode, vid_params)\r
106                 , fps_(read_fps(*input_.context(), format_desc_.fps))\r
107                 , start_(start)\r
108                 , length_(length)\r
109                 , thumbnail_mode_(thumbnail_mode)\r
110                 , last_frame_(core::basic_frame::empty())\r
111                 , frame_number_(0)\r
112         {\r
113                 graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));\r
114                 graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));   \r
115                 diagnostics::register_graph(graph_);\r
116         \r
117                 try\r
118                 {\r
119                         video_decoder_.reset(new video_decoder(input_.context()));\r
120                         if (!thumbnail_mode_)\r
121                                 CASPAR_LOG(info) << print() << L" " << video_decoder_->print();\r
122                 }\r
123                 catch(averror_stream_not_found&)\r
124                 {\r
125                         //CASPAR_LOG(warning) << print() << " No video-stream found. Running without video.";   \r
126                 }\r
127                 catch(...)\r
128                 {\r
129                         if (!thumbnail_mode_)\r
130                         {\r
131                                 CASPAR_LOG_CURRENT_EXCEPTION();\r
132                                 CASPAR_LOG(warning) << print() << "Failed to open video-stream. Running without video.";        \r
133                         }\r
134                 }\r
135 \r
136                 core::channel_layout audio_channel_layout = core::default_channel_layout_repository().get_by_name(L"STEREO");\r
137 \r
138                 if (!thumbnail_mode_)\r
139                 {\r
140                         try\r
141                         {\r
142                                 audio_decoder_.reset(new audio_decoder(input_.context(), frame_factory->get_video_format_desc(), custom_channel_order));\r
143                                 audio_channel_layout = audio_decoder_->channel_layout();\r
144                                 CASPAR_LOG(info) << print() << L" " << audio_decoder_->print();\r
145                         }\r
146                         catch(averror_stream_not_found&)\r
147                         {\r
148                                 //CASPAR_LOG(warning) << print() << " No audio-stream found. Running without audio.";   \r
149                         }\r
150                         catch(...)\r
151                         {\r
152                                 CASPAR_LOG_CURRENT_EXCEPTION();\r
153                                 CASPAR_LOG(warning) << print() << " Failed to open audio-stream. Running without audio.";               \r
154                         }\r
155                 }\r
156 \r
157                 if(!video_decoder_ && !audio_decoder_)\r
158                         BOOST_THROW_EXCEPTION(averror_stream_not_found() << msg_info("No streams found"));\r
159 \r
160                 muxer_.reset(new frame_muxer(fps_, frame_factory, thumbnail_mode_, audio_channel_layout, filter));\r
161         }\r
162 \r
163         // frame_producer\r
164         \r
165         virtual safe_ptr<core::basic_frame> receive(int hints) override\r
166         {\r
167                 return render_frame(hints).first;\r
168         }\r
169 \r
170         virtual safe_ptr<core::basic_frame> last_frame() const override\r
171         {\r
172                 return disable_audio(last_frame_);\r
173         }\r
174 \r
175         std::pair<safe_ptr<core::basic_frame>, uint32_t> render_frame(int hints)\r
176         {               \r
177                 frame_timer_.restart();\r
178                 auto disable_logging = temporary_disable_logging_for_thread(thumbnail_mode_);\r
179                                 \r
180                 for(int n = 0; n < 16 && frame_buffer_.size() < 2; ++n)\r
181                         try_decode_frame(hints);\r
182                 \r
183                 graph_->set_value("frame-time", frame_timer_.elapsed()*format_desc_.fps*0.5);\r
184 \r
185                 if(frame_buffer_.empty())\r
186                 {\r
187                         if (input_.eof())\r
188                         {\r
189                                 return std::make_pair(last_frame(), -1);\r
190                         } else if (resource_type_ == FFMPEG_FILE)\r
191                         {\r
192                                 graph_->set_tag("underflow");  \r
193                                 return std::make_pair(core::basic_frame::late(), -1);     \r
194                         } else\r
195                         {\r
196                                 return std::make_pair(last_frame(), -1);\r
197                         }\r
198                 }\r
199                 \r
200                 auto frame = frame_buffer_.front(); \r
201                 frame_buffer_.pop();\r
202                 \r
203                 ++frame_number_;\r
204                 file_frame_number_ = frame.second;\r
205 \r
206                 graph_->set_text(print());\r
207 \r
208                 last_frame_ = frame.first;\r
209                                         \r
210                 monitor_subject_        << core::monitor::message("/profiler/time")             % frame_timer_.elapsed() % (1.0/format_desc_.fps);                      \r
211                                                                 \r
212                 monitor_subject_        << core::monitor::message("/file/time")                 % (file_frame_number()/fps_) \r
213                                                                                                                                                         % (file_nb_frames()/fps_)\r
214                                                         << core::monitor::message("/file/frame")                        % static_cast<int32_t>(file_frame_number())\r
215                                                                                                                                                         % static_cast<int32_t>(file_nb_frames())\r
216                                                         << core::monitor::message("/file/fps")                  % fps_\r
217                                                         << core::monitor::message("/file/path")                 % filename_\r
218                                                         << core::monitor::message("/loop")                              % input_.loop();\r
219 \r
220                 return frame;\r
221         }\r
222         \r
223         safe_ptr<core::basic_frame> render_specific_frame(uint32_t file_position, int hints)\r
224         {\r
225                 // Some trial and error and undeterministic stuff here\r
226                 static const int NUM_RETRIES = 32;\r
227                 \r
228                 if (file_position > 0) // Assume frames are requested in sequential order,\r
229                                            // therefore no seeking should be necessary for the first frame.\r
230                 {\r
231                         input_.seek(file_position > 1 ? file_position - 2: file_position).get();\r
232                         boost::this_thread::sleep(boost::posix_time::milliseconds(40));\r
233                 }\r
234 \r
235                 for (int i = 0; i < NUM_RETRIES; ++i)\r
236                 {\r
237                         boost::this_thread::sleep(boost::posix_time::milliseconds(40));\r
238                 \r
239                         auto frame = render_frame(hints);\r
240 \r
241                         if (frame.second == std::numeric_limits<uint32_t>::max())\r
242                         {\r
243                                 // Retry\r
244                                 continue;\r
245                         }\r
246                         else if (frame.second == file_position + 1 || frame.second == file_position)\r
247                                 return frame.first;\r
248                         else if (frame.second > file_position + 1)\r
249                         {\r
250                                 CASPAR_LOG(trace) << print() << L" " << frame.second << L" received, wanted " << file_position + 1;\r
251                                 int64_t adjusted_seek = file_position - (frame.second - file_position + 1);\r
252 \r
253                                 if (adjusted_seek > 1 && file_position > 0)\r
254                                 {\r
255                                         CASPAR_LOG(trace) << print() << L" adjusting to " << adjusted_seek;\r
256                                         input_.seek(static_cast<uint32_t>(adjusted_seek) - 1).get();\r
257                                         boost::this_thread::sleep(boost::posix_time::milliseconds(40));\r
258                                 }\r
259                                 else\r
260                                         return frame.first;\r
261                         }\r
262                 }\r
263 \r
264                 CASPAR_LOG(trace) << print() << " Giving up finding frame at " << file_position;\r
265                 return core::basic_frame::empty();\r
266         }\r
267 \r
268         virtual safe_ptr<core::basic_frame> create_thumbnail_frame() override\r
269         {\r
270                 auto disable_logging = temporary_disable_logging_for_thread(thumbnail_mode_);\r
271                 auto total_frames = nb_frames();\r
272                 auto grid = env::properties().get(L"configuration.thumbnails.video-grid", 2);\r
273 \r
274                 if (grid < 1)\r
275                 {\r
276                         CASPAR_LOG(error) << L"configuration/thumbnails/video-grid cannot be less than 1";\r
277                         BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("configuration/thumbnails/video-grid cannot be less than 1"));\r
278                 }\r
279 \r
280                 if (grid == 1)\r
281                 {\r
282                         return render_specific_frame(total_frames / 2, 0/*DEINTERLACE_HINT*/);\r
283                 }\r
284 \r
285                 auto num_snapshots = grid * grid;\r
286 \r
287                 std::vector<safe_ptr<core::basic_frame>> frames;\r
288 \r
289                 for (int i = 0; i < num_snapshots; ++i)\r
290                 {\r
291                         int x = i % grid;\r
292                         int y = i / grid;\r
293                         int desired_frame;\r
294                         \r
295                         if (i == 0)\r
296                                 desired_frame = 0; // first\r
297                         else if (i == num_snapshots - 1)\r
298                                 desired_frame = total_frames - 1; // last\r
299                         else\r
300                                 // evenly distributed across the file.\r
301                                 desired_frame = total_frames * i / (num_snapshots - 1);\r
302 \r
303                         auto frame = render_specific_frame(desired_frame, 0/*DEINTERLACE_HINT*/);\r
304                         frame->get_frame_transform().fill_scale[0] = 1.0 / static_cast<double>(grid);\r
305                         frame->get_frame_transform().fill_scale[1] = 1.0 / static_cast<double>(grid);\r
306                         frame->get_frame_transform().fill_translation[0] = 1.0 / static_cast<double>(grid) * x;\r
307                         frame->get_frame_transform().fill_translation[1] = 1.0 / static_cast<double>(grid) * y;\r
308 \r
309                         frames.push_back(frame);\r
310                 }\r
311 \r
312                 return make_safe<core::basic_frame>(frames);\r
313         }\r
314         \r
315         uint32_t file_frame_number() const\r
316         {\r
317                 return video_decoder_ ? video_decoder_->file_frame_number() : 0;\r
318         }\r
319 \r
320         virtual uint32_t nb_frames() const override\r
321         {\r
322                 //if(input_.loop())\r
323                 if(resource_type_ == FFMPEG_DEVICE || resource_type_ == FFMPEG_STREAM || input_.loop()) \r
324                         return std::numeric_limits<uint32_t>::max();\r
325 \r
326                 uint32_t nb_frames = file_nb_frames();\r
327 \r
328                 nb_frames = std::min(length_, nb_frames);\r
329                 nb_frames = muxer_->calc_nb_frames(nb_frames);\r
330                 \r
331                 return nb_frames > start_ ? nb_frames - start_ : 0;\r
332         }\r
333 \r
334         uint32_t file_nb_frames() const\r
335         {\r
336                 uint32_t file_nb_frames = 0;\r
337                 file_nb_frames = std::max(file_nb_frames, video_decoder_ ? video_decoder_->nb_frames() : 0);\r
338                 file_nb_frames = std::max(file_nb_frames, audio_decoder_ ? audio_decoder_->nb_frames() : 0);\r
339                 return file_nb_frames;\r
340         }\r
341         \r
342         virtual boost::unique_future<std::wstring> call(const std::wstring& param) override\r
343         {\r
344                 boost::promise<std::wstring> promise;\r
345                 promise.set_value(do_call(param));\r
346                 return promise.get_future();\r
347         }\r
348                                 \r
349         virtual std::wstring print() const override\r
350         {\r
351                 return L"ffmpeg[" + boost::filesystem::wpath(filename_).filename() + L"|" \r
352                                                   + print_mode() + L"|" \r
353                                                   + boost::lexical_cast<std::wstring>(file_frame_number_) + L"/" + boost::lexical_cast<std::wstring>(file_nb_frames()) + L"]";\r
354         }\r
355 \r
356         boost::property_tree::wptree info() const override\r
357         {\r
358                 boost::property_tree::wptree info;\r
359                 info.add(L"type",                               L"ffmpeg-producer");\r
360                 info.add(L"filename",                   filename_);\r
361                 info.add(L"width",                              video_decoder_ ? video_decoder_->width() : 0);\r
362                 info.add(L"height",                             video_decoder_ ? video_decoder_->height() : 0);\r
363                 info.add(L"progressive",                video_decoder_ ? video_decoder_->is_progressive() : false);\r
364                 info.add(L"fps",                                fps_);\r
365                 info.add(L"loop",                               input_.loop());\r
366                 info.add(L"frame-number",               frame_number_);\r
367                 auto nb_frames2 = nb_frames();\r
368                 info.add(L"nb-frames",                  nb_frames2 == std::numeric_limits<int64_t>::max() ? -1 : nb_frames2);\r
369                 info.add(L"file-frame-number",  file_frame_number_);\r
370                 info.add(L"file-nb-frames",             file_nb_frames());\r
371                 return info;\r
372         }\r
373 \r
374         // ffmpeg_producer\r
375 \r
376         std::wstring print_mode() const\r
377         {\r
378                 return video_decoder_ ? ffmpeg::print_mode(video_decoder_->width(), video_decoder_->height(), fps_, !video_decoder_->is_progressive()) : L"";\r
379         }\r
380                                         \r
381         std::wstring do_call(const std::wstring& param)\r
382         {\r
383                 static const boost::wregex loop_exp(L"LOOP\\s*(?<VALUE>\\d?)?", boost::regex::icase);\r
384                 static const boost::wregex seek_exp(L"SEEK\\s+(?<VALUE>\\d+)", boost::regex::icase);\r
385                 \r
386                 boost::wsmatch what;\r
387                 if(boost::regex_match(param, what, loop_exp))\r
388                 {\r
389                         if(!what["VALUE"].str().empty())\r
390                                 input_.loop(boost::lexical_cast<bool>(what["VALUE"].str()));\r
391                         return boost::lexical_cast<std::wstring>(input_.loop());\r
392                 }\r
393                 if(boost::regex_match(param, what, seek_exp))\r
394                 {\r
395                         input_.seek(boost::lexical_cast<uint32_t>(what["VALUE"].str()));\r
396                         return L"";\r
397                 }\r
398 \r
399                 BOOST_THROW_EXCEPTION(invalid_argument());\r
400         }\r
401 \r
402         void try_decode_frame(int hints)\r
403         {\r
404                 std::shared_ptr<AVPacket> pkt;\r
405 \r
406                 for(int n = 0; n < 32 && ((video_decoder_ && !video_decoder_->ready()) || (audio_decoder_ && !audio_decoder_->ready())) && input_.try_pop(pkt); ++n)\r
407                 {\r
408                         if(video_decoder_)\r
409                                 video_decoder_->push(pkt);\r
410                         if(audio_decoder_)\r
411                                 audio_decoder_->push(pkt);\r
412                 }\r
413                 \r
414                 std::shared_ptr<AVFrame>                        video;\r
415                 std::shared_ptr<core::audio_buffer> audio;\r
416 \r
417                 tbb::parallel_invoke(\r
418                 [&]\r
419                 {\r
420                         if(!muxer_->video_ready() && video_decoder_)    \r
421                                 video = video_decoder_->poll(); \r
422                 },\r
423                 [&]\r
424                 {               \r
425                         if(!muxer_->audio_ready() && audio_decoder_)            \r
426                                 audio = audio_decoder_->poll();         \r
427                 });\r
428                 \r
429                 muxer_->push(video, hints);\r
430                 muxer_->push(audio);\r
431 \r
432                 if(!audio_decoder_)\r
433                 {\r
434                         if(video == flush_video())\r
435                                 muxer_->push(flush_audio());\r
436                         else if(!muxer_->audio_ready())\r
437                                 muxer_->push(empty_audio());\r
438                 }\r
439 \r
440                 if(!video_decoder_)\r
441                 {\r
442                         if(audio == flush_audio())\r
443                                 muxer_->push(flush_video(), 0);\r
444                         else if(!muxer_->video_ready())\r
445                                 muxer_->push(empty_video(), 0);\r
446                 }\r
447                 \r
448                 size_t file_frame_number = 0;\r
449                 file_frame_number = std::max(file_frame_number, video_decoder_ ? video_decoder_->file_frame_number() : 0);\r
450                 //file_frame_number = std::max(file_frame_number, audio_decoder_ ? audio_decoder_->file_frame_number() : 0);\r
451 \r
452                 for(auto frame = muxer_->poll(); frame; frame = muxer_->poll())\r
453                         frame_buffer_.push(std::make_pair(make_safe_ptr(frame), file_frame_number));\r
454         }\r
455 \r
456         core::monitor::source& monitor_output()\r
457         {\r
458                 return monitor_subject_;\r
459         }\r
460 };\r
461 \r
462 safe_ptr<core::frame_producer> create_producer(\r
463                 const safe_ptr<core::frame_factory>& frame_factory,\r
464                 const std::vector<std::wstring>& params,\r
465                 const std::vector<std::wstring>& original_case_params)\r
466 {               \r
467         static const std::vector<std::wstring> invalid_exts = boost::assign::list_of(L".png")(L".tga")(L".bmp")(L".jpg")(L".jpeg")(L".gif")(L".tiff")(L".tif")(L".jp2")(L".jpx")(L".j2k")(L".j2c")(L".swf")(L".ct");\r
468 \r
469         // Infer the resource type from the resource_name\r
470         auto resource_type = FFMPEG_FILE;\r
471         auto tokens = caspar::core::protocol_split(original_case_params[0]);\r
472         auto filename = params[0];\r
473         if (!tokens[0].empty())\r
474         {\r
475                 if (tokens[0] == L"dshow")\r
476                 {\r
477                         // Camera\r
478                         resource_type = FFMPEG_DEVICE;\r
479                         filename = tokens[1];\r
480                 } else\r
481                 {\r
482                         // Stream\r
483                         resource_type = FFMPEG_STREAM;\r
484                         filename = original_case_params[0];\r
485                 }\r
486         } else\r
487         {\r
488                 // File\r
489                 resource_type = FFMPEG_FILE;\r
490                 filename = env::media_folder() + L"\\" + tokens[1];\r
491                 if(!boost::filesystem::exists(filename))\r
492                         filename = probe_stem(filename);\r
493 \r
494                 //TODO fix these?\r
495                 //ffmpeg_params->loop       = params.has(L"LOOP");\r
496                 //ffmpeg_params->start     = params.get(L"SEEK", static_cast<uint32_t>(0));\r
497         }\r
498 \r
499         if(filename.empty())\r
500                 return core::frame_producer::empty();\r
501         \r
502         auto loop                                       = boost::range::find(params, L"LOOP") != params.end();\r
503         auto start                                      = get_param(L"SEEK", params, static_cast<uint32_t>(0));\r
504         auto length                                     = get_param(L"LENGTH", params, std::numeric_limits<uint32_t>::max());\r
505         auto filter_str                         = get_param(L"FILTER", params, L"");    \r
506         auto custom_channel_order       = get_param(L"CHANNEL_LAYOUT", params, L"");\r
507 \r
508         boost::replace_all(filter_str, L"DEINTERLACE", L"YADIF=0:-1");\r
509         boost::replace_all(filter_str, L"DEINTERLACE_BOB", L"YADIF=1:-1");\r
510 \r
511         ffmpeg_params vid_params;\r
512         vid_params.size_str = get_param(L"SIZE", params, L"");\r
513         vid_params.pixel_format = get_param(L"PIXFMT", params, L"");\r
514         vid_params.frame_rate = get_param(L"FRAMERATE", params, L"");\r
515         \r
516         return create_producer_destroy_proxy(make_safe<ffmpeg_producer>(frame_factory, filename, resource_type, filter_str, loop, start, length, false, custom_channel_order, vid_params));\r
517 }\r
518 \r
519 safe_ptr<core::frame_producer> create_thumbnail_producer(\r
520                 const safe_ptr<core::frame_factory>& frame_factory,\r
521                 const std::vector<std::wstring>& params,\r
522                 const std::vector<std::wstring>& original_case_params)\r
523 {               \r
524         static const std::vector<std::wstring> invalid_exts = boost::assign::list_of\r
525                         (L".png")(L".tga")(L".bmp")(L".jpg")(L".jpeg")(L".gif")(L".tiff")(L".tif")(L".jp2")(L".jpx")(L".j2k")(L".j2c")(L".swf")(L".ct")\r
526                         (L".wav")(L".mp3"); // audio shall not have thumbnails\r
527         auto filename = probe_stem(env::media_folder() + L"\\" + params.at(0), invalid_exts);\r
528 \r
529         if(filename.empty())\r
530                 return core::frame_producer::empty();\r
531         \r
532         auto loop               = false;\r
533         auto start              = 0;\r
534         auto length             = std::numeric_limits<uint32_t>::max();\r
535         auto filter_str = L"";\r
536                 \r
537         ffmpeg_params vid_params;\r
538 \r
539         return create_producer_destroy_proxy(make_safe<ffmpeg_producer>(frame_factory, filename, FFMPEG_FILE, filter_str, loop, start, length, true, L"", vid_params));\r
540 }\r
541 \r
542 }}