You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Improved ChunkWriter to create chunk folder and write JSON meta data
This commit is contained in:
@@ -14,15 +14,18 @@
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <omp.h>
|
||||
#include <qdir.h>
|
||||
#include <stdio.h>
|
||||
#include <sstream>
|
||||
#include <unistd.h>
|
||||
#include "Magick++.h"
|
||||
#include "Cache.h"
|
||||
#include "Exceptions.h"
|
||||
#include "Json.h"
|
||||
#include "Sleep.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace openshot
|
||||
@@ -51,11 +54,14 @@ namespace openshot
|
||||
void process_frame(tr1::shared_ptr<Frame> frame);
|
||||
|
||||
/// check for chunk folder
|
||||
bool does_chunk_folder_exist();
|
||||
bool create_folder(string path);
|
||||
|
||||
/// check for valid chunk json
|
||||
bool is_chunk_valid();
|
||||
|
||||
/// write json meta data
|
||||
void write_json_meta_data();
|
||||
|
||||
/// write all queued frames
|
||||
void write_queued_frames();
|
||||
|
||||
|
||||
@@ -17,6 +17,12 @@ ChunkWriter::ChunkWriter(string path, FileReaderBase *reader) throw (InvalidFile
|
||||
|
||||
// Copy info struct from the source reader
|
||||
CopyReaderInfo(local_reader);
|
||||
|
||||
// Create folder (if it does not exist)
|
||||
create_folder(path);
|
||||
|
||||
// Write JSON meta data file
|
||||
write_json_meta_data();
|
||||
}
|
||||
|
||||
// Add a frame to the queue waiting to be encoded.
|
||||
@@ -128,10 +134,58 @@ void ChunkWriter::Close()
|
||||
write_audio_count = 0;
|
||||
}
|
||||
|
||||
// check for chunk folder
|
||||
bool ChunkWriter::does_chunk_folder_exist()
|
||||
// write json meta data
|
||||
void ChunkWriter::write_json_meta_data()
|
||||
{
|
||||
Json::Value root;
|
||||
root["has_video"] = local_reader->info.has_video;
|
||||
root["has_audio"] = local_reader->info.has_audio;
|
||||
root["duration"] = local_reader->info.duration;
|
||||
stringstream filesize_stream;
|
||||
filesize_stream << local_reader->info.file_size;
|
||||
root["file_size"] = filesize_stream.str();
|
||||
root["height"] = local_reader->info.height;
|
||||
root["width"] = local_reader->info.width;
|
||||
root["pixel_format"] = local_reader->info.pixel_format;
|
||||
root["fps"] = Json::Value(Json::objectValue);
|
||||
root["fps"]["num"] = local_reader->info.fps.num;
|
||||
root["fps"]["den"] = local_reader->info.fps.den;
|
||||
root["video_bit_rate"] = local_reader->info.video_bit_rate;
|
||||
root["pixel_ratio"] = Json::Value(Json::objectValue);
|
||||
root["pixel_ratio"]["num"] = local_reader->info.pixel_ratio.num;
|
||||
root["pixel_ratio"]["den"] = local_reader->info.pixel_ratio.den;
|
||||
root["display_ratio"] = Json::Value(Json::objectValue);
|
||||
root["display_ratio"]["num"] = local_reader->info.display_ratio.num;
|
||||
root["display_ratio"]["den"] = local_reader->info.display_ratio.den;
|
||||
root["vcodec"] = local_reader->info.vcodec;
|
||||
stringstream video_length_stream;
|
||||
video_length_stream << local_reader->info.video_length;
|
||||
root["video_length"] = video_length_stream.str();
|
||||
root["video_stream_index"] = local_reader->info.video_stream_index;
|
||||
root["video_timebase"] = Json::Value(Json::objectValue);
|
||||
root["video_timebase"]["num"] = local_reader->info.video_timebase.num;
|
||||
root["video_timebase"]["den"] = local_reader->info.video_timebase.den;
|
||||
root["interlaced_frame"] = local_reader->info.interlaced_frame;
|
||||
root["top_field_first"] = local_reader->info.top_field_first;
|
||||
root["acodec"] = local_reader->info.acodec;
|
||||
root["audio_bit_rate"] = local_reader->info.audio_bit_rate;
|
||||
root["sample_rate"] = local_reader->info.sample_rate;
|
||||
root["channels"] = local_reader->info.channels;
|
||||
root["audio_stream_index"] = local_reader->info.audio_stream_index;
|
||||
root["audio_timebase"] = Json::Value(Json::objectValue);
|
||||
root["audio_timebase"]["num"] = local_reader->info.audio_timebase.num;
|
||||
root["audio_timebase"]["den"] = local_reader->info.audio_timebase.den;
|
||||
|
||||
cout << root << endl;
|
||||
}
|
||||
|
||||
// check for chunk folder
|
||||
bool ChunkWriter::create_folder(string path)
|
||||
{
|
||||
QDir dir(path.c_str());
|
||||
if (!dir.exists()) {
|
||||
dir.mkpath(".");
|
||||
}
|
||||
}
|
||||
|
||||
// check for valid chunk json
|
||||
|
||||
@@ -19,6 +19,10 @@ void FrameReady(int number)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
// Create a chunkwriter
|
||||
FFmpegReader *r3 = new FFmpegReader("/home/jonathan/Videos/sintel_trailer-720p.mp4");
|
||||
ChunkWriter cw1("/home/jonathan/apps/chunks/chunk1/", r3);
|
||||
|
||||
// Qt Test Code
|
||||
if (argc == 2)
|
||||
{
|
||||
|
||||
@@ -33,6 +33,15 @@ FIND_PACKAGE(SDL REQUIRED)
|
||||
# Include SDL headers (needed for compile)
|
||||
include_directories(${SDL_INCLUDE_DIR})
|
||||
|
||||
################# QT4 ###################
|
||||
# Find QT4 libraries
|
||||
FIND_PACKAGE(Qt4 REQUIRED)
|
||||
|
||||
# Include Qt headers (needed for compile)
|
||||
include(${QT_USE_FILE})
|
||||
include_directories(${QT_INCLUDES})
|
||||
add_definitions(${QT_DEFINITIONS})
|
||||
|
||||
################# BLACKMAGIC DECKLINK ###################
|
||||
# Find BlackMagic DeckLinkAPI libraries
|
||||
FIND_PACKAGE(BlackMagic)
|
||||
@@ -49,6 +58,10 @@ FIND_PACKAGE(OpenMP)
|
||||
# Add the OpenMP compiler flag
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
|
||||
################### JSONCPP #####################
|
||||
# Include jsoncpp headers (needed for JSON parsing)
|
||||
include_directories("../thirdparty/jsoncpp/include")
|
||||
|
||||
################ TESTER EXECUTABLE #################
|
||||
# Create unit test executable (tester)
|
||||
add_executable(tester
|
||||
|
||||
Reference in New Issue
Block a user