2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
\r
4 * This file is part of CasparCG (www.casparcg.com).
\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
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
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
19 * Author: Robert Nagy, ronag89@gmail.com
\r
22 #include "../StdAfx.h"
\r
24 #include "../ffmpeg_error.h"
\r
26 #include "ffmpeg_consumer.h"
\r
28 #include "../producer/tbb_avcodec.h"
\r
30 #include <core/frame/frame.h>
\r
31 #include <core/mixer/audio/audio_util.h>
\r
32 #include <core/consumer/frame_consumer.h>
\r
33 #include <core/video_format.h>
\r
35 #include <common/env.h>
\r
36 #include <common/utf.h>
\r
37 #include <common/param.h>
\r
38 #include <common/executor.h>
\r
39 #include <common/diagnostics/graph.h>
\r
40 #include <common/array.h>
\r
41 #include <common/memory.h>
\r
43 #include <boost/algorithm/string.hpp>
\r
44 #include <boost/timer.hpp>
\r
45 #include <boost/property_tree/ptree.hpp>
\r
46 #include <boost/filesystem.hpp>
\r
47 #include <boost/range/algorithm.hpp>
\r
48 #include <boost/range/algorithm_ext.hpp>
\r
49 #include <boost/lexical_cast.hpp>
\r
51 #if defined(_MSC_VER)
\r
52 #pragma warning (push)
\r
53 #pragma warning (disable : 4244)
\r
57 #define __STDC_CONSTANT_MACROS
\r
58 #define __STDC_LIMIT_MACROS
\r
59 #include <libavformat/avformat.h>
\r
60 #include <libswscale/swscale.h>
\r
61 #include <libavutil/opt.h>
\r
62 #include <libavutil/pixdesc.h>
\r
63 #include <libavutil/parseutils.h>
\r
64 #include <libavutil/samplefmt.h>
\r
65 #include <libswresample/swresample.h>
\r
67 #if defined(_MSC_VER)
\r
68 #pragma warning (pop)
\r
71 namespace caspar { namespace ffmpeg {
\r
73 int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
\r
75 AVClass* av_class = *(AVClass**)obj;
\r
77 if((strcmp(name, "pix_fmt") == 0 || strcmp(name, "pixel_format") == 0) && strcmp(av_class->class_name, "AVCodecContext") == 0)
\r
79 AVCodecContext* c = (AVCodecContext*)obj;
\r
80 auto pix_fmt = av_get_pix_fmt(val);
\r
81 if(pix_fmt == PIX_FMT_NONE)
\r
83 c->pix_fmt = pix_fmt;
\r
86 //if((strcmp(name, "r") == 0 || strcmp(name, "frame_rate") == 0) && strcmp(av_class->class_name, "AVCodecContext") == 0)
\r
88 // AVCodecContext* c = (AVCodecContext*)obj;
\r
90 // if(c->codec_type != AVMEDIA_TYPE_VIDEO)
\r
94 // int ret = av_parse_video_rate(&rate, val);
\r
98 // c->time_base.num = rate.den;
\r
99 // c->time_base.den = rate.num;
\r
103 return ::av_opt_set(obj, name, val, search_flags);
\r
111 option(std::string name, std::string value)
\r
112 : name(std::move(name))
\r
113 , value(std::move(value))
\r
118 struct output_format
\r
120 AVOutputFormat* format;
\r
128 output_format(const core::video_format_desc& format_desc, const std::string& filename, std::vector<option>& options)
\r
129 : format(av_guess_format(nullptr, filename.c_str(), nullptr))
\r
130 , width(format_desc.width)
\r
131 , height(format_desc.height)
\r
132 , vcodec(CODEC_ID_NONE)
\r
133 , acodec(CODEC_ID_NONE)
\r
137 boost::range::remove_erase_if(options, [&](const option& o)
\r
139 return set_opt(o.name, o.value);
\r
142 if(vcodec == CODEC_ID_NONE)
\r
143 vcodec = format->video_codec;
\r
145 if(acodec == CODEC_ID_NONE)
\r
146 acodec = format->audio_codec;
\r
148 if(vcodec == CODEC_ID_NONE)
\r
149 vcodec = CODEC_ID_H264;
\r
151 if(acodec == CODEC_ID_NONE)
\r
152 acodec = CODEC_ID_PCM_S16LE;
\r
155 bool set_opt(const std::string& name, const std::string& value)
\r
157 //if(name == "target")
\r
159 // enum { PAL, NTSC, FILM, UNKNOWN } norm = UNKNOWN;
\r
161 // if(name.find("pal-") != std::string::npos)
\r
163 // else if(name.find("ntsc-") != std::string::npos)
\r
166 // if(norm == UNKNOWN)
\r
167 // BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("target"));
\r
169 // if (name.find("-dv") != std::string::npos)
\r
171 // set_opt("f", "dv");
\r
172 // set_opt("s", norm == PAL ? "720x576" : "720x480");
\r
173 // //set_opt("pix_fmt", name.find("-dv50") != std::string::npos ? "yuv422p" : norm == PAL ? "yuv420p" : "yuv411p");
\r
174 // //set_opt("ar", "48000");
\r
175 // //set_opt("ac", "2");
\r
180 format = av_guess_format(value.c_str(), nullptr, nullptr);
\r
182 if(format == nullptr)
\r
183 BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("f"));
\r
187 else if(name == "vcodec")
\r
189 auto c = avcodec_find_encoder_by_name(value.c_str());
\r
191 BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("vcodec"));
\r
193 vcodec = avcodec_find_encoder_by_name(value.c_str())->id;
\r
197 else if(name == "acodec")
\r
199 auto c = avcodec_find_encoder_by_name(value.c_str());
\r
201 BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("acodec"));
\r
203 acodec = avcodec_find_encoder_by_name(value.c_str())->id;
\r
207 else if(name == "s")
\r
209 if(av_parse_video_size(&width, &height, value.c_str()) < 0)
\r
210 BOOST_THROW_EXCEPTION(invalid_argument() << arg_name_info("s"));
\r
214 else if(name == "croptop")
\r
216 croptop = boost::lexical_cast<int>(value);
\r
220 else if(name == "cropbot")
\r
222 cropbot = boost::lexical_cast<int>(value);
\r
231 typedef std::vector<uint8_t, tbb::cache_aligned_allocator<uint8_t>> byte_vector;
\r
233 struct ffmpeg_consumer : boost::noncopyable
\r
235 const std::string filename_;
\r
237 const std::shared_ptr<AVFormatContext> oc_;
\r
238 const core::video_format_desc format_desc_;
\r
240 const spl::shared_ptr<diagnostics::graph> graph_;
\r
243 std::shared_ptr<AVStream> audio_st_;
\r
244 std::shared_ptr<AVStream> video_st_;
\r
246 byte_vector picture_buffer_;
\r
247 byte_vector audio_buffer_;
\r
248 std::shared_ptr<SwrContext> swr_;
\r
249 std::shared_ptr<SwsContext> sws_;
\r
251 int64_t frame_number_;
\r
253 output_format output_format_;
\r
255 executor executor_;
\r
257 ffmpeg_consumer(const std::string& filename, const core::video_format_desc& format_desc, std::vector<option> options)
\r
258 : filename_(filename)
\r
259 , oc_(avformat_alloc_context(), av_free)
\r
260 , format_desc_(format_desc)
\r
262 , output_format_(format_desc, filename, options)
\r
263 , executor_(print())
\r
265 // TODO: Ask stakeholders about case where file already exists.
\r
266 boost::filesystem::remove(boost::filesystem::path(env::media_folder() + u16(filename))); // Delete the file if it exists
\r
268 graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));
\r
269 graph_->set_text(print());
\r
270 diagnostics::register_graph(graph_);
\r
272 executor_.set_capacity(8);
\r
274 oc_->oformat = output_format_.format;
\r
276 strcpy_s(oc_->filename, filename_.c_str());
\r
278 // Add the audio and video streams using the default format codecs and initialize the codecs.
\r
279 video_st_ = add_video_stream(options);
\r
280 audio_st_ = add_audio_stream(options);
\r
282 av_dump_format(oc_.get(), 0, filename_.c_str(), 1);
\r
284 // Open the output ffmpeg, if needed.
\r
285 if (!(oc_->oformat->flags & AVFMT_NOFILE))
\r
286 THROW_ON_ERROR2(avio_open(&oc_->pb, filename.c_str(), AVIO_FLAG_WRITE), "[ffmpeg_consumer]");
\r
288 THROW_ON_ERROR2(avformat_write_header(oc_.get(), nullptr), "[ffmpeg_consumer]");
\r
290 if(options.size() > 0)
\r
292 BOOST_FOREACH(auto& option, options)
\r
293 CASPAR_LOG(warning) << L"Invalid option: -" << u16(option.name) << L" " << u16(option.value);
\r
296 CASPAR_LOG(info) << print() << L" Successfully Initialized.";
\r
303 LOG_ON_ERROR2(av_write_trailer(oc_.get()), "[ffmpeg_consumer]");
\r
308 if (!(oc_->oformat->flags & AVFMT_NOFILE))
\r
309 LOG_ON_ERROR2(avio_close(oc_->pb), "[ffmpeg_consumer]"); // Close the output ffmpeg.
\r
311 CASPAR_LOG(info) << print() << L" Successfully Uninitialized.";
\r
314 std::wstring print() const
\r
316 return L"ffmpeg[" + u16(filename_) + L"]";
\r
319 std::shared_ptr<AVStream> add_video_stream(std::vector<option>& options)
\r
321 if(output_format_.vcodec == CODEC_ID_NONE)
\r
324 auto st = av_new_stream(oc_.get(), 0);
\r
326 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Could not allocate video-stream.") << boost::errinfo_api_function("av_new_stream"));
\r
328 auto encoder = avcodec_find_encoder(output_format_.vcodec);
\r
330 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Codec not found."));
\r
332 auto c = st->codec;
\r
334 avcodec_get_context_defaults3(c, encoder);
\r
336 c->codec_id = output_format_.vcodec;
\r
337 c->codec_type = AVMEDIA_TYPE_VIDEO;
\r
338 c->width = output_format_.width;
\r
339 c->height = output_format_.height - output_format_.croptop - output_format_.cropbot;
\r
340 c->time_base.den = format_desc_.time_scale;
\r
341 c->time_base.num = format_desc_.duration;
\r
343 c->flags |= format_desc_.field_mode == core::field_mode::progressive ? 0 : (CODEC_FLAG_INTERLACED_ME | CODEC_FLAG_INTERLACED_DCT);
\r
344 c->pix_fmt = c->pix_fmt != PIX_FMT_NONE ? c->pix_fmt : PIX_FMT_YUV420P;
\r
346 if(c->codec_id == CODEC_ID_PRORES)
\r
348 c->bit_rate = c->width < 1280 ? 63*1000000 : 220*1000000;
\r
349 c->pix_fmt = PIX_FMT_YUV422P10;
\r
351 else if(c->codec_id == CODEC_ID_DNXHD)
\r
353 if(c->width < 1280 || c->height < 720)
\r
354 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Unsupported video dimensions."));
\r
356 c->bit_rate = 220*1000000;
\r
357 c->pix_fmt = PIX_FMT_YUV422P;
\r
359 else if(c->codec_id == CODEC_ID_DVVIDEO)
\r
361 c->width = c->height == 1280 ? 960 : c->width;
\r
363 if(format_desc_.format == core::video_format::ntsc)
\r
364 c->pix_fmt = PIX_FMT_YUV411P;
\r
365 else if(format_desc_.format == core::video_format::pal)
\r
366 c->pix_fmt = PIX_FMT_YUV420P;
\r
368 c->pix_fmt = PIX_FMT_YUV422P;
\r
370 if(format_desc_.duration == 1001)
\r
371 c->width = c->height == 1080 ? 1280 : c->width;
\r
373 c->width = c->height == 1080 ? 1440 : c->width;
\r
375 else if(c->codec_id == CODEC_ID_H264)
\r
377 c->pix_fmt = PIX_FMT_YUV420P;
\r
378 av_opt_set(c->priv_data, "preset", "ultrafast", 0);
\r
379 av_opt_set(c->priv_data, "tune", "fastdecode", 0);
\r
380 av_opt_set(c->priv_data, "crf", "5", 0);
\r
382 else if(c->codec_id == CODEC_ID_QTRLE)
\r
384 c->pix_fmt = PIX_FMT_ARGB;
\r
387 boost::range::remove_erase_if(options, [&](const option& o)
\r
389 return o.name.at(0) != 'a' && ffmpeg::av_opt_set(c, o.name.c_str(), o.value.c_str(), AV_OPT_SEARCH_CHILDREN) > -1;
\r
392 if(output_format_.format->flags & AVFMT_GLOBALHEADER)
\r
393 c->flags |= CODEC_FLAG_GLOBAL_HEADER;
\r
395 THROW_ON_ERROR2(tbb_avcodec_open(c, encoder), "[ffmpeg_consumer]");
\r
397 return std::shared_ptr<AVStream>(st, [](AVStream* st)
\r
399 LOG_ON_ERROR2(tbb_avcodec_close(st->codec), "[ffmpeg_consumer]");
\r
400 av_freep(&st->codec);
\r
405 std::shared_ptr<AVStream> add_audio_stream(std::vector<option>& options)
\r
407 if(output_format_.acodec == CODEC_ID_NONE)
\r
410 auto st = av_new_stream(oc_.get(), 1);
\r
412 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Could not allocate audio-stream") << boost::errinfo_api_function("av_new_stream"));
\r
414 auto encoder = avcodec_find_encoder(output_format_.acodec);
\r
416 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("codec not found"));
\r
418 auto c = st->codec;
\r
420 avcodec_get_context_defaults3(c, encoder);
\r
422 c->codec_id = output_format_.acodec;
\r
423 c->codec_type = AVMEDIA_TYPE_AUDIO;
\r
424 c->sample_rate = 48000;
\r
426 c->sample_fmt = AV_SAMPLE_FMT_S16;
\r
427 c->time_base.num = 1;
\r
428 c->time_base.den = c->sample_rate;
\r
430 if(output_format_.vcodec == CODEC_ID_FLV1)
\r
431 c->sample_rate = 44100;
\r
433 if(output_format_.format->flags & AVFMT_GLOBALHEADER)
\r
434 c->flags |= CODEC_FLAG_GLOBAL_HEADER;
\r
436 boost::range::remove_erase_if(options, [&](const option& o)
\r
438 return ffmpeg::av_opt_set(c, o.name.c_str(), o.value.c_str(), AV_OPT_SEARCH_CHILDREN) > -1;
\r
441 THROW_ON_ERROR2(avcodec_open(c, encoder), "[ffmpeg_consumer]");
\r
443 return std::shared_ptr<AVStream>(st, [](AVStream* st)
\r
445 LOG_ON_ERROR2(avcodec_close(st->codec), "[ffmpeg_consumer]");;
\r
446 av_freep(&st->codec);
\r
451 void encode_video_frame(core::const_frame frame)
\r
456 auto enc = video_st_->codec;
\r
460 auto av_frame = convert_video(frame, enc);
\r
461 av_frame->interlaced_frame = format_desc_.field_mode != core::field_mode::progressive;
\r
462 av_frame->top_field_first = format_desc_.field_mode == core::field_mode::upper;
\r
463 av_frame->pts = frame_number_++;
\r
466 av_init_packet(&pkt);
470 int got_packet = 0;
\r
471 THROW_ON_ERROR2(avcodec_encode_video2(enc, &pkt, av_frame.get(), &got_packet), "[ffmpeg_consumer]");
\r
472 std::shared_ptr<AVPacket> guard(&pkt, av_free_packet);
\r
477 if (pkt.pts != AV_NOPTS_VALUE)
478 pkt.pts = av_rescale_q(pkt.pts, enc->time_base, video_st_->time_base);
479 if (pkt.dts != AV_NOPTS_VALUE)
480 pkt.dts = av_rescale_q(pkt.dts, enc->time_base, video_st_->time_base);
\r
482 pkt.stream_index = video_st_->index;
\r
484 av_interleaved_write_frame(oc_.get(), &pkt);
\r
488 CASPAR_LOG_CURRENT_EXCEPTION();
\r
493 uint64_t get_channel_layout(AVCodecContext* dec)
\r
495 auto layout = (dec->channel_layout && dec->channels == av_get_channel_layout_nb_channels(dec->channel_layout)) ? dec->channel_layout : av_get_default_channel_layout(dec->channels);
\r
499 void encode_audio_frame(core::const_frame frame)
\r
504 auto enc = audio_st_->codec;
\r
508 boost::push_back(audio_buffer_, convert_audio(frame, enc));
\r
510 auto frame_size = enc->frame_size != 0 ? enc->frame_size * enc->channels * av_get_bytes_per_sample(enc->sample_fmt) : static_cast<int>(audio_buffer_.size());
\r
512 while(audio_buffer_.size() >= frame_size)
\r
514 std::shared_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);
515 avcodec_get_frame_defaults(av_frame.get());
516 av_frame->nb_samples = frame_size / (enc->channels * av_get_bytes_per_sample(enc->sample_fmt));
\r
519 av_init_packet(&pkt);
523 THROW_ON_ERROR2(avcodec_fill_audio_frame(av_frame.get(), enc->channels, enc->sample_fmt, audio_buffer_.data(), frame_size, 1), "[ffmpeg_consumer]");
\r
525 int got_packet = 0;
\r
526 THROW_ON_ERROR2(avcodec_encode_audio2(enc, &pkt, av_frame.get(), &got_packet), "[ffmpeg_consumer]");
\r
527 std::shared_ptr<AVPacket> guard(&pkt, av_free_packet);
\r
529 audio_buffer_.erase(audio_buffer_.begin(), audio_buffer_.begin() + frame_size);
\r
534 if (pkt.pts != AV_NOPTS_VALUE)
535 pkt.pts = av_rescale_q(pkt.pts, enc->time_base, audio_st_->time_base);
536 if (pkt.dts != AV_NOPTS_VALUE)
537 pkt.dts = av_rescale_q(pkt.dts, enc->time_base, audio_st_->time_base);
538 if (pkt.duration > 0)
539 pkt.duration = static_cast<int>(av_rescale_q(pkt.duration, enc->time_base, audio_st_->time_base));
\r
541 pkt.stream_index = audio_st_->index;
\r
543 av_interleaved_write_frame(oc_.get(), &pkt);
\r
548 CASPAR_LOG_CURRENT_EXCEPTION();
\r
553 std::shared_ptr<AVFrame> convert_video(core::const_frame frame, AVCodecContext* c)
\r
557 sws_.reset(sws_getContext(format_desc_.width,
\r
558 format_desc_.height - output_format_.croptop - output_format_.cropbot,
\r
563 SWS_BICUBIC, nullptr, nullptr, nullptr),
\r
565 if (sws_ == nullptr)
\r
566 BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Cannot initialize the conversion context"));
\r
569 std::shared_ptr<AVFrame> in_frame(avcodec_alloc_frame(), av_free);
\r
571 avpicture_fill(reinterpret_cast<AVPicture*>(in_frame.get()),
\r
572 const_cast<uint8_t*>(frame.image_data().begin()),
\r
574 format_desc_.width,
\r
575 format_desc_.height - output_format_.croptop - output_format_.cropbot);
\r
577 for(int n = 0; n < 4; ++n)
\r
578 in_frame->data[n] += in_frame->linesize[n] * output_format_.croptop;
\r
580 picture_buffer_.resize(avpicture_get_size(c->pix_fmt, c->width, c->height));
\r
582 std::shared_ptr<AVFrame> out_frame(avcodec_alloc_frame(), av_free);
\r
584 avpicture_fill(reinterpret_cast<AVPicture*>(out_frame.get()),
\r
585 picture_buffer_.data(),
\r
590 sws_scale(sws_.get(),
\r
592 in_frame->linesize,
\r
594 format_desc_.height - output_format_.cropbot - output_format_.croptop,
\r
596 out_frame->linesize);
\r
601 byte_vector convert_audio(core::const_frame& frame, AVCodecContext* c)
\r
605 swr_ = std::shared_ptr<SwrContext>(swr_alloc_set_opts(nullptr,
\r
606 get_channel_layout(c), c->sample_fmt, c->sample_rate,
\r
607 av_get_default_channel_layout(format_desc_.audio_channels), AV_SAMPLE_FMT_S32, format_desc_.audio_sample_rate,
\r
608 0, nullptr), [](SwrContext* p){swr_free(&p);});
\r
611 BOOST_THROW_EXCEPTION(std::bad_alloc("swr_"));
\r
613 THROW_ON_ERROR2(swr_init(swr_.get()), "[audio_decoder]");
\r
616 byte_vector buffer(48000);
\r
618 const uint8_t *in[] = {reinterpret_cast<const uint8_t*>(frame.audio_data().data())};
\r
619 uint8_t* out[] = {buffer.data()};
\r
621 auto channel_samples = swr_convert(swr_.get(),
\r
622 out, static_cast<int>(buffer.size()) / c->channels / av_get_bytes_per_sample(c->sample_fmt),
\r
623 in, static_cast<int>(frame.audio_data().size()/format_desc_.audio_channels));
\r
625 buffer.resize(channel_samples * c->channels * av_get_bytes_per_sample(c->sample_fmt));
\r
630 void send(core::const_frame& frame)
\r
632 executor_.begin_invoke([=]
\r
634 boost::timer frame_timer;
\r
636 encode_video_frame(frame);
\r
637 encode_audio_frame(frame);
\r
639 graph_->set_value("frame-time", frame_timer.elapsed()*format_desc_.fps*0.5);
\r
644 struct ffmpeg_consumer_proxy : public core::frame_consumer
\r
646 const std::wstring filename_;
\r
647 const std::vector<option> options_;
\r
649 std::unique_ptr<ffmpeg_consumer> consumer_;
\r
653 ffmpeg_consumer_proxy(const std::wstring& filename, const std::vector<option>& options)
\r
654 : filename_(filename)
\r
655 , options_(options)
\r
659 virtual void initialize(const core::video_format_desc& format_desc, int)
\r
662 consumer_.reset(new ffmpeg_consumer(u8(filename_), format_desc, options_));
\r
665 bool send(core::const_frame frame) override
\r
667 consumer_->send(frame);
\r
671 std::wstring print() const override
\r
673 return consumer_ ? consumer_->print() : L"[ffmpeg_consumer]";
\r
676 std::wstring name() const override
\r
681 boost::property_tree::wptree info() const override
\r
683 boost::property_tree::wptree info;
\r
684 info.add(L"type", L"file");
\r
685 info.add(L"filename", filename_);
\r
689 bool has_synchronization_clock() const override
\r
694 int buffer_depth() const override
\r
699 int index() const override
\r
704 spl::shared_ptr<core::frame_consumer> create_consumer(const std::vector<std::wstring>& params)
\r
706 if(params.size() < 1 || params[0] != L"FILE")
\r
707 return core::frame_consumer::empty();
\r
709 auto filename = (params.size() > 1 ? params[1] : L"");
\r
711 std::vector<option> options;
\r
713 if(params.size() >= 3)
\r
715 for(auto opt_it = params.begin()+2; opt_it != params.end();)
\r
717 auto name = u8(boost::trim_copy(boost::to_lower_copy(*opt_it++))).substr(1);
\r
718 auto value = u8(boost::trim_copy(boost::to_lower_copy(*opt_it++)));
\r
720 if(value == "h264")
\r
722 else if(value == "dvcpro")
\r
725 options.push_back(option(name, value));
\r
729 return spl::make_shared<ffmpeg_consumer_proxy>(env::media_folder() + filename, options);
\r
732 spl::shared_ptr<core::frame_consumer> create_consumer(const boost::property_tree::wptree& ptree)
\r
734 auto filename = ptree.get<std::wstring>(L"path");
\r
735 auto codec = ptree.get(L"vcodec", L"libx264");
\r
737 std::vector<option> options;
\r
738 options.push_back(option("vcodec", u8(codec)));
\r
740 return spl::make_shared<ffmpeg_consumer_proxy>(env::media_folder() + filename, options);
\r