X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fconsumer%2Fffmpeg_consumer.cpp;h=b3006ab0a2ebcd6a1bb9450178c6800d90a49efa;hb=b8c8660af595b9897af41183fe8b12786d45af98;hp=437511c92a36ba6074ec0286a1a89cd0a7c8c21d;hpb=26f1b7eac5e2dd3b36dbae38dfdc0ae270705aea;p=casparcg diff --git a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp index 437511c92..b3006ab0a 100644 --- a/modules/ffmpeg/consumer/ffmpeg_consumer.cpp +++ b/modules/ffmpeg/consumer/ffmpeg_consumer.cpp @@ -1,743 +1,940 @@ -/* -* 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