\r
std::unique_ptr<input> input_; \r
public:\r
- explicit ffmpeg_producer(const std::wstring& filename, bool loop) \r
+ explicit ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, bool loop) \r
: filename_(filename)\r
, loop_(loop) \r
, last_frame_(core::basic_frame(core::basic_frame::empty()))\r
- \r
+ , frame_factory_(frame_factory) \r
{\r
graph_ = diagnostics::create_graph(boost::bind(&ffmpeg_producer::print, this)); \r
graph_->add_guide("frame-time", 0.5);\r
graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
- }\r
- \r
- virtual void set_frame_factory(const safe_ptr<core::frame_factory>& frame_factory)\r
- {\r
- frame_factory_ = frame_factory;\r
+\r
input_.reset(new input(safe_ptr<diagnostics::graph>(graph_), filename_, loop_));\r
video_decoder_.reset(input_->get_video_codec_context().get() ? new video_decoder(input_->get_video_codec_context().get(), frame_factory) : nullptr);\r
audio_decoder_.reset(input_->get_audio_codec_context().get() ? new audio_decoder(input_->get_audio_codec_context().get(), frame_factory->get_video_format_desc().fps) : nullptr);\r
double format_frame_time = 1.0/frame_factory->get_video_format_desc().fps;\r
if(abs(frame_time - format_frame_time) > 0.0001)\r
CASPAR_LOG(warning) << print() << L" Invalid framerate detected. This may cause distorted audio during playback. frame-time: " << frame_time;\r
-\r
}\r
- \r
+ \r
virtual safe_ptr<core::basic_frame> receive()\r
{\r
perf_timer_.reset();\r
\r
if(audio_decoder_) \r
{\r
- if(!frame)\r
+ if(!frame) // If there is no video create a dummy frame.\r
{\r
frame = frame_factory_->create_frame(1, 1);\r
std::fill(frame->image_data().begin(), frame->image_data().end(), 0);\r
graph_->update_value("frame-time", static_cast<float>(perf_timer_.elapsed()/frame_factory_->get_video_format_desc().interval*0.5));\r
\r
auto result = last_frame_;\r
- if(!ouput_channel_.empty())\r
- {\r
- result = get_frame();\r
-\r
- bool interlace = abs(input_->fps()/2.0 - frame_factory_->get_video_format_desc().fps) < 0.001;\r
- if(interlace && !ouput_channel_.empty())\r
- result = core::basic_frame::interlace(result, get_frame(), frame_factory_->get_video_format_desc().mode);\r
- }\r
+ if(!ouput_channel_.empty()) \r
+ result = get_frame(); // TODO: Support 50p \r
else if(input_->is_eof())\r
result = core::basic_frame::eof();\r
\r
}\r
};\r
\r
-safe_ptr<core::frame_producer> create_ffmpeg_producer(const std::vector<std::wstring>& params)\r
+safe_ptr<core::frame_producer> create_ffmpeg_producer(const safe_ptr<core::frame_factory>& frame_factory, const std::vector<std::wstring>& params)\r
{ \r
static const std::vector<std::wstring> extensions = boost::assign::list_of\r
(L"mpg")(L"mpeg")(L"avi")(L"mov")(L"qt")(L"webm")(L"dv")(L"mp4")(L"f4v")(L"flv")(L"mkv")(L"mka")(L"wmw")(L"wma")(L"ogg")(L"divx")(L"wav")(L"mp3");\r
std::wstring path = filename + L"." + *ext;\r
bool loop = std::find(params.begin(), params.end(), L"LOOP") != params.end();\r
\r
- return make_safe<ffmpeg_producer>(path, loop);\r
+ return make_safe<ffmpeg_producer>(frame_factory, path, loop);\r
}\r
\r
}
\ No newline at end of file