\r
#include "util.h"\r
\r
+#include "format/flv.h"\r
+\r
#include <tbb/concurrent_unordered_map.h>\r
#include <tbb/concurrent_queue.h>\r
\r
\r
#include <tbb/parallel_for.h>\r
\r
+#include <boost/filesystem.hpp>\r
+#include <boost/lexical_cast.hpp>\r
+\r
#if defined(_MSC_VER)\r
#pragma warning (push)\r
#pragma warning (disable : 4244)\r
{\r
#include <libswscale/swscale.h>\r
#include <libavcodec/avcodec.h>\r
+ #include <libavformat/avformat.h>\r
}\r
#if defined(_MSC_VER)\r
#pragma warning (pop)\r
}\r
}\r
\r
+bool is_sane_frame_rate(AVRational time_base)\r
+{\r
+ return true;\r
+}\r
+\r
+//TODO: Not finished\r
+void fix_meta_data(AVFormatContext& context)\r
+{\r
+ auto video_index = av_find_best_stream(&context, AVMEDIA_TYPE_VIDEO, -1, -1, 0, 0);\r
+ auto audio_index = av_find_best_stream(&context, AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0);\r
+\r
+ if(video_index > -1)\r
+ {\r
+ auto& video_stream = *context.streams[video_index];\r
+\r
+ if(video_stream.time_base.num == 1)\r
+ video_stream.time_base.num = static_cast<int>(std::pow(10.0, static_cast<int>(std::log10(static_cast<float>(video_stream.time_base.den)))-1)); \r
+ \r
+ if(boost::filesystem2::path(context.filename).extension() == ".flv")\r
+ {\r
+ try\r
+ {\r
+ //auto meta = read_flv_meta_info(context.filename);\r
+ //fps_ = boost::lexical_cast<double>(meta["framerate"]);\r
+ //video_stream.nb_frames = static_cast<int64_t>(boost::lexical_cast<double>(meta["duration"])*fps_);\r
+ }\r
+ catch(...){}\r
+ }\r
+ else\r
+ {\r
+ if(video_stream.nb_frames == 0)\r
+ video_stream.nb_frames = video_stream.duration;\r
+ }\r
+\r
+ if(!is_sane_frame_rate(video_stream.time_base))\r
+ {\r
+ if(audio_index > -1)\r
+ {\r
+ video_stream.time_base.num = video_stream.nb_frames;\r
+ video_stream.time_base.den = context.streams[audio_index]->duration / context.streams[audio_index]->codec->sample_rate;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
}
\ No newline at end of file
}\r
\r
struct AVFrame;\r
+struct AVFormatContext;\r
\r
namespace caspar {\r
\r
int make_alpha_format(int format); // NOTE: Be careful about CASPAR_PIX_FMT_LUMA, change it to PIX_FMT_GRAY8 if you want to use the frame inside some ffmpeg function.\r
safe_ptr<core::write_frame> make_write_frame(const void* tag, const safe_ptr<AVFrame>& decoded_frame, const safe_ptr<core::frame_factory>& frame_factory, int hints);\r
\r
+void fix_meta_data(AVFormatContext& context);\r
+\r
}
\ No newline at end of file