_have_setup_video_filters = true;
}
- if (_video_frame >= _fs->dcp_length()) {
+ if (!_ignore_length && _video_frame >= _fs->dcp_length()) {
return true;
}
#include "film_state.h"
#include "decoder_factory.h"
#include "decoder.h"
+#include "imagemagick_encoder.h"
+#include "transcoder.h"
using namespace std;
using namespace boost;
void
ExamineContentJob::run ()
{
+ shared_ptr<FilmState> fs = _fs->state_copy ();
+
+ /* Decode the content to get an accurate length */
+
shared_ptr<Options> o (new Options ("", "", ""));
o->out_size = Size (512, 512);
o->apply_crop = false;
- _decoder = decoder_factory (_fs, o, this, _log, true, true);
+ descend (0.5);
+
+ _decoder = decoder_factory (fs, o, this, _log, true, true);
_decoder->go ();
-
+ fs->set_length (last_video_frame ());
+
+ ascend ();
+
+ /* Now make thumbnails for it */
+
+ descend (0.5);
+
+ try {
+ o.reset (new Options (fs->dir ("thumbs"), ".png", ""));
+ o->out_size = fs->size ();
+ o->apply_crop = false;
+ o->decode_audio = false;
+ o->decode_video_frequency = 128;
+ o->decode_subtitles = true;
+ shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (fs, o, _log));
+ Transcoder w (fs, o, this, _log, e);
+ w.go ();
+ set_progress (1);
+ set_state (FINISHED_OK);
+
+ } catch (std::exception& e) {
+
+ ascend ();
+ set_progress (1);
+ set_error (e.what ());
+ set_state (FINISHED_ERROR);
+
+ }
+
+ ascend ();
set_progress (1);
set_state (FINISHED_OK);
}
delete _log;
}
-/** The pre-processing GUI part of a thumbs update.
- * Must be called from the GUI thread.
- */
-void
-Film::update_thumbs_pre_gui ()
-{
- set_thumbs (vector<int> ());
- filesystem::remove_all (dir ("thumbs"));
-
- /* This call will recreate the directory */
- dir ("thumbs");
-}
-
-/** The post-processing GUI part of a thumbs update.
- * Must be called from the GUI thread.
- */
-void
-Film::update_thumbs_post_gui ()
-{
- string const tdir = dir ("thumbs");
- vector<int> thumbs;
-
- for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) {
-
- /* Aah, the sweet smell of progress */
-#if BOOST_FILESYSTEM_VERSION == 3
- string const l = filesystem::path(*i).leaf().generic_string();
-#else
- string const l = i->leaf ();
-#endif
-
- size_t const d = l.find (".png");
- if (d != string::npos) {
- thumbs.push_back (atoi (l.substr (0, d).c_str()));
- }
- }
-
- sort (thumbs.begin(), thumbs.end());
- set_thumbs (thumbs);
-}
-
/** @return The path to the directory to write JPEG2000 files to */
string
Film::j2k_dir () const
if (_examine_content_job) {
return;
}
+
+ set_thumbs (vector<int> ());
+ filesystem::remove_all (dir ("thumbs"));
+
+ /* This call will recreate the directory */
+ dir ("thumbs");
_examine_content_job.reset (new ExamineContentJob (state_copy (), log(), shared_ptr<Job> ()));
_examine_content_job->Finished.connect (sigc::mem_fun (*this, &Film::examine_content_post_gui));
{
set_length (_examine_content_job->last_video_frame ());
_examine_content_job.reset ();
+
+ string const tdir = dir ("thumbs");
+ vector<int> thumbs;
+
+ for (filesystem::directory_iterator i = filesystem::directory_iterator (tdir); i != filesystem::directory_iterator(); ++i) {
+
+ /* Aah, the sweet smell of progress */
+#if BOOST_FILESYSTEM_VERSION == 3
+ string const l = filesystem::path(*i).leaf().generic_string();
+#else
+ string const l = i->leaf ();
+#endif
+
+ size_t const d = l.find (".png");
+ if (d != string::npos) {
+ thumbs.push_back (atoi (l.substr (0, d).c_str()));
+ }
+ }
+
+ sort (thumbs.begin(), thumbs.end());
+ set_thumbs (thumbs);
}
return sub;
}
+
+void
+Film::set_content (string c)
+{
+ FilmState::set_content (c);
+ examine_content ();
+}
~Film ();
std::string j2k_dir () const;
-
std::vector<std::string> audio_files () const;
-
- void update_thumbs_pre_gui ();
- void update_thumbs_post_gui ();
std::pair<Position, std::string> thumb_subtitle (int) const;
void copy_from_dvd_post_gui ();
int encoded_frames () const;
-private:
+ void set_content (std::string);
+
+private:
+
/** Log to write to */
Log* _log;
shared_ptr<Decoder> d = decoder_factory (s, o, 0, 0);
set_size (d->native_size ());
- set_length (d->length_in_frames ());
set_frames_per_second (d->frames_per_second ());
set_audio_sample_rate (d->audio_sample_rate ());
set_has_subtitles (d->has_subtitles ());
return _audio_streams[_audio_stream].channels ();
}
-
-
void set_directory (std::string);
void set_name (std::string);
void set_use_dci_name (bool);
- void set_content (std::string);
+ virtual void set_content (std::string);
void set_dcp_content_type (DCPContentType const *);
void set_format (Format const *);
void set_crop (Crop);
+++ /dev/null
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/thumbs_job.cc
- * @brief A job to create thumbnails.
- */
-
-#include <exception>
-#include "thumbs_job.h"
-#include "film_state.h"
-#include "imagemagick_encoder.h"
-#include "transcoder.h"
-#include "options.h"
-
-using namespace std;
-using namespace boost;
-
-/** @param s FilmState to use.
- * @param o Options.
- * @param l A log that we can write to.
- */
-ThumbsJob::ThumbsJob (shared_ptr<const FilmState> s, shared_ptr<const Options> o, Log* l, shared_ptr<Job> req)
- : Job (s, o, l, req)
-{
-
-}
-
-string
-ThumbsJob::name () const
-{
- return String::compose ("Update thumbs for %1", _fs->name());
-}
-
-void
-ThumbsJob::run ()
-{
- try {
- shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (_fs, _opt, _log));
- Transcoder w (_fs, _opt, this, _log, e);
- w.go ();
- set_progress (1);
- set_state (FINISHED_OK);
-
- } catch (std::exception& e) {
-
- set_progress (1);
- set_error (e.what ());
- set_state (FINISHED_ERROR);
- }
-}
+++ /dev/null
-/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-/** @file src/thumbs_job.h
- * @brief A job to create thumbnails.
- */
-
-#include "job.h"
-
-class FilmState;
-
-/** @class ThumbsJob
- * @brief A job to create thumbnails (single frames of the film spaced out throughout the film).
- */
-class ThumbsJob : public Job
-{
-public:
- ThumbsJob (boost::shared_ptr<const FilmState> s, boost::shared_ptr<const Options> o, Log* l, boost::shared_ptr<Job> req);
- std::string name () const;
- void run ();
-};
sound_processor.cc
stream.cc
subtitle.cc
- thumbs_job.cc
tiff_decoder.cc
timer.cc
transcode_job.cc
#include "lib/transcode_job.h"
#include "lib/exceptions.h"
#include "lib/ab_transcode_job.h"
-#include "lib/thumbs_job.h"
#include "lib/job_manager.h"
#include "lib/filter.h"
#include "lib/screen.h"
#include "lib/film.h"
#include "lib/format.h"
#include "lib/util.h"
-#include "lib/thumbs_job.h"
#include "lib/job_manager.h"
#include "lib/film_state.h"
#include "lib/options.h"
break;
case FilmState::CONTENT:
setup_visibility ();
- _film->examine_content ();
- update_thumbs ();
break;
case FilmState::CROP:
case FilmState::FORMAT:
setup_visibility ();
}
-void
-FilmViewer::update_thumbs ()
-{
- if (!_film) {
- return;
- }
-
- _film->update_thumbs_pre_gui ();
-
- shared_ptr<const FilmState> s = _film->state_copy ();
- shared_ptr<Options> o (new Options (s->dir ("thumbs"), ".png", ""));
- o->out_size = _film->size ();
- o->apply_crop = false;
- o->decode_audio = false;
- o->decode_video_frequency = 128;
- o->decode_subtitles = true;
-
- shared_ptr<Job> j (new ThumbsJob (s, o, _film->log(), shared_ptr<Job> ()));
- j->Finished.connect (sigc::mem_fun (_film, &Film::update_thumbs_post_gui));
- JobManager::instance()->add (j);
-}
-
void
FilmViewer::setup_visibility ()
{
private:
void slider_changed (wxCommandEvent &);
- void update_thumbs ();
void set_thumbnail (int);
void film_changed (FilmState::Property);