X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fconsumer%2Fffmpeg_consumer.cpp;h=0b38701253151cb00c20dd797d9284f0c5d01dae;hb=b17a5351a13075978b5e5d4c817fb683224d9d38;hp=55fe20e25480b78fb6b5389a6ae07bf4bd540f71;hpb=dfa5b7de320290ccfdfbb56661ee352dd9427ac6;p=casparcg diff --git a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp index 55fe20e25..0b3870125 100644 --- a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp +++ b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp @@ -1,743 +1,1317 @@ -/* -* Copyright (c) 2011 Sveriges Television AB -* -* This file is part of CasparCG (www.casparcg.com). -* -* CasparCG is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* CasparCG is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with CasparCG. If not, see . -* -* Author: Robert Nagy, ronag89@gmail.com -*/ - -#include "../StdAfx.h" - -#include "../ffmpeg_error.h" - -#include "ffmpeg_consumer.h" - -#include "../producer/tbb_avcodec.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#if defined(_MSC_VER) -#pragma warning (push) -#pragma warning (disable : 4244) -#endif -extern "C" -{ - #define __STDC_CONSTANT_MACROS - #define __STDC_LIMIT_MACROS - #include - #include - #include - #include - #include - #include - #include -} -#if defined(_MSC_VER) -#pragma warning (pop) -#endif - -namespace caspar { namespace ffmpeg { - -int av_opt_set(void *obj, const char *name, const char *val, int search_flags) -{ - AVClass* av_class = *(AVClass**)obj; - - if((strcmp(name, "pix_fmt") == 0 || strcmp(name, "pixel_format") == 0) && strcmp(av_class->class_name, "AVCodecContext") == 0) - { - AVCodecContext* c = (AVCodecContext*)obj; - auto pix_fmt = av_get_pix_fmt(val); - if(pix_fmt == PIX_FMT_NONE) - return -1; - c->pix_fmt = pix_fmt; - return 0; - } - //if((strcmp(name, "r") == 0 || strcmp(name, "frame_rate") == 0) && strcmp(av_class->class_name, "AVCodecContext") == 0) - //{ - // AVCodecContext* c = (AVCodecContext*)obj; - - // if(c->codec_type != AVMEDIA_TYPE_VIDEO) - // return -1; - - // AVRational rate; - // int ret = av_parse_video_rate(&rate, val); - // if(ret < 0) - // return ret; - - // c->time_base.num = rate.den; - // c->time_base.den = rate.num; - // return 0; - //} - - return ::av_opt_set(obj, name, val, search_flags); -} - -struct option -{ - std::string name; - std::string value; - - option(std::string name, std::string value) - : name(std::move(name)) - , value(std::move(value)) - { - } -}; - -struct output_format -{ - AVOutputFormat* format; - int width; - int height; - CodecID vcodec; - CodecID acodec; - int croptop; - int cropbot; - - output_format(const core::video_format_desc& format_desc, const std::string& filename, std::vector