22#define RAPIDJSON_ASSERT(x)
23#include "rapidjson/reader.h"
24#include "rapidjson/document.h"
25#include "rapidjson/error/en.h"
34 }
catch(
const std::exception& exception) {
35 std::cout <<
"MediaInformation parsing failed: " << exception.what() << std::endl;
41 std::shared_ptr<rapidjson::Document> document = std::make_shared<rapidjson::Document>();
43 document->Parse(ffprobeJsonOutput.c_str());
45 if (document->HasParseError()) {
46 throw std::runtime_error(GetParseError_En(document->GetParseError()));
48 std::shared_ptr<std::vector<std::shared_ptr<ffmpegkit::StreamInformation>>> streams = std::make_shared<std::vector<std::shared_ptr<ffmpegkit::StreamInformation>>>();
49 std::shared_ptr<std::vector<std::shared_ptr<ffmpegkit::Chapter>>> chapters = std::make_shared<std::vector<std::shared_ptr<ffmpegkit::Chapter>>>();
53 if (streamArray.IsArray()) {
54 for (rapidjson::SizeType i = 0; i < streamArray.Size(); i++) {
55 auto stream = std::make_shared<rapidjson::Value>();
56 *stream = streamArray[i];
57 streams->push_back(std::make_shared<ffmpegkit::StreamInformation>(stream));
64 if (chapterArray.IsArray()) {
65 for (rapidjson::SizeType i = 0; i < chapterArray.Size(); i++) {
66 auto chapter = std::make_shared<rapidjson::Value>();
67 *chapter = chapterArray[i];
68 chapters->push_back(std::make_shared<ffmpegkit::Chapter>(chapter));
73 return std::make_shared<ffmpegkit::MediaInformation>(std::static_pointer_cast<rapidjson::Value>(document), streams, chapters);