2013-09-12 17:52:10 -05:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
* @brief Source file for WriterBase class
|
|
|
|
|
* @author Jonathan Thomas <jonathan@openshot.org>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* Copyright (c) 2008-2014 OpenShot Studios, LLC
|
|
|
|
|
* <http://www.openshotstudios.com/>. This file is part of
|
|
|
|
|
* OpenShot Library (libopenshot), an open-source project dedicated to
|
|
|
|
|
* delivering high quality video editing and animation solutions to the
|
|
|
|
|
* world. For more information visit <http://www.openshot.org/>.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) is free software: you can redistribute it
|
2014-07-11 16:52:14 -05:00
|
|
|
* and/or modify it under the terms of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* as published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-03-29 18:49:22 -05:00
|
|
|
* OpenShot Library (libopenshot) 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
|
2014-07-11 16:52:14 -05:00
|
|
|
* GNU Lesser General Public License for more details.
|
2013-09-12 17:52:10 -05:00
|
|
|
*
|
2014-07-11 16:52:14 -05:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2014-03-29 18:49:22 -05:00
|
|
|
* along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
|
2013-09-12 17:52:10 -05:00
|
|
|
*/
|
|
|
|
|
|
2013-09-08 16:40:57 -05:00
|
|
|
#include "../include/WriterBase.h"
|
2012-07-09 15:18:24 -05:00
|
|
|
|
|
|
|
|
using namespace openshot;
|
|
|
|
|
|
2014-08-27 09:44:27 -05:00
|
|
|
// Constructor
|
|
|
|
|
WriterBase::WriterBase()
|
2012-07-12 15:55:41 -05:00
|
|
|
{
|
2014-08-27 09:44:27 -05:00
|
|
|
// Initialized writer info
|
2012-07-12 15:55:41 -05:00
|
|
|
info.has_video = false;
|
|
|
|
|
info.has_audio = false;
|
|
|
|
|
info.duration = 0.0;
|
|
|
|
|
info.file_size = 0;
|
|
|
|
|
info.height = 0;
|
|
|
|
|
info.width = 0;
|
|
|
|
|
info.pixel_format = -1;
|
|
|
|
|
info.fps = Fraction();
|
|
|
|
|
info.video_bit_rate = 0;
|
|
|
|
|
info.pixel_ratio = Fraction();
|
|
|
|
|
info.display_ratio = Fraction();
|
|
|
|
|
info.vcodec = "";
|
|
|
|
|
info.video_length = 0;
|
|
|
|
|
info.video_stream_index = -1;
|
|
|
|
|
info.video_timebase = Fraction();
|
|
|
|
|
info.interlaced_frame = false;
|
|
|
|
|
info.top_field_first = true;
|
|
|
|
|
info.acodec = "";
|
|
|
|
|
info.audio_bit_rate = 0;
|
|
|
|
|
info.sample_rate = 0;
|
|
|
|
|
info.channels = 0;
|
2015-02-05 00:02:59 -06:00
|
|
|
info.channel_layout = LAYOUT_MONO;
|
2012-07-12 15:55:41 -05:00
|
|
|
info.audio_stream_index = -1;
|
|
|
|
|
info.audio_timebase = Fraction();
|
2014-08-27 09:44:27 -05:00
|
|
|
|
|
|
|
|
// Initialize debug
|
|
|
|
|
debug = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Output debug information as JSON
|
|
|
|
|
string WriterBase::OutputDebugJSON()
|
|
|
|
|
{
|
|
|
|
|
// Return formatted string
|
|
|
|
|
return debug_root.toStyledString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Append debug information as JSON
|
|
|
|
|
void WriterBase::AppendDebugItem(Json::Value debug_item)
|
|
|
|
|
{
|
|
|
|
|
// Append item to root array
|
|
|
|
|
debug_root.append(debug_item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Append debug information as JSON
|
|
|
|
|
void WriterBase::AppendDebugMethod(string method_name, string arg1_name, int arg1_value,
|
|
|
|
|
string arg2_name, int arg2_value,
|
|
|
|
|
string arg3_name, int arg3_value,
|
|
|
|
|
string arg4_name, int arg4_value,
|
|
|
|
|
string arg5_name, int arg5_value,
|
|
|
|
|
string arg6_name, int arg6_value)
|
|
|
|
|
{
|
|
|
|
|
if (!debug)
|
|
|
|
|
// Don't do anything
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Json::Value debug_item;
|
|
|
|
|
debug_item["method"] = method_name;
|
|
|
|
|
|
|
|
|
|
// Output to standard output
|
|
|
|
|
cout << "Debug: Method: " << method_name << " (";
|
|
|
|
|
|
|
|
|
|
// Add attributes to method JSON
|
|
|
|
|
if (arg1_name.length() > 0) {
|
|
|
|
|
debug_item[arg1_name] = arg1_value;
|
|
|
|
|
cout << arg1_name << "=" << arg1_value;
|
|
|
|
|
}
|
|
|
|
|
if (arg2_name.length() > 0) {
|
|
|
|
|
debug_item[arg2_name] = arg2_value;
|
|
|
|
|
cout << ", " << arg2_name << "=" << arg2_value;
|
|
|
|
|
}
|
|
|
|
|
if (arg3_name.length() > 0) {
|
|
|
|
|
debug_item[arg3_name] = arg3_value;
|
|
|
|
|
cout << ", " << arg3_name << "=" << arg3_value;
|
|
|
|
|
}
|
|
|
|
|
if (arg4_name.length() > 0) {
|
|
|
|
|
debug_item[arg4_name] = arg4_value;
|
|
|
|
|
cout << ", " << arg4_name << "=" << arg4_value;
|
|
|
|
|
}
|
|
|
|
|
if (arg5_name.length() > 0) {
|
|
|
|
|
debug_item[arg5_name] = arg5_value;
|
|
|
|
|
cout << ", " << arg5_name << "=" << arg5_value;
|
|
|
|
|
}
|
|
|
|
|
if (arg6_name.length() > 0) {
|
|
|
|
|
debug_item[arg6_name] = arg6_value;
|
|
|
|
|
cout << ", " << arg6_name << "=" << arg6_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Output to standard output
|
|
|
|
|
cout << ")" << endl;
|
|
|
|
|
|
|
|
|
|
// Append method to root array
|
|
|
|
|
debug_root.append(debug_item);
|
2012-07-12 15:55:41 -05:00
|
|
|
}
|
|
|
|
|
|
2013-07-31 12:45:47 -05:00
|
|
|
// This method copy's the info struct of a reader, and sets the writer with the same info
|
2013-09-08 16:40:57 -05:00
|
|
|
void WriterBase::CopyReaderInfo(ReaderBase* reader)
|
2013-07-31 12:45:47 -05:00
|
|
|
{
|
|
|
|
|
info.has_video = reader->info.has_video;
|
|
|
|
|
info.has_audio = reader->info.has_audio;
|
|
|
|
|
info.duration = reader->info.duration;
|
|
|
|
|
info.file_size = reader->info.file_size;
|
|
|
|
|
info.height = reader->info.height;
|
|
|
|
|
info.width = reader->info.width;
|
|
|
|
|
info.pixel_format = reader->info.pixel_format;
|
|
|
|
|
info.fps.num = reader->info.fps.num;
|
|
|
|
|
info.fps.den = reader->info.fps.den;
|
|
|
|
|
info.video_bit_rate = reader->info.video_bit_rate;
|
|
|
|
|
info.pixel_ratio.num = reader->info.pixel_ratio.num;
|
|
|
|
|
info.pixel_ratio.den = reader->info.pixel_ratio.den;
|
|
|
|
|
info.display_ratio.num = reader->info.display_ratio.num;
|
|
|
|
|
info.display_ratio.den = reader->info.display_ratio.den;
|
|
|
|
|
info.vcodec = reader->info.vcodec;
|
|
|
|
|
info.video_length = reader->info.video_length;
|
|
|
|
|
info.video_stream_index = reader->info.video_stream_index;
|
|
|
|
|
info.video_timebase.num = reader->info.video_timebase.num;
|
|
|
|
|
info.video_timebase.den = reader->info.video_timebase.den;
|
|
|
|
|
info.interlaced_frame = reader->info.interlaced_frame;
|
|
|
|
|
info.top_field_first = reader->info.top_field_first;
|
|
|
|
|
info.acodec = reader->info.acodec;
|
|
|
|
|
info.audio_bit_rate = reader->info.audio_bit_rate;
|
|
|
|
|
info.sample_rate = reader->info.sample_rate;
|
|
|
|
|
info.channels = reader->info.channels;
|
2015-02-05 00:02:59 -06:00
|
|
|
info.channel_layout = reader->info.channel_layout;
|
2013-07-31 12:45:47 -05:00
|
|
|
info.audio_stream_index = reader->info.audio_stream_index;
|
|
|
|
|
info.audio_timebase.num = reader->info.audio_timebase.num;
|
|
|
|
|
info.audio_timebase.den = reader->info.audio_timebase.den;
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-09 15:18:24 -05:00
|
|
|
// Display file information
|
2013-09-08 16:40:57 -05:00
|
|
|
void WriterBase::DisplayInfo() {
|
2012-07-09 15:18:24 -05:00
|
|
|
cout << fixed << setprecision(2) << boolalpha;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "----- File Information -----" << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "--> Has Video: " << info.has_video << endl;
|
|
|
|
|
cout << "--> Has Audio: " << info.has_audio << endl;
|
|
|
|
|
cout << "--> Duration: " << info.duration << " Seconds" << endl;
|
|
|
|
|
cout << "--> File Size: " << double(info.file_size) / 1024 / 1024 << " MB" << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "----- Video Attributes -----" << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "--> Width: " << info.width << endl;
|
|
|
|
|
cout << "--> Height: " << info.height << endl;
|
|
|
|
|
cout << "--> Pixel Format: " << info.pixel_format << endl;
|
|
|
|
|
cout << "--> Frames Per Second: " << info.fps.ToDouble() << " (" << info.fps.num << "/" << info.fps.den << ")" << endl;
|
|
|
|
|
cout << "--> Video Bit Rate: " << info.video_bit_rate/1000 << " kb/s" << endl;
|
|
|
|
|
cout << "--> Pixel Ratio: " << info.pixel_ratio.ToDouble() << " (" << info.pixel_ratio.num << "/" << info.pixel_ratio.den << ")" << endl;
|
|
|
|
|
cout << "--> Display Aspect Ratio: " << info.display_ratio.ToDouble() << " (" << info.display_ratio.num << "/" << info.display_ratio.den << ")" << endl;
|
|
|
|
|
cout << "--> Video Codec: " << info.vcodec << endl;
|
|
|
|
|
cout << "--> Video Length: " << info.video_length << " Frames" << endl;
|
|
|
|
|
cout << "--> Video Stream Index: " << info.video_stream_index << endl;
|
|
|
|
|
cout << "--> Video Timebase: " << info.video_timebase.ToDouble() << " (" << info.video_timebase.num << "/" << info.video_timebase.den << ")" << endl;
|
|
|
|
|
cout << "--> Interlaced: " << info.interlaced_frame << endl;
|
|
|
|
|
cout << "--> Interlaced: Top Field First: " << info.top_field_first << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "----- Audio Attributes -----" << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
cout << "--> Audio Codec: " << info.acodec << endl;
|
|
|
|
|
cout << "--> Audio Bit Rate: " << info.audio_bit_rate/1000 << " kb/s" << endl;
|
|
|
|
|
cout << "--> Sample Rate: " << info.sample_rate << " Hz" << endl;
|
|
|
|
|
cout << "--> # of Channels: " << info.channels << endl;
|
2015-02-05 00:02:59 -06:00
|
|
|
cout << "--> Channel Layout: " << info.channel_layout << endl;
|
2012-07-09 15:18:24 -05:00
|
|
|
cout << "--> Audio Stream Index: " << info.audio_stream_index << endl;
|
|
|
|
|
cout << "--> Audio Timebase: " << info.audio_timebase.ToDouble() << " (" << info.audio_timebase.num << "/" << info.audio_timebase.den << ")" << endl;
|
|
|
|
|
cout << "----------------------------" << endl;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-07 16:52:09 -06:00
|
|
|
// Generate JSON string of this object
|
2013-12-03 00:13:25 -06:00
|
|
|
string WriterBase::Json() {
|
|
|
|
|
|
2013-12-07 16:52:09 -06:00
|
|
|
// Return formatted string
|
|
|
|
|
return JsonValue().toStyledString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Generate Json::JsonValue for this object
|
|
|
|
|
Json::Value WriterBase::JsonValue() {
|
|
|
|
|
|
2013-12-03 00:13:25 -06:00
|
|
|
// Create root json object
|
|
|
|
|
Json::Value root;
|
|
|
|
|
root["has_video"] = info.has_video;
|
|
|
|
|
root["has_audio"] = info.has_audio;
|
|
|
|
|
root["duration"] = info.duration;
|
|
|
|
|
stringstream filesize_stream;
|
|
|
|
|
filesize_stream << info.file_size;
|
|
|
|
|
root["file_size"] = filesize_stream.str();
|
|
|
|
|
root["height"] = info.height;
|
|
|
|
|
root["width"] = info.width;
|
|
|
|
|
root["pixel_format"] = info.pixel_format;
|
|
|
|
|
root["fps"] = Json::Value(Json::objectValue);
|
|
|
|
|
root["fps"]["num"] = info.fps.num;
|
|
|
|
|
root["fps"]["den"] = info.fps.den;
|
|
|
|
|
root["video_bit_rate"] = info.video_bit_rate;
|
|
|
|
|
root["pixel_ratio"] = Json::Value(Json::objectValue);
|
|
|
|
|
root["pixel_ratio"]["num"] = info.pixel_ratio.num;
|
|
|
|
|
root["pixel_ratio"]["den"] = info.pixel_ratio.den;
|
|
|
|
|
root["display_ratio"] = Json::Value(Json::objectValue);
|
|
|
|
|
root["display_ratio"]["num"] = info.display_ratio.num;
|
|
|
|
|
root["display_ratio"]["den"] = info.display_ratio.den;
|
|
|
|
|
root["vcodec"] = info.vcodec;
|
|
|
|
|
stringstream video_length_stream;
|
|
|
|
|
video_length_stream << info.video_length;
|
|
|
|
|
root["video_length"] = video_length_stream.str();
|
|
|
|
|
root["video_stream_index"] = info.video_stream_index;
|
|
|
|
|
root["video_timebase"] = Json::Value(Json::objectValue);
|
|
|
|
|
root["video_timebase"]["num"] = info.video_timebase.num;
|
|
|
|
|
root["video_timebase"]["den"] = info.video_timebase.den;
|
|
|
|
|
root["interlaced_frame"] = info.interlaced_frame;
|
|
|
|
|
root["top_field_first"] = info.top_field_first;
|
|
|
|
|
root["acodec"] = info.acodec;
|
|
|
|
|
root["audio_bit_rate"] = info.audio_bit_rate;
|
|
|
|
|
root["sample_rate"] = info.sample_rate;
|
|
|
|
|
root["channels"] = info.channels;
|
2015-02-05 00:02:59 -06:00
|
|
|
root["channel_layout"] = info.channel_layout;
|
2013-12-03 00:13:25 -06:00
|
|
|
root["audio_stream_index"] = info.audio_stream_index;
|
|
|
|
|
root["audio_timebase"] = Json::Value(Json::objectValue);
|
|
|
|
|
root["audio_timebase"]["num"] = info.audio_timebase.num;
|
|
|
|
|
root["audio_timebase"]["den"] = info.audio_timebase.den;
|
|
|
|
|
|
2013-12-07 16:52:09 -06:00
|
|
|
// return JsonValue
|
|
|
|
|
return root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load JSON string into this object
|
2013-12-07 21:09:55 -06:00
|
|
|
void WriterBase::SetJson(string value) throw(InvalidJSON) {
|
2013-12-07 16:52:09 -06:00
|
|
|
|
|
|
|
|
// Parse JSON string into JSON objects
|
|
|
|
|
Json::Value root;
|
|
|
|
|
Json::Reader reader;
|
|
|
|
|
bool success = reader.parse( value, root );
|
|
|
|
|
if (!success)
|
|
|
|
|
// Raise exception
|
|
|
|
|
throw InvalidJSON("JSON could not be parsed (or is invalid)", "");
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Set all values that match
|
2013-12-07 21:09:55 -06:00
|
|
|
SetJsonValue(root);
|
2013-12-07 16:52:09 -06:00
|
|
|
}
|
|
|
|
|
catch (exception e)
|
|
|
|
|
{
|
|
|
|
|
// Error parsing JSON (or missing keys)
|
|
|
|
|
throw InvalidJSON("JSON is invalid (missing keys or invalid data types)", "");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Load Json::JsonValue into this object
|
2013-12-07 21:09:55 -06:00
|
|
|
void WriterBase::SetJsonValue(Json::Value root) {
|
2013-12-07 16:52:09 -06:00
|
|
|
|
|
|
|
|
// Set data from Json (if key is found)
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["has_video"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.has_video = root["has_video"].asBool();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["has_audio"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.has_audio = root["has_audio"].asBool();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["duration"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.duration = root["duration"].asDouble();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["file_size"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.file_size = (long long) root["file_size"].asUInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["height"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.height = root["height"].asInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["width"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.width = root["width"].asInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["pixel_format"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.pixel_format = root["pixel_format"].asInt();
|
2014-05-16 14:48:25 -05:00
|
|
|
if (!root["fps"].isNull() && root["fps"].isObject()) {
|
|
|
|
|
if (!root["fps"]["num"].isNull())
|
|
|
|
|
info.fps.num = root["fps"]["num"].asInt();
|
|
|
|
|
if (!root["fps"]["den"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.fps.den = root["fps"]["den"].asInt();
|
|
|
|
|
}
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["video_bit_rate"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.video_bit_rate = root["video_bit_rate"].asInt();
|
2014-05-16 14:48:25 -05:00
|
|
|
if (!root["pixel_ratio"].isNull() && root["pixel_ratio"].isObject()) {
|
|
|
|
|
if (!root["pixel_ratio"]["num"].isNull())
|
|
|
|
|
info.pixel_ratio.num = root["pixel_ratio"]["num"].asInt();
|
|
|
|
|
if (!root["pixel_ratio"]["den"].isNull())
|
|
|
|
|
info.pixel_ratio.den = root["pixel_ratio"]["den"].asInt();
|
2013-12-07 16:52:09 -06:00
|
|
|
}
|
2014-05-16 14:48:25 -05:00
|
|
|
if (!root["display_ratio"].isNull() && root["display_ratio"].isObject()) {
|
|
|
|
|
if (!root["display_ratio"]["num"].isNull())
|
|
|
|
|
info.display_ratio.num = root["display_ratio"]["num"].asInt();
|
|
|
|
|
if (!root["display_ratio"]["den"].isNull())
|
|
|
|
|
info.display_ratio.den = root["display_ratio"]["den"].asInt();
|
2013-12-07 16:52:09 -06:00
|
|
|
}
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["vcodec"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.vcodec = root["vcodec"].asString();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["video_length"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.video_length = (long int) root["video_length"].asUInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["video_stream_index"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.video_stream_index = root["video_stream_index"].asInt();
|
2014-05-16 14:48:25 -05:00
|
|
|
if (!root["video_timebase"].isNull() && root["video_timebase"].isObject()) {
|
|
|
|
|
if (!root["video_timebase"]["num"].isNull())
|
|
|
|
|
info.video_timebase.num = root["video_timebase"]["num"].asInt();
|
|
|
|
|
if (!root["video_timebase"]["den"].isNull())
|
|
|
|
|
info.video_timebase.den = root["video_timebase"]["den"].asInt();
|
2013-12-07 16:52:09 -06:00
|
|
|
}
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["interlaced_frame"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.interlaced_frame = root["interlaced_frame"].asBool();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["top_field_first"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.top_field_first = root["top_field_first"].asBool();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["acodec"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.acodec = root["acodec"].asString();
|
|
|
|
|
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["audio_bit_rate"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.audio_bit_rate = root["audio_bit_rate"].asInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["sample_rate"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.sample_rate = root["sample_rate"].asInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["channels"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.channels = root["channels"].asInt();
|
2015-02-05 00:02:59 -06:00
|
|
|
if (!root["channel_layout"].isNull())
|
|
|
|
|
info.channel_layout = (ChannelLayout) root["channel_layout"].asInt();
|
2014-01-08 01:43:58 -06:00
|
|
|
if (!root["audio_stream_index"].isNull())
|
2013-12-07 16:52:09 -06:00
|
|
|
info.audio_stream_index = root["audio_stream_index"].asInt();
|
2014-05-16 14:48:25 -05:00
|
|
|
if (!root["audio_timebase"].isNull() && root["audio_timebase"].isObject()) {
|
|
|
|
|
if (!root["audio_timebase"]["num"].isNull())
|
|
|
|
|
info.audio_timebase.num = root["audio_timebase"]["num"].asInt();
|
|
|
|
|
if (!root["audio_timebase"]["den"].isNull())
|
|
|
|
|
info.audio_timebase.den = root["audio_timebase"]["den"].asInt();
|
2013-12-07 16:52:09 -06:00
|
|
|
}
|
2013-12-03 00:13:25 -06:00
|
|
|
}
|