#include "transcoder.h"
#include "log.h"
#include "film.h"
+#include "video_decoder.h"
using std::string;
using std::vector;
+using std::pair;
using boost::shared_ptr;
ExamineContentJob::ExamineContentJob (shared_ptr<Film> f, shared_ptr<Job> req)
ExamineContentJob::run ()
{
/* Decode the content to get an accurate length */
+
+ /* We don't want to use any existing length here, as progress
+ will be messed up.
+ */
+ _film->unset_length ();
shared_ptr<Options> o (new Options ("", "", ""));
o->out_size = Size (512, 512);
o->apply_crop = false;
+ o->decode_audio = false;
descend (0.5);
- _decoder = decoder_factory (_film, o, this, true, true);
- _decoder->go ();
+ pair<shared_ptr<VideoDecoder>, shared_ptr<AudioDecoder> > decoders = decoder_factory (_film, o, this);
+
+ set_progress_unknown ();
+ while (!decoders.first->pass()) {
+ /* keep going */
+ }
- _film->set_length (_decoder->last_video_frame ());
+ _film->set_length (decoders.first->video_frame());
- _film->log()->log (String::compose ("Video length is %1 frames", _decoder->last_video_frame()));
+ _film->log()->log (String::compose ("Video length is %1 frames", _film->length()));
ascend ();
o->out_size = _film->size ();
o->apply_crop = false;
o->decode_audio = false;
- o->decode_video_frequency = 128;
+ if (_film->length() > 0) {
+ o->decode_video_skip = _film->length().get() / 128;
+ } else {
+ o->decode_video_skip = 0;
+ }
o->decode_subtitles = true;
shared_ptr<ImageMagickEncoder> e (new ImageMagickEncoder (_film, o));
Transcoder w (_film, o, this, e);
}
string const tdir = _film->dir ("thumbs");
- vector<int> thumbs;
+ vector<SourceFrame> thumbs;
for (boost::filesystem::directory_iterator i = boost::filesystem::directory_iterator (tdir); i != boost::filesystem::directory_iterator(); ++i) {
set_progress (1);
set_state (FINISHED_OK);
}
-
-int
-ExamineContentJob::last_video_frame () const
-{
- return _decoder->last_video_frame ();
-}