Reworked existing subtitle support (sideloaded, MP4 in and srt out)
This commit is contained in:
parent
741c4755cc
commit
b9e261e1ef
7 changed files with 159 additions and 33 deletions
38
lib/subtitles.cpp
Normal file
38
lib/subtitles.cpp
Normal file
|
@ -0,0 +1,38 @@
|
|||
#include "subtitles.h"
|
||||
#include "bitfields.h"
|
||||
|
||||
#include "defines.h"
|
||||
namespace Subtitle {
|
||||
|
||||
Packet getSubtitle(DTSC::Packet packet, DTSC::Meta meta) {
|
||||
char * tmp = 0;
|
||||
uint16_t length = 0;
|
||||
unsigned int len;
|
||||
|
||||
Packet output;
|
||||
long int trackId= packet.getTrackId();
|
||||
if(meta.tracks[trackId].codec != "TTXT" && meta.tracks[trackId].codec != "SRT") {
|
||||
//no subtitle track
|
||||
return output;
|
||||
}
|
||||
|
||||
if(packet.hasMember("duration")) {
|
||||
output.duration = packet.getInt("duration");
|
||||
} else {
|
||||
//get parts from meta
|
||||
//calculate duration
|
||||
|
||||
}
|
||||
|
||||
packet.getString("data", output.subtitle);
|
||||
if(meta.tracks[trackId].codec == "TTXT") {
|
||||
unsigned short size = Bit::btohs(output.subtitle.c_str());
|
||||
output.subtitle = output.subtitle.substr(2,size);
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
15
lib/subtitles.h
Normal file
15
lib/subtitles.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "dtsc.h"
|
||||
|
||||
namespace Subtitle {
|
||||
|
||||
struct Packet {
|
||||
std::string subtitle;
|
||||
uint64_t duration;
|
||||
};
|
||||
|
||||
Packet getSubtitle(DTSC::Packet packet, DTSC::Meta meta);
|
||||
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue