Put in silence where there was none.
[dcpomatic.git] / src / lib / film.cc
index a881e957acca19b83f7fb0ee2dd368e3b2e396ae..ce555ac8b29b3ac33d17e906ec05a3699620da7e 100644 (file)
@@ -68,6 +68,7 @@ using std::setfill;
 using std::min;
 using std::make_pair;
 using std::endl;
+using std::list;
 using boost::shared_ptr;
 using boost::lexical_cast;
 using boost::to_upper_copy;
@@ -107,6 +108,7 @@ Film::Film (string d, bool must_exist)
        , _j2k_bandwidth (200000000)
        , _dci_metadata (Config::instance()->default_dci_metadata ())
        , _dcp_frame_rate (0)
+       , _minimum_audio_channels (0)
        , _source_frame_rate (0)
        , _dirty (false)
 {
@@ -142,13 +144,13 @@ Film::Film (string d, bool must_exist)
 
        _sndfile_stream = SndfileStream::create ();
        
+       _log.reset (new FileLog (file ("log")));
+       
        if (must_exist) {
                read_metadata ();
        } else {
                write_metadata ();
        }
-
-       _log.reset (new FileLog (file ("log")));
 }
 
 Film::Film (Film const & o)
@@ -184,6 +186,7 @@ Film::Film (Film const & o)
        , _dci_metadata      (o._dci_metadata)
        , _dci_date          (o._dci_date)
        , _dcp_frame_rate    (o._dcp_frame_rate)
+       , _minimum_audio_channels (o._minimum_audio_channels)
        , _size              (o._size)
        , _length            (o._length)
        , _content_digest    (o._content_digest)
@@ -244,7 +247,6 @@ Film::info_dir () const
 string
 Film::internal_video_mxf_dir () const
 {
-       boost::filesystem::path p;
        return dir ("video");
 }
 
@@ -317,6 +319,11 @@ Film::make_dcp ()
        log()->log (String::compose ("Content at %1 fps, DCP at %2 fps", source_frame_rate(), dcp_frame_rate()));
        log()->log (String::compose ("%1 threads", Config::instance()->num_local_encoding_threads()));
        log()->log (String::compose ("J2K bandwidth %1", j2k_bandwidth()));
+       if (use_content_audio()) {
+               log()->log ("Using content's audio");
+       } else {
+               log()->log (String::compose ("Using external audio (%1 files)", external_audio().size()));
+       }
 #ifdef DVDOMATIC_DEBUG
        log()->log ("DVD-o-matic built in debug mode.");
 #else
@@ -329,6 +336,10 @@ Film::make_dcp ()
 #endif
        pair<string, int> const c = cpu_info ();
        log()->log (String::compose ("CPU: %1, %2 processors", c.first, c.second));
+       list<pair<string, string> > const m = mount_info ();
+       for (list<pair<string, string> >::const_iterator i = m.begin(); i != m.end(); ++i) {
+               log()->log (String::compose ("Mount: %1 %2", i->first, i->second));
+       }
        
        if (format() == 0) {
                throw MissingSettingError (_("format"));
@@ -497,6 +508,7 @@ Film::write_metadata () const
        _dci_metadata.write (f);
        f << "dci_date " << boost::gregorian::to_iso_string (_dci_date) << endl;
        f << "dcp_frame_rate " << _dcp_frame_rate << endl;
+       f << "minimum_audio_channels " << _minimum_audio_channels << endl;
        f << "width " << _size.width << endl;
        f << "height " << _size.height << endl;
        f << "length " << _length.get_value_or(0) << endl;
@@ -633,6 +645,8 @@ Film::read_metadata ()
                        _dci_date = boost::gregorian::from_undelimited_string (v);
                } else if (k == "dcp_frame_rate") {
                        _dcp_frame_rate = atoi (v.c_str ());
+               } else if (k == "minimum_audio_channels") {
+                       _minimum_audio_channels = atoi (v.c_str ());
                }
 
                _dci_metadata.read (k, v);
@@ -943,6 +957,9 @@ Film::set_content (string c)
                _content = c;
        }
 
+       /* Do this before we start using FFmpeg ourselves */
+       run_ffprobe (c, file ("ffprobe.log"), _log);
+       
        /* Reset streams here in case the new content doesn't have one or the other */
        _content_audio_stream = shared_ptr<AudioStream> ();
        _subtitle_stream = shared_ptr<SubtitleStream> ();
@@ -998,16 +1015,6 @@ Film::set_content (string c)
        if (content_type() == STILL) {
                set_use_content_audio (false);
        }
-
-#ifdef DVDOMATIC_WINDOWS
-       string ffprobe = "ffprobe.exe ";
-#else
-       string ffprobe = "ffprobe ";
-#endif
-       ffprobe += "\"" + c + "\"";
-       ffprobe += " 2> \"" + file ("ffprobe.log") + "\"";
-       log()->log (String::compose ("Probing with %1", ffprobe));
-       system (ffprobe.c_str ());
 }
 
 void
@@ -1321,6 +1328,16 @@ Film::set_dcp_frame_rate (int f)
        signal_changed (DCP_FRAME_RATE);
 }
 
+void
+Film::set_minimum_audio_channels (int c)
+{
+       {
+               boost::mutex::scoped_lock lm (_state_mutex);
+               _minimum_audio_channels = c;
+       }
+       signal_changed (MINIMUM_AUDIO_CHANNELS);
+}
+                       
 void
 Film::set_size (libdcp::Size s)
 {