struct ffmpeg_consumer::implementation : boost::noncopyable\r
{ \r
printer parent_printer_;\r
- const std::string filename_;\r
+ std::string filename_;\r
\r
// Audio\r
AVStream* audio_st_;\r
{\r
CASPAR_LOG(warning) << "Could not deduce output format from ffmpeg extension: using MPEG.";\r
fmt_ = av_guess_format("mpeg", nullptr, nullptr);\r
+ filename_ = filename_ + ".avi"; \r
}\r
if (!fmt_)\r
BOOST_THROW_EXCEPTION(caspar_exception() << msg_info("Could not find suitable output format"));\r
}\r
\r
av_write_header(oc_.get()); // write the stream header, if any \r
+\r
+ CASPAR_LOG(info) << print() << L" Successfully initialized.";\r
}\r
\r
void set_parent_printer(const printer& parent_printer) \r
parent_printer_ = parent_printer;\r
}\r
\r
+ std::wstring print() const\r
+ {\r
+ return (parent_printer_ ? parent_printer_() + L"/" : L"") + L"ffmpeg[" + widen(filename_) + L"]";\r
+ }\r
+\r
AVStream* add_video_stream(enum CodecID codec_id)\r
{ \r
auto st = av_new_stream(oc_.get(), 0);\r
std::shared_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);\r
avpicture_fill(reinterpret_cast<AVPicture*>(av_frame.get()), const_cast<uint8_t*>(frame->image_data().begin()), PIX_FMT_BGRA, format_desc_.width, format_desc_.height);\r
\r
- AVFrame local_av_frame;\r
- avcodec_get_frame_defaults(&local_av_frame);\r
+ std::shared_ptr<AVFrame> local_av_frame(avcodec_alloc_frame(), av_free);\r
picture_buf_.resize(avpicture_get_size(c->pix_fmt, format_desc_.width, format_desc_.height));\r
- avpicture_fill(reinterpret_cast<AVPicture*>(&local_av_frame), picture_buf_.data(), c->pix_fmt, format_desc_.width, format_desc_.height);\r
+ avpicture_fill(reinterpret_cast<AVPicture*>(local_av_frame.get()), picture_buf_.data(), c->pix_fmt, format_desc_.width, format_desc_.height);\r
\r
- sws_scale(img_convert_ctx_, av_frame->data, av_frame->linesize, 0, c->height, local_av_frame.data, local_av_frame.linesize);\r
+ sws_scale(img_convert_ctx_, av_frame->data, av_frame->linesize, 0, c->height, local_av_frame->data, local_av_frame->linesize);\r
\r
- int ret = avcodec_encode_video(c, video_outbuf_.data(), video_outbuf_.size(), &local_av_frame);\r
+ int ret = avcodec_encode_video(c, video_outbuf_.data(), video_outbuf_.size(), local_av_frame.get());\r
\r
int errn = -ret;\r
if (errn > 0) \r
return frame_consumer::empty();\r
\r
// TODO: Ask stakeholders about case where file already exists.\r
- boost::filesystem::remove(boost::filesystem::wpath(env::media_folder() + params[2])); // Delete the file if it exists\r
- return make_safe<ffmpeg_consumer>(env::media_folder() + params[2]);\r
+ boost::filesystem::remove(boost::filesystem::wpath(env::media_folder() + params[1])); // Delete the file if it exists\r
+ return make_safe<ffmpeg_consumer>(env::media_folder() + params[1]);\r
}\r
\r
}}\r