Untested external audio support; AB transcodes still broken.
[dcpomatic.git] / src / lib / examine_content_job.cc
index ec0d2409bb5fc059c597cdfa1f8bec3866ca5841..8db74801fdd634feed5e2a822c4d4f97691884b6 100644 (file)
 #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)
@@ -59,19 +61,29 @@ void
 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);
-       _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->video_frame_index());
+       _film->set_length (decoders.first->video_frame());
 
-       _film->log()->log (String::compose ("Video length is %1 frames", _decoder->video_frame_index()));
+       _film->log()->log (String::compose ("Video length is %1 frames", _film->length()));
 
        ascend ();