DTSC2SRT Converter

This commit is contained in:
Erik Zandvliet 2013-07-10 15:01:51 +02:00 committed by Thulinma
parent f236d1c1f2
commit 0fa966906d
2 changed files with 50 additions and 0 deletions

View file

@ -42,6 +42,7 @@ bin_PROGRAMS+=MistAnalyserAMF
bin_PROGRAMS+=MistAnalyserMP4 bin_PROGRAMS+=MistAnalyserMP4
bin_PROGRAMS+=MistInfo bin_PROGRAMS+=MistInfo
bin_PROGRAMS+=MistDTSC2MP4 bin_PROGRAMS+=MistDTSC2MP4
bin_PROGRAMS+=MistDTSC2SRT
#buffer folder (MistBuffer, MistPlayer) #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 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 MistDTSC2TS_SOURCES=converters/dtsc2ts.cpp
MistSRT2DTSC_SOURCES=converters/srt2dtsc.cpp MistSRT2DTSC_SOURCES=converters/srt2dtsc.cpp
MistDTSC2MP4_SOURCES=converters/dtsc2mp4.cpp MistDTSC2MP4_SOURCES=converters/dtsc2mp4.cpp
MistDTSC2SRT_SOURCES=converters/dtsc2srt.cpp
#analysers directory (MistAnalyser*) #analysers directory (MistAnalyser*)
MistAnalyserRTMP_SOURCES=analysers/rtmp_analyser.cpp MistAnalyserRTMP_SOURCES=analysers/rtmp_analyser.cpp

View file

@ -0,0 +1,48 @@
/// \file dtscfix.cpp
/// Contains the code that will attempt to fix the metadata contained in an DTSC file.
#include <string>
#include <mist/dtsc.h>
#include <mist/json.h>
#include <mist/config.h>
#include <iomanip>
#include <iostream>
///\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