media: implement importing SRT files
This commit is contained in:
@@ -28,6 +28,7 @@ namespace olive {
|
||||
|
||||
const QString ViewerOutput::kVideoParamsInput = QStringLiteral("video_param_in");
|
||||
const QString ViewerOutput::kAudioParamsInput = QStringLiteral("audio_param_in");
|
||||
const QString ViewerOutput::kSubtitleParamsInput = QStringLiteral("subtitle_param_in");
|
||||
const QString ViewerOutput::kTextureInput = QStringLiteral("tex_in");
|
||||
const QString ViewerOutput::kSamplesInput = QStringLiteral("samples_in");
|
||||
const QString ViewerOutput::kVideoAutoCacheInput = QStringLiteral("video_autocache_in");
|
||||
@@ -48,6 +49,8 @@ ViewerOutput::ViewerOutput(bool create_buffer_inputs, bool create_default_stream
|
||||
|
||||
AddInput(kAudioParamsInput, NodeValue::kAudioParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray | kInputFlagHidden));
|
||||
|
||||
AddInput(kSubtitleParamsInput, NodeValue::kSubtitleParams, InputFlags(kInputFlagNotConnectable | kInputFlagNotKeyframable | kInputFlagArray | kInputFlagHidden));
|
||||
|
||||
if (create_buffer_inputs) {
|
||||
AddInput(kTextureInput, NodeValue::kTexture, InputFlags(kInputFlagNotKeyframable));
|
||||
AddInput(kSamplesInput, NodeValue::kSamples, InputFlags(kInputFlagNotKeyframable));
|
||||
@@ -100,6 +103,7 @@ QString ViewerOutput::duration() const
|
||||
// Get first enabled streams
|
||||
VideoParams video = GetFirstEnabledVideoStream();
|
||||
AudioParams audio = GetFirstEnabledAudioStream();
|
||||
SubtitleParams sub = GetFirstEnabledSubtitleStream();
|
||||
|
||||
if (video.is_valid() && video.video_type() != VideoParams::kVideoTypeStill) {
|
||||
// Prioritize video
|
||||
@@ -113,6 +117,8 @@ QString ViewerOutput::duration() const
|
||||
}
|
||||
|
||||
using_timebase = audio.sample_rate_as_time_base();
|
||||
} else if (sub.is_valid()) {
|
||||
using_timebase = OLIVE_CONFIG("DefaultSequenceFrameRate").value<rational>();
|
||||
}
|
||||
|
||||
if (using_timebase.isNull()) {
|
||||
@@ -151,6 +157,11 @@ bool ViewerOutput::HasEnabledAudioStreams() const
|
||||
return GetFirstEnabledAudioStream().is_valid();
|
||||
}
|
||||
|
||||
bool ViewerOutput::HasEnabledSubtitleStreams() const
|
||||
{
|
||||
return GetFirstEnabledSubtitleStream().is_valid();
|
||||
}
|
||||
|
||||
VideoParams ViewerOutput::GetFirstEnabledVideoStream() const
|
||||
{
|
||||
int sz = GetVideoStreamCount();
|
||||
@@ -181,6 +192,21 @@ AudioParams ViewerOutput::GetFirstEnabledAudioStream() const
|
||||
return AudioParams();
|
||||
}
|
||||
|
||||
SubtitleParams ViewerOutput::GetFirstEnabledSubtitleStream() const
|
||||
{
|
||||
int sz = GetSubtitleStreamCount();
|
||||
|
||||
for (int i=0; i<sz; i++) {
|
||||
SubtitleParams sp = GetSubtitleParams(i);
|
||||
|
||||
if (sp.enabled()) {
|
||||
return sp;
|
||||
}
|
||||
}
|
||||
|
||||
return SubtitleParams();
|
||||
}
|
||||
|
||||
void ViewerOutput::set_default_parameters()
|
||||
{
|
||||
int width = OLIVE_CONFIG("DefaultSequenceWidth").toInt();
|
||||
@@ -276,6 +302,16 @@ QVector<Track::Reference> ViewerOutput::GetEnabledStreamsAsReferences() const
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
int sp_sz = GetSubtitleStreamCount();
|
||||
|
||||
for (int i=0; i<sp_sz; i++) {
|
||||
if (GetSubtitleParams(i).enabled()) {
|
||||
refs.append(Track::Reference(Track::kSubtitle, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return refs;
|
||||
}
|
||||
|
||||
@@ -285,6 +321,7 @@ void ViewerOutput::Retranslate()
|
||||
|
||||
SetInputName(kVideoParamsInput, tr("Video Parameters"));
|
||||
SetInputName(kAudioParamsInput, tr("Audio Parameters"));
|
||||
SetInputName(kSubtitleParamsInput, tr("Subtitle Parameters"));
|
||||
|
||||
if (HasInputWithID(kTextureInput)) {
|
||||
SetInputName(kTextureInput, tr("Texture"));
|
||||
@@ -520,6 +557,8 @@ int ViewerOutput::AddStream(Track::Type type, const QVariant& value)
|
||||
id = kVideoParamsInput;
|
||||
} else if (type == Track::kAudio) {
|
||||
id = kAudioParamsInput;
|
||||
} else if (type == Track::kSubtitle) {
|
||||
id = kSubtitleParamsInput;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user