]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/consumer/ffmpeg_consumer.cpp
#405 Fixed typo.
[casparcg] / modules / ffmpeg / consumer / ffmpeg_consumer.cpp
index 44394b9a835512fc107e0a287d060aeebb880fe9..fb2045b6f5cd65f3334e648b53dfae171c96a1f1 100644 (file)
@@ -48,6 +48,7 @@
 #include <common/assert.h>
 #include <common/memshfl.h>
 #include <common/timer.h>
+#include <common/ptree.h>
 
 #include <boost/algorithm/string.hpp>
 #include <boost/property_tree/ptree.hpp>
@@ -209,7 +210,7 @@ struct output_format
                        format = av_guess_format(value.c_str(), nullptr, nullptr);
 
                        if(format == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("f"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown format " + value));
 
                        return true;
                }
@@ -217,7 +218,7 @@ struct output_format
                {
                        auto c = avcodec_find_encoder_by_name(value.c_str());
                        if(c == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("vcodec"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown video codec " + value));
 
                        vcodec = avcodec_find_encoder_by_name(value.c_str())->id;
                        return true;
@@ -227,7 +228,7 @@ struct output_format
                {
                        auto c = avcodec_find_encoder_by_name(value.c_str());
                        if(c == nullptr)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("acodec"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown audio codec " + value));
 
                        acodec = avcodec_find_encoder_by_name(value.c_str())->id;
 
@@ -236,7 +237,7 @@ struct output_format
                else if(name == "s")
                {
                        if(av_parse_video_size(&width, &height, value.c_str()) < 0)
-                               CASPAR_THROW_EXCEPTION(invalid_argument() << arg_name_info("s"));
+                               CASPAR_THROW_EXCEPTION(user_error() << msg_info("Unknown video size " + value));
                        
                        return true;
                }
@@ -389,7 +390,7 @@ public:
 
        void mark_dropped()
        {
-               graph_->set_tag("dropped-frame");
+               graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
        }
 
        std::wstring print() const
@@ -424,8 +425,8 @@ private:
                c->codec_type           = AVMEDIA_TYPE_VIDEO;
                c->width                        = output_format_.width;
                c->height                       = output_format_.height - output_format_.croptop - output_format_.cropbot;
-               st->time_base.den       = format_desc_.time_scale;
-               st->time_base.num       = format_desc_.duration;
+               c->time_base.den        = format_desc_.time_scale;
+               c->time_base.num        = format_desc_.duration;
                c->gop_size                     = 25;
                c->flags                   |= format_desc_.field_mode == core::field_mode::progressive ? 0 : (CODEC_FLAG_INTERLACED_ME | CODEC_FLAG_INTERLACED_DCT);
                c->pix_fmt                      = c->pix_fmt != PIX_FMT_NONE ? c->pix_fmt : PIX_FMT_YUV420P;
@@ -484,7 +485,7 @@ private:
                if(output_format_.format->flags & AVFMT_GLOBALHEADER)
                        c->flags |= CODEC_FLAG_GLOBAL_HEADER;
                
-               THROW_ON_ERROR2(tbb_avcodec_open(c, encoder), "[ffmpeg_consumer]");
+               THROW_ON_ERROR2(tbb_avcodec_open(c, encoder, false), "[ffmpeg_consumer]");
 
                return std::shared_ptr<AVStream>(st, [](AVStream* st)
                {
@@ -514,8 +515,8 @@ private:
                c->sample_rate          = 48000;
                c->channels                     = 2;
                c->sample_fmt           = AV_SAMPLE_FMT_S16;
-               st->time_base.num       = 1;
-               st->time_base.den       = c->sample_rate;
+               c->time_base.num        = 1;
+               c->time_base.den        = c->sample_rate;
 
                if(output_format_.vcodec == CODEC_ID_FLV1)              
                        c->sample_rate  = 44100;                
@@ -867,12 +868,12 @@ public:
 
 void describe_consumer(core::help_sink& sink, const core::help_repository& repo)
 {
-       sink.short_description(L"Can record a channel to a file supported by FFMpeg.");
+       sink.short_description(L"Can record a channel to a file supported by FFmpeg.");
        sink.syntax(L"FILE [filename:string] {-[ffmpeg_param1:string] [value1:string] {-[ffmpeg_param2:string] [value2:string] {...}}} {[separate_key:SEPARATE_KEY]}");
-       sink.para()->text(L"Can record a channel to a file supported by FFMpeg.");
+       sink.para()->text(L"Can record a channel to a file supported by FFmpeg.");
        sink.definitions()
                ->item(L"filename", L"The filename under the media folder including the extension (decides which kind of container format that will be used).")
-               ->item(L"ffmpeg_paramX", L"A parameter supported by FFMpeg. For example vcodec or acodec etc.")
+               ->item(L"ffmpeg_paramX", L"A parameter supported by FFmpeg. For example vcodec or acodec etc.")
                ->item(L"separate_key", L"If defined will create two files simultaneously -- One for fill and one for key (_A will be appended).")
                ;
        sink.para()->text(L"Examples:");
@@ -926,7 +927,7 @@ spl::shared_ptr<core::frame_consumer> create_consumer(
 spl::shared_ptr<core::frame_consumer> create_preconfigured_consumer(
                const boost::property_tree::wptree& ptree, core::interaction_sink*)
 {
-       auto filename           = ptree.get<std::wstring>(L"path");
+       auto filename           = ptree_get<std::wstring>(ptree, L"path");
        auto codec                      = ptree.get(L"vcodec", L"libx264");
        auto separate_key       = ptree.get(L"separate-key", false);