From 0fa966906d5389476f0375db34aff87f242514da Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Wed, 10 Jul 2013 15:01:51 +0200 Subject: [PATCH] DTSC2SRT Converter --- src/Makefile.am | 2 ++ src/converters/dtsc2srt.cpp | 48 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/converters/dtsc2srt.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 5e96502c..998a79b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,6 +42,7 @@ bin_PROGRAMS+=MistAnalyserAMF bin_PROGRAMS+=MistAnalyserMP4 bin_PROGRAMS+=MistInfo bin_PROGRAMS+=MistDTSC2MP4 +bin_PROGRAMS+=MistDTSC2SRT #buffer folder (MistBuffer, MistPlayer) MistBuffer_SOURCES=buffer/buffer.cpp buffer/buffer_user.h buffer/buffer_user.cpp buffer/buffer_stream.h buffer/buffer_stream.cpp tinythread.cpp tinythread.h ../VERSION @@ -75,6 +76,7 @@ MistDTSCMerge_SOURCES=converters/dtscmerge.cpp MistDTSC2TS_SOURCES=converters/dtsc2ts.cpp MistSRT2DTSC_SOURCES=converters/srt2dtsc.cpp MistDTSC2MP4_SOURCES=converters/dtsc2mp4.cpp +MistDTSC2SRT_SOURCES=converters/dtsc2srt.cpp #analysers directory (MistAnalyser*) MistAnalyserRTMP_SOURCES=analysers/rtmp_analyser.cpp diff --git a/src/converters/dtsc2srt.cpp b/src/converters/dtsc2srt.cpp new file mode 100644 index 00000000..dd6b5f70 --- /dev/null +++ b/src/converters/dtsc2srt.cpp @@ -0,0 +1,48 @@ +/// \file dtscfix.cpp +/// Contains the code that will attempt to fix the metadata contained in an DTSC file. + +#include +#include +#include +#include +#include +#include + +///\brief Holds everything unique to converters. +namespace Converters { + ///\brief Reads a DTSC file and attempts to fix the metadata in it. + ///\param conf The current configuration of the program. + ///\return The return code for the fixed program. + int DTSCFix(Util::Config & conf){ + DTSC::File F(conf.getString("filename")); + + int curIndex = 1; + + F.parseNext(); + while ( !F.getJSON().isNull()){ + std::cout << curIndex++ << std::endl; + long long unsigned int time = F.getJSON()["time"].asInt(); + std::cout << std::setfill('0') << std::setw(2) << (time / 3600000) << ":"; + std::cout << std::setfill('0') << std::setw(2) << ((time % 3600000) / 60000) << ":"; + std::cout << std::setfill('0') << std::setw(2) << (((time % 3600000) % 60000) / 1000) << ","; + std::cout << std::setfill('0') << std::setw(3) << time % 1000 << " --> "; + time += F.getJSON()["duration"].asInt(); + std::cout << std::setfill('0') << std::setw(2) << (time / 3600000) << ":"; + std::cout << std::setfill('0') << std::setw(2) << ((time % 3600000) / 60000) << ":"; + std::cout << std::setfill('0') << std::setw(2) << (((time % 3600000) % 60000) / 1000) << ","; + std::cout << std::setfill('0') << std::setw(3) << time % 1000 << std::endl; + std::cout << F.getJSON()["data"].asString() << std::endl; + F.parseNext(); + } + + } //DTSCFix + +} + +/// Entry point for DTSCFix, simply calls Converters::DTSCFix(). +int main(int argc, char ** argv){ + Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION); + conf.addOption("filename", JSON::fromString("{\"arg_num\":1, \"arg\":\"string\", \"help\":\"Filename of the file to attempt to fix.\"}")); + conf.parseArgs(argc, argv); + return Converters::DTSCFix(conf); +} //main