Quote ffprobe path.
[dcpomatic.git] / src / lib / film.cc
index a42b874e856d3470e9d7526bc8d5b6b53a9cd771..041bbc22503c624c447a0ed4e5eca3ecad16849c 100644 (file)
@@ -52,6 +52,7 @@
 #include "audio_decoder.h"
 #include "sndfile_decoder.h"
 #include "analyse_audio_job.h"
+#include "cross.h"
 
 #include "i18n.h"
 
@@ -88,8 +89,8 @@ int const Film::state_version = 4;
 Film::Film (string d, bool must_exist)
        : _use_dci_name (true)
        , _trust_content_header (true)
-       , _dcp_content_type (0)
-       , _format (0)
+       , _dcp_content_type (Config::instance()->default_dcp_content_type ())
+       , _format (Config::instance()->default_format ())
        , _scaler (Scaler::from_id ("bicubic"))
        , _trim_start (0)
        , _trim_end (0)
@@ -143,6 +144,8 @@ Film::Film (string d, bool must_exist)
        
        if (must_exist) {
                read_metadata ();
+       } else {
+               write_metadata ();
        }
 
        _log.reset (new FileLog (file ("log")));
@@ -202,6 +205,7 @@ string
 Film::video_state_identifier () const
 {
        assert (format ());
+       LocaleGuard lg;
 
        pair<string, string> f = Filter::ffmpeg_strings (filters());
 
@@ -215,6 +219,10 @@ Film::video_state_identifier () const
          << "_" << j2k_bandwidth()
          << "_" << boost::lexical_cast<int> (colour_lut());
 
+       if (trim_type() == ENCODE) {
+               s << "_" << trim_start() << "_" << trim_end();
+       }
+
        if (dcp_ab()) {
                pair<string, string> fa = Filter::ffmpeg_strings (Config::instance()->reference_filters());
                s << "ab_" << Config::instance()->reference_scaler()->id() << "_" << fa.first << "_" << fa.second;
@@ -426,6 +434,7 @@ void
 Film::write_metadata () const
 {
        boost::mutex::scoped_lock lm (_state_mutex);
+       LocaleGuard lg;
 
        boost::filesystem::create_directories (directory());
 
@@ -513,6 +522,7 @@ void
 Film::read_metadata ()
 {
        boost::mutex::scoped_lock lm (_state_mutex);
+       LocaleGuard lg;
 
        _external_audio.clear ();
        _content_audio_streams.clear ();
@@ -982,19 +992,27 @@ Film::set_content (string c)
        }
 
        /* Default format */
-       switch (content_type()) {
-       case STILL:
-               set_format (Format::from_id ("var-185"));
-               break;
-       case VIDEO:
-               set_format (Format::from_id ("185"));
-               break;
-       }
+       set_format (Config::instance()->default_format ());
 
        /* Still image DCPs must use external audio */
        if (content_type() == STILL) {
                set_use_content_audio (false);
        }
+
+#ifdef DVDOMATIC_WINDOWS
+       wchar_t dir[512];
+       GetModuleFileName (GetModuleHandle (0), dir, sizeof (dir));
+       boost::filesystem::path path_dir (dir);
+       path_dir = path_dir.parent_path ();
+       path_dir /= "ffprobe.exe";
+       string ffprobe = "\"" + path_dir.string () + "\" ";
+#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