/** @return format of audio samples */
virtual AVSampleFormat audio_sample_format () const = 0;
virtual int64_t audio_channel_layout () const = 0;
+ virtual bool has_subtitles () const = 0;
void process_begin ();
bool pass ();
process_audio (_frame->data[0], data_size);
}
- } else if (_subtitle_stream >= 0 && _packet.stream_index == _subtitle_stream) {
+ } else if (_subtitle_stream >= 0 && _packet.stream_index == _subtitle_stream && _fs->with_subtitles) {
if (_have_subtitle) {
avsubtitle_free (&_subtitle);
}
}
+bool
+FFmpegDecoder::has_subtitles () const
+{
+ return (_subtitle_stream != -1);
+}
int audio_sample_rate () const;
AVSampleFormat audio_sample_format () const;
int64_t audio_channel_layout () const;
+ bool has_subtitles () const;
private:
_state.audio_channels = d->audio_channels ();
_state.audio_sample_rate = d->audio_sample_rate ();
_state.audio_sample_format = d->audio_sample_format ();
+ _state.has_subtitles = d->has_subtitles ();
_state.content_digest = md5_digest (s->content_path ());
_state.content = c;
return N;
}
+
+void
+Film::set_with_subtitles (bool w)
+{
+ _state.with_subtitles = w;
+ signal_changed (WITH_SUBTITLES);
+}
int still_duration () const {
return _state.still_duration;
}
+
+ bool with_subtitles () const {
+ return _state.with_subtitles;
+ }
void set_filters (std::vector<Filter const *> const &);
void set_audio_gain (float);
void set_audio_delay (int);
void set_still_duration (int);
+ void set_with_subtitles (bool);
/** @return size, in pixels, of the source (ignoring cropping) */
Size size () const {
AVSampleFormat audio_sample_format () const {
return _state.audio_sample_format;
}
+
+ bool has_subtitles () const {
+ return _state.has_subtitles;
+ }
std::string j2k_dir () const;
FRAMES_PER_SECOND,
AUDIO_CHANNELS,
AUDIO_SAMPLE_RATE,
- STILL_DURATION
+ STILL_DURATION,
+ WITH_SUBTITLES,
};
boost::shared_ptr<FilmState> state_copy () const;
f << "audio_gain " << audio_gain << "\n";
f << "audio_delay " << audio_delay << "\n";
f << "still_duration " << still_duration << "\n";
+ f << "with_subtitles " << with_subtitles << "\n";
/* Cached stuff; this is information about our content; we could
look it up each time, but that's slow.
f << "audio_sample_rate " << audio_sample_rate << "\n";
f << "audio_sample_format " << audio_sample_format_to_string (audio_sample_format) << "\n";
f << "content_digest " << content_digest << "\n";
+ f << "has_subtitles " << has_subtitles << "\n";
}
/** Read state from a key / value pair.
audio_delay = atoi (v.c_str ());
} else if (k == "still_duration") {
still_duration = atoi (v.c_str ());
+ } else if (k == "with_subtitles") {
+ with_subtitles = (v == "1");
}
/* Cached stuff */
audio_sample_format = audio_sample_format_from_string (v);
} else if (k == "content_digest") {
content_digest = v;
+ } else if (k == "has_subtitles") {
+ has_subtitles = (v == "1");
}
}
, audio_gain (0)
, audio_delay (0)
, still_duration (10)
+ , with_subtitles (false)
, length (0)
, audio_channels (0)
, audio_sample_rate (0)
, audio_sample_format (AV_SAMPLE_FMT_NONE)
+ , has_subtitles (false)
{}
std::string file (std::string f) const;
int audio_delay;
/** Duration to make still-sourced films (in seconds) */
int still_duration;
+ bool with_subtitles;
/* Data which is cached to speed things up */
AVSampleFormat audio_sample_format;
/** MD5 digest of our content file */
std::string content_digest;
+ /** true if the source has subtitles */
+ bool has_subtitles;
private:
std::string thumb_file_for_frame (int) const;
return 0;
}
+ bool has_subtitles () const {
+ return false;
+ }
+
static float static_frames_per_second () {
return 24;
}
int audio_sample_rate () const;
AVSampleFormat audio_sample_format () const;
int64_t audio_channel_layout () const;
+ bool has_subtitles () const {
+ return false;
+ }
private:
bool do_pass ();
_sizer->Add (s);
}
+ _with_subtitles = new wxCheckBox (this, wxID_ANY, wxT("With Subtitles"));
+ video_control (_with_subtitles);
+ _sizer->Add (_with_subtitles, 1);
+ _sizer->AddSpacer (0);
+
video_control (add_label_to_sizer (_sizer, this, "Frames Per Second"));
_frames_per_second = new wxStaticText (this, wxID_ANY, wxT (""));
_sizer->Add (video_control (_frames_per_second), 1, wxALIGN_CENTER_VERTICAL);
setup_visibility ();
setup_formats ();
+ setup_subtitle_button ();
}
/** Called when the DCP A/B switch has been toggled */
_content->SetPath (std_to_wx (_film->content ()));
setup_visibility ();
setup_formats ();
+ setup_subtitle_button ();
break;
case Film::FORMAT:
{
case Film::STILL_DURATION:
_still_duration->SetValue (_film->still_duration ());
break;
+ case Film::WITH_SUBTITLES:
+ _with_subtitles->SetValue (_film->with_subtitles ());
+ break;
}
}
_sizer->Layout ();
}
+
+void
+FilmEditor::with_subtitles_toggled (wxCommandEvent &)
+{
+ if (!_film) {
+ return;
+ }
+
+ _ignore_changes = Film::WITH_SUBTITLES;
+ _film->set_with_subtitles (_with_subtitles->GetValue ());
+ _ignore_changes = Film::NONE;
+}
+
+void
+FilmEditor::setup_subtitle_button ()
+{
+ _with_subtitles->Enable (_film->has_subtitles ());
+ if (!_film->has_subtitles ()) {
+ _with_subtitles->SetValue (false);
+ }
+}
+
void audio_gain_changed (wxCommandEvent &);
void audio_gain_calculate_button_clicked (wxCommandEvent &);
void audio_delay_changed (wxCommandEvent &);
+ void with_subtitles_toggled (wxCommandEvent &);
void still_duration_changed (wxCommandEvent &);
/* Handle changes to the model */
void set_things_sensitive (bool);
void setup_formats ();
+ void setup_subtitle_button ();
wxControl* video_control (wxControl *);
wxControl* still_control (wxControl *);
wxButton* _audio_gain_calculate_button;
/** The Film's audio delay */
wxSpinCtrl* _audio_delay;
+ wxCheckBox* _with_subtitles;
/** The Film's DCP content type */
wxComboBox* _dcp_content_type;
/** The Film's frames per second */