summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-04-03 00:27:09 +0100
committerCarl Hetherington <cth@carlh.net>2013-04-03 00:27:09 +0100
commit9c3e4462d32c726a6c257b0a40e642ab23d9526a (patch)
treecedc2faa6de6264177ea5c465bb26c3330413148 /src
parent7ebb57db2013c9e929d44d0e547ab1f27c59cc7f (diff)
Make subs work again (sort of).
Diffstat (limited to 'src')
-rw-r--r--src/lib/ffmpeg_decoder.cc2
-rw-r--r--src/lib/film.cc24
-rw-r--r--src/lib/film.h6
-rw-r--r--src/lib/playlist.cc57
-rw-r--r--src/lib/playlist.h6
-rw-r--r--src/wx/film_editor.cc99
-rw-r--r--src/wx/film_editor.h2
-rw-r--r--src/wx/film_viewer.cc6
8 files changed, 145 insertions, 57 deletions
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index ced9b95e9..3a185bd6a 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -122,7 +122,7 @@ FFmpegDecoder::setup_general ()
throw DecodeError (_("could not find stream information"));
}
- /* Find video, audio and subtitle streams and choose the first of each */
+ /* Find video, audio and subtitle streams */
for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
AVStream* s = _format_context->streams[i];
diff --git a/src/lib/film.cc b/src/lib/film.cc
index f71180157..091b35d47 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -1161,6 +1161,30 @@ Film::video_length () const
return _playlist->video_length ();
}
+vector<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_streams () const
+{
+ return _playlist->ffmpeg_subtitle_streams ();
+}
+
+boost::optional<FFmpegSubtitleStream>
+Film::ffmpeg_subtitle_stream () const
+{
+ return _playlist->ffmpeg_subtitle_stream ();
+}
+
+vector<FFmpegAudioStream>
+Film::ffmpeg_audio_streams () const
+{
+ return _playlist->ffmpeg_audio_streams ();
+}
+
+boost::optional<FFmpegAudioStream>
+Film::ffmpeg_audio_stream () const
+{
+ return _playlist->ffmpeg_audio_stream ();
+}
+
void
Film::content_changed (int p)
{
diff --git a/src/lib/film.h b/src/lib/film.h
index 63a86bc43..e71fe2606 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -39,6 +39,7 @@ extern "C" {
#include "util.h"
#include "dci_metadata.h"
#include "types.h"
+#include "ffmpeg_content.h"
class Format;
class Job;
@@ -114,6 +115,11 @@ public:
libdcp::Size video_size () const;
ContentVideoFrame video_length () const;
+ std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const;
+ boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
+ std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
+ boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
+
/** Identifiers for the parts of our state;
used for signalling changes.
*/
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index 3822420da..0c29650b6 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -28,6 +28,7 @@
using std::list;
using std::cout;
+using std::vector;
using boost::shared_ptr;
using boost::dynamic_pointer_cast;
@@ -47,7 +48,7 @@ Playlist::setup (ContentList content)
_ffmpeg.reset ();
_imagemagick.clear ();
_sndfile.clear ();
-
+
for (ContentList::const_iterator i = content.begin(); i != content.end(); ++i) {
shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (*i);
if (fc) {
@@ -206,6 +207,46 @@ Playlist::has_audio () const
return _audio_from != AUDIO_NONE;
}
+vector<FFmpegSubtitleStream>
+Playlist::ffmpeg_subtitle_streams () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return vector<FFmpegSubtitleStream> ();
+ }
+
+ return _ffmpeg->subtitle_streams ();
+}
+
+boost::optional<FFmpegSubtitleStream>
+Playlist::ffmpeg_subtitle_stream () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return boost::none;
+ }
+
+ return _ffmpeg->subtitle_stream ();
+}
+
+vector<FFmpegAudioStream>
+Playlist::ffmpeg_audio_streams () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return vector<FFmpegAudioStream> ();
+ }
+
+ return _ffmpeg->audio_streams ();
+}
+
+boost::optional<FFmpegAudioStream>
+Playlist::ffmpeg_audio_stream () const
+{
+ if (_video_from != VIDEO_FFMPEG || !_ffmpeg) {
+ return boost::none;
+ }
+
+ return _ffmpeg->audio_stream ();
+}
+
Player::Player (boost::shared_ptr<const Film> f, boost::shared_ptr<const Playlist> p)
: _film (f)
, _playlist (p)
@@ -296,13 +337,18 @@ Player::process_audio (shared_ptr<AudioBuffers> b)
bool
Player::seek (double t)
{
+ if (!_have_setup_decoders) {
+ setup_decoders ();
+ _have_setup_decoders = true;
+ }
+
bool r = false;
switch (_playlist->video_from()) {
case Playlist::VIDEO_NONE:
break;
case Playlist::VIDEO_FFMPEG:
- if (_ffmpeg_decoder->seek (t)) {
+ if (!_ffmpeg_decoder || _ffmpeg_decoder->seek (t)) {
r = true;
}
break;
@@ -334,13 +380,18 @@ Player::seek (double t)
bool
Player::seek_to_last ()
{
+ if (!_have_setup_decoders) {
+ setup_decoders ();
+ _have_setup_decoders = true;
+ }
+
bool r = false;
switch (_playlist->video_from ()) {
case Playlist::VIDEO_NONE:
break;
case Playlist::VIDEO_FFMPEG:
- if (_ffmpeg_decoder->seek_to_last ()) {
+ if (!_ffmpeg_decoder || _ffmpeg_decoder->seek_to_last ()) {
r = true;
}
break;
diff --git a/src/lib/playlist.h b/src/lib/playlist.h
index 403fb58d4..c461151d4 100644
--- a/src/lib/playlist.h
+++ b/src/lib/playlist.h
@@ -24,6 +24,7 @@
#include "audio_source.h"
#include "video_sink.h"
#include "audio_sink.h"
+#include "ffmpeg_content.h"
class Content;
class FFmpegContent;
@@ -52,6 +53,11 @@ public:
libdcp::Size video_size () const;
ContentVideoFrame video_length () const;
+ std::vector<FFmpegSubtitleStream> ffmpeg_subtitle_streams () const;
+ boost::optional<FFmpegSubtitleStream> ffmpeg_subtitle_stream () const;
+ std::vector<FFmpegAudioStream> ffmpeg_audio_streams () const;
+ boost::optional<FFmpegAudioStream> ffmpeg_audio_stream () const;
+
enum VideoFrom {
VIDEO_NONE,
VIDEO_FFMPEG,
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc
index d354e6e5a..5143bd370 100644
--- a/src/wx/film_editor.cc
+++ b/src/wx/film_editor.cc
@@ -150,11 +150,6 @@ FilmEditor::make_film_panel ()
_frame_rate_description->SetFont(font);
++r;
- add_label_to_grid_bag_sizer (grid, _film_panel, _("Original Size"), wxGBPosition (r, 0));
- _original_size = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
- grid->Add (_original_size, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
- ++r;
-
add_label_to_grid_bag_sizer (grid, _film_panel, _("Length"), wxGBPosition (r, 0));
_length = new wxStaticText (_film_panel, wxID_ANY, wxT (""));
grid->Add (_length, wxGBPosition (r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
@@ -220,8 +215,8 @@ FilmEditor::connect_to_widgets ()
_subtitle_scale->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::subtitle_scale_changed), 0, this);
_colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::colour_lut_changed), 0, this);
_j2k_bandwidth->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::j2k_bandwidth_changed), 0, this);
-// _ffmpeg_subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ffmpeg_subtitle_stream_changed), 0, this);
-// _ffmpeg_audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ffmpeg_audio_stream_changed), 0, this);
+ _ffmpeg_subtitle_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ffmpeg_subtitle_stream_changed), 0, this);
+ _ffmpeg_audio_stream->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (FilmEditor::ffmpeg_audio_stream_changed), 0, this);
_audio_gain->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (FilmEditor::audio_gain_changed), 0, this);
_audio_gain_calculate_button->Connect (
wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (FilmEditor::audio_gain_calculate_button_clicked), 0, this
@@ -394,6 +389,16 @@ FilmEditor::make_audio_panel ()
grid->Add (s);
}
+ {
+ add_label_to_sizer (grid, _audio_panel, _("Audio Stream"));
+ wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
+ _ffmpeg_audio_stream = new wxChoice (_audio_panel, wxID_ANY);
+ s->Add (_ffmpeg_audio_stream, 1);
+ _audio = new wxStaticText (_audio_panel, wxID_ANY, wxT (""));
+ s->Add (_audio, 1, wxALIGN_CENTER_VERTICAL | wxLEFT, 8);
+ grid->Add (s, 1, wxEXPAND);
+ }
+
_audio_gain->SetRange (-60, 60);
_audio_delay->SetRange (-1000, 1000);
}
@@ -616,18 +621,6 @@ FilmEditor::film_changed (Film::Property p)
checked_set (_name, _film->name());
setup_dcp_name ();
break;
-// case Film::SOURCE_FRAME_RATE:
-// s << fixed << setprecision(2) << _film->source_frame_rate();
-// _source_frame_rate->SetLabel (std_to_wx (s.str ()));
-// break;
-// case Film::VIDEO_SIZE:
-// if (_film->size().width == 0 && _film->size().height == 0) {
-// _original_size->SetLabel (wxT (""));
-// } else {
-// s << _film->size().width << " x " << _film->size().height;
-// _original_size->SetLabel (std_to_wx (s.str ()));
-// }
-// break;
case Film::DCP_CONTENT_TYPE:
checked_set (_dcp_content_type, DCPContentType::as_index (_film->dcp_content_type ()));
setup_dcp_name ();
@@ -674,19 +667,6 @@ FilmEditor::film_changed (Film::Property p)
case Film::DCI_METADATA:
setup_dcp_name ();
break;
-// case Film::CONTENT_AUDIO_STREAM:
-// if (_film->content_audio_stream()) {
-// checked_set (_audio_stream, _film->content_audio_stream()->to_string());
-// }
-// setup_dcp_name ();
-// setup_audio_details ();
-// setup_show_audio_sensitivity ();
-// break;
-// case Film::SUBTITLE_STREAM:
-// if (_film->subtitle_stream()) {
-// checked_set (_subtitle_stream, _film->subtitle_stream()->to_string());
-// }
-// break;
case Film::DCP_FRAME_RATE:
for (unsigned int i = 0; i < _dcp_frame_rate->GetCount(); ++i) {
if (wx_to_std (_dcp_frame_rate->GetString(i)) == boost::lexical_cast<string> (_film->dcp_frame_rate())) {
@@ -718,6 +698,17 @@ FilmEditor::film_content_changed (int p)
setup_show_audio_sensitivity ();
} else if (p == VideoContentProperty::VIDEO_LENGTH) {
setup_length ();
+ } else if (p == FFmpegContentProperty::AUDIO_STREAM) {
+ if (_film->ffmpeg_audio_stream()) {
+ checked_set (_ffmpeg_audio_stream, _film->ffmpeg_audio_stream()->id);
+ }
+ setup_dcp_name ();
+ setup_audio_details ();
+ setup_show_audio_sensitivity ();
+ } else if (p == FFmpegContentProperty::SUBTITLE_STREAM) {
+ if (_film->ffmpeg_subtitle_stream()) {
+ checked_set (_ffmpeg_subtitle_stream, _film->ffmpeg_subtitle_stream()->id);
+ }
}
}
@@ -836,6 +827,11 @@ FilmEditor::set_film (shared_ptr<Film> f)
film_changed (Film::J2K_BANDWIDTH);
film_changed (Film::DCI_METADATA);
film_changed (Film::DCP_FRAME_RATE);
+
+ film_content_changed (FFmpegContentProperty::SUBTITLE_STREAMS);
+ film_content_changed (FFmpegContentProperty::SUBTITLE_STREAM);
+ film_content_changed (FFmpegContentProperty::AUDIO_STREAMS);
+ film_content_changed (FFmpegContentProperty::AUDIO_STREAM);
}
/** Updates the sensitivity of lots of widgets to a given value.
@@ -859,7 +855,7 @@ FilmEditor::set_things_sensitive (bool s)
_bottom_crop->Enable (s);
_filters_button->Enable (s);
_scaler->Enable (s);
-// _ffmpeg_audio_stream->Enable (s);
+ _ffmpeg_audio_stream->Enable (s);
_dcp_content_type->Enable (s);
_dcp_frame_rate->Enable (s);
_trim_start->Enable (s);
@@ -996,7 +992,7 @@ FilmEditor::setup_subtitle_control_sensitivity ()
{
bool h = false;
if (_generally_sensitive && _film) {
-// h = !_film->subtitle_streams().empty();
+ h = !_film->ffmpeg_subtitle_streams().empty();
}
_with_subtitles->Enable (h);
@@ -1037,26 +1033,27 @@ FilmEditor::edit_dci_button_clicked (wxCommandEvent &)
void
FilmEditor::setup_streams ()
{
-// _ffmpeg_audio_stream->Clear ();
- vector<FFmpegAudioStream> a;// = _film->content_audio_streams ();
-// for (vector<FFmpegAudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
-// _audio_stream->Append (std_to_wx (ffa->name()), new wxStringClientData (std_to_wx (i->to_string ())));
-// }
+ _ffmpeg_audio_stream->Clear ();
+ vector<FFmpegAudioStream> a = _film->ffmpeg_audio_streams ();
+ for (vector<FFmpegAudioStream>::iterator i = a.begin(); i != a.end(); ++i) {
+ _ffmpeg_audio_stream->Append (std_to_wx (i->name), new wxStringClientData (std_to_wx (boost::lexical_cast<string> (i->id))));
+ }
-// if (_film->use_content_audio() && _film->audio_stream()) {
-// checked_set (_audio_stream, _film->audio_stream()->to_string());
-// }
+ if (_film->ffmpeg_audio_stream()) {
+ checked_set (_ffmpeg_audio_stream, boost::lexical_cast<string> (_film->ffmpeg_audio_stream()->id));
+ }
_ffmpeg_subtitle_stream->Clear ();
-// vector<shared_ptr<SubtitleStream> > s = _film->subtitle_streams ();
-// for (vector<shared_ptr<SubtitleStream> >::iterator i = s.begin(); i != s.end(); ++i) {
-// _subtitle_stream->Append (std_to_wx ((*i)->name()), new wxStringClientData (std_to_wx ((*i)->to_string ())));
-// }
-// if (_film->subtitle_stream()) {
-// checked_set (_subtitle_stream, _film->subtitle_stream()->to_string());
-// } else {
-// _subtitle_stream->SetSelection (wxNOT_FOUND);
-// }
+ vector<FFmpegSubtitleStream> s = _film->ffmpeg_subtitle_streams ();
+ for (vector<FFmpegSubtitleStream>::iterator i = s.begin(); i != s.end(); ++i) {
+ _ffmpeg_subtitle_stream->Append (std_to_wx (i->name), new wxStringClientData (std_to_wx (boost::lexical_cast<string> (i->id))));
+ }
+
+ if (_film->ffmpeg_subtitle_stream()) {
+ checked_set (_ffmpeg_subtitle_stream, boost::lexical_cast<string> (_film->ffmpeg_subtitle_stream()->id));
+ } else {
+ _ffmpeg_subtitle_stream->SetSelection (wxNOT_FOUND);
+ }
}
void
diff --git a/src/wx/film_editor.h b/src/wx/film_editor.h
index 311f8ceaa..60da2de4d 100644
--- a/src/wx/film_editor.h
+++ b/src/wx/film_editor.h
@@ -148,6 +148,7 @@ private:
wxButton* _audio_gain_calculate_button;
wxButton* _show_audio;
wxSpinCtrl* _audio_delay;
+ wxChoice* _ffmpeg_audio_stream;
wxCheckBox* _with_subtitles;
wxChoice* _ffmpeg_subtitle_stream;
wxSpinCtrl* _subtitle_offset;
@@ -158,7 +159,6 @@ private:
wxChoice* _dcp_frame_rate;
wxButton* _best_dcp_frame_rate;
wxStaticText* _frame_rate_description;
- wxStaticText* _original_size;
wxStaticText* _length;
/** The Film's audio details */
wxStaticText* _audio;
diff --git a/src/wx/film_viewer.cc b/src/wx/film_viewer.cc
index 0c03a9998..54ef28ff0 100644
--- a/src/wx/film_viewer.cc
+++ b/src/wx/film_viewer.cc
@@ -107,6 +107,8 @@ FilmViewer::film_changed (Film::Property p)
break;
}
case Film::WITH_SUBTITLES:
+ setup_player ();
+ /* fall through */
case Film::SUBTITLE_OFFSET:
case Film::SUBTITLE_SCALE:
case Film::SCALER:
@@ -124,7 +126,9 @@ FilmViewer::setup_player ()
{
_player = _film->player ();
_player->disable_audio ();
- _player->disable_subtitles ();
+ if (!_film->with_subtitles ()) {
+ _player->disable_subtitles ();
+ }
_player->disable_video_sync ();
_player->Video.connect (bind (&FilmViewer::process_video, this, _1, _2, _3));
}