Added subtitle conversion from srt.
This commit is contained in:
parent
d9bda0c65a
commit
b104752855
2 changed files with 66 additions and 1 deletions
|
@ -11,7 +11,7 @@ RELEASE ?= "Generic_`getconf LONG_BIT`"
|
||||||
|
|
||||||
AM_CPPFLAGS = $(global_CFLAGS) $(MIST_CFLAGS) -DRELEASE=\"$(RELEASE)\"
|
AM_CPPFLAGS = $(global_CFLAGS) $(MIST_CFLAGS) -DRELEASE=\"$(RELEASE)\"
|
||||||
LDADD = $(MIST_LIBS)
|
LDADD = $(MIST_LIBS)
|
||||||
bin_PROGRAMS=MistBuffer MistController MistConnRAW MistConnRTMP MistConnHTTP MistConnHTTPProgressive MistConnHTTPDynamic MistConnHTTPSmooth MistConnHTTPLive MistConnTS MistPlayer MistDTSC2FLV MistFLV2DTSC MistDTSCFix MistDTSCMerge MistDTSC2TS MistAnalyserRTMP MistAnalyserFLV MistAnalyserDTSC MistAnalyserAMF MistAnalyserMP4
|
bin_PROGRAMS=MistBuffer MistController MistConnRAW MistConnRTMP MistConnHTTP MistConnHTTPProgressive MistConnHTTPDynamic MistConnHTTPSmooth MistConnHTTPLive MistConnTS MistPlayer MistDTSC2FLV MistFLV2DTSC MistDTSCFix MistDTSCMerge MistDTSC2TS MistSRT2DTSC MistAnalyserRTMP MistAnalyserFLV MistAnalyserDTSC MistAnalyserAMF MistAnalyserMP4
|
||||||
|
|
||||||
#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
|
||||||
|
@ -38,6 +38,7 @@ MistFLV2DTSC_SOURCES=converters/flv2dtsc.cpp
|
||||||
MistDTSCFix_SOURCES=converters/dtscfix.cpp
|
MistDTSCFix_SOURCES=converters/dtscfix.cpp
|
||||||
MistDTSCMerge_SOURCES=converters/dtscmerge.cpp
|
MistDTSCMerge_SOURCES=converters/dtscmerge.cpp
|
||||||
MistDTSC2TS_SOURCES=converters/dtsc2ts.cpp
|
MistDTSC2TS_SOURCES=converters/dtsc2ts.cpp
|
||||||
|
MistSRT2DTSC_SOURCES=converters/srt2dtsc.cpp
|
||||||
|
|
||||||
#analysers directory (MistAnalyser*)
|
#analysers directory (MistAnalyser*)
|
||||||
MistAnalyserRTMP_SOURCES=analysers/rtmp_analyser.cpp
|
MistAnalyserRTMP_SOURCES=analysers/rtmp_analyser.cpp
|
||||||
|
|
64
src/converters/srt2dtsc.cpp
Normal file
64
src/converters/srt2dtsc.cpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/// \file flv2dtsc.cpp
|
||||||
|
/// Contains the code that will transform any valid FLV input into valid DTSC.
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <signal.h>
|
||||||
|
#include <mist/flv_tag.h>
|
||||||
|
#include <mist/dtsc.h>
|
||||||
|
#include <mist/json.h>
|
||||||
|
#include <mist/amf.h>
|
||||||
|
#include <mist/config.h>
|
||||||
|
|
||||||
|
///\brief Holds everything unique to converters.
|
||||||
|
namespace Converters {
|
||||||
|
|
||||||
|
///\brief Converts FLV from stdin to DTSC on stdout.
|
||||||
|
///\return The return code for the converter.
|
||||||
|
int SRT2DTSC(){
|
||||||
|
int lineNum;
|
||||||
|
int beginH, beginM, beginS, beginMs;
|
||||||
|
int endH, endM, endS, endMs;
|
||||||
|
char lineBuf[1024];
|
||||||
|
std::string myData;
|
||||||
|
JSON::Value meta;
|
||||||
|
meta["moreheader"] = 0ll;
|
||||||
|
meta["tracks"]["track3"]["trackid"] = 3ll;
|
||||||
|
meta["tracks"]["track3"]["type"] = "meta";
|
||||||
|
meta["tracks"]["track3"]["codec"] = "srt";
|
||||||
|
std::cout << meta.toNetPacked();
|
||||||
|
JSON::Value newPack;
|
||||||
|
while (std::cin.good()){
|
||||||
|
if (scanf( "%d\n%d:%d:%d,%d --> %d:%d:%d,%d\n", &lineNum, &beginH, &beginM, &beginS, &beginMs, &endH, &endM, &endS, &endMs) != 9){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
while (std::cin.good() && myData.find("\r\n\r\n") == std::string::npos && myData.find("\n\n") == std::string::npos){
|
||||||
|
std::cin.getline(lineBuf, 1024);
|
||||||
|
myData += std::string(lineBuf) + "\n";
|
||||||
|
}
|
||||||
|
myData.erase( myData.end() - 1 );
|
||||||
|
newPack.null();
|
||||||
|
newPack["trackid"] = 3;
|
||||||
|
newPack["time"] = (((((beginH * 60) + beginM) * 60) + beginS) * 1000) + beginMs;
|
||||||
|
newPack["duration"] = (((((endH - beginH) * 60) + (endM - beginM)) * 60) + (endS - beginS)) * 1000 + (endMs - beginMs);
|
||||||
|
newPack["data"] = myData;
|
||||||
|
std::cout << newPack.toNetPacked();
|
||||||
|
myData = "";
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} //SRT2DTSC
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///\brief Entry point for SRT2DTSC, simply calls Converters::SRT2DTSC().
|
||||||
|
int main(int argc, char ** argv){
|
||||||
|
Util::Config conf = Util::Config(argv[0], PACKAGE_VERSION);
|
||||||
|
conf.parseArgs(argc, argv);
|
||||||
|
return Converters::SRT2DTSC();
|
||||||
|
} //main
|
Loading…
Add table
Reference in a new issue