X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_ecinema.cc;h=152194c482f415560320a4feaae9fb0816770431;hp=f91dbb584271db03555155bbee03f80c5f0afa82;hb=5eb8b5c3a1566aef638e9d9df03b88d320735092;hpb=4d11fe7cea71b0564df9a21a3cc706509d12b0d1 diff --git a/src/tools/dcpomatic_ecinema.cc b/src/tools/dcpomatic_ecinema.cc index f91dbb584..152194c48 100644 --- a/src/tools/dcpomatic_ecinema.cc +++ b/src/tools/dcpomatic_ecinema.cc @@ -29,6 +29,8 @@ #include "lib/transcode_job.h" #include "lib/ffmpeg_encoder.h" #include "lib/signal_manager.h" +#include "lib/video_content.h" +#include "lib/ratio.h" #include extern "C" { #include @@ -50,22 +52,27 @@ using std::ofstream; using boost::optional; using boost::shared_ptr; -static void convert_dcp (boost::filesystem::path input, boost::filesystem::path output_file, boost::optional kdm, int crf); -static void convert_ffmpeg (boost::filesystem::path input, boost::filesystem::path output_file, string format, boost::optional kdm); -static void write_kdm (string id, string name, dcp::Key key, optional kdm); +static void convert_dcp ( + boost::filesystem::path input, + boost::filesystem::path output_file, + boost::optional kdm, + int crf + ); +static void convert_ffmpeg (boost::filesystem::path input, boost::filesystem::path output_file, string format); +static void write_kdm (string id, boost::filesystem::path name, dcp::Key key); static void help (string n) { - cerr << "Syntax: " << n << " [OPTION] \n" + cerr << "Syntax: " << n << " [OPTION] |\n" << " -v, --version show DCP-o-matic version\n" << " -h, --help show this help\n" << " -o, --output output directory\n" << " -f, --format output format (mov or mp4; defaults to mov)\n" - << " -k, --kdm KDM output filename (defaults to stdout)\n" + << " -k, --kdm DCP KDM filename (if required)\n" << " -c, --crf quality (CRF) when transcoding from DCP (0 is best, 51 is worst, defaults to 23)\n" << "\n" - << " is the unencrypted .mp4 file.\n"; + << " is an unencrypted .mp4 file; is a DCP directory.\n"; } int @@ -156,12 +163,12 @@ main (int argc, char* argv[]) /* Assume input is a DCP */ convert_dcp (input, output_file, kdm, crf); } else { - convert_ffmpeg (input, output_file, *format, kdm); + convert_ffmpeg (input, output_file, *format); } } static void -convert_ffmpeg (boost::filesystem::path input, boost::filesystem::path output_file, string format, optional kdm) +convert_ffmpeg (boost::filesystem::path input, boost::filesystem::path output_file, string format) { AVFormatContext* input_fc = avformat_alloc_context (); if (avformat_open_input(&input_fc, input.string().c_str(), 0, 0) < 0) { @@ -255,48 +262,51 @@ convert_ffmpeg (boost::filesystem::path input, boost::filesystem::path output_fi avformat_free_context (input_fc); avformat_free_context (output_fc); - write_kdm (id, output_file.filename().string(), key, kdm); + write_kdm (id, output_file, key); } static void -write_kdm (string id, string name, dcp::Key key, optional kdm) +write_kdm (string id, boost::filesystem::path name, dcp::Key key) { - DecryptedECinemaKDM decrypted_kdm (id, name, key, optional(), optional()); + DecryptedECinemaKDM decrypted_kdm (id, name.filename().string(), key, optional(), optional()); EncryptedECinemaKDM encrypted_kdm = decrypted_kdm.encrypt (Config::instance()->decryption_chain()->leaf()); - if (kdm) { - ofstream f(kdm->c_str()); - f << encrypted_kdm.as_xml() << "\n"; - } else { - cout << encrypted_kdm.as_xml() << "\n"; - } + ofstream f(string(name.string() + ".xml").c_str()); + f << encrypted_kdm.as_xml() << "\n"; } static void -convert_dcp (boost::filesystem::path input, boost::filesystem::path output_file, optional kdm, int crf) +convert_dcp ( + boost::filesystem::path input, boost::filesystem::path output_file, optional kdm, int crf + ) { shared_ptr film (new Film(boost::optional())); shared_ptr dcp (new DCPContent(input)); film->examine_and_add_content (dcp); + if (kdm) { + dcp->add_kdm (dcp::EncryptedKDM(dcp::file_to_string(*kdm))); + } JobManager* jm = JobManager::instance (); while (jm->work_to_do ()) { while (signal_manager->ui_idle ()) {} - dcpomatic_sleep (1); + dcpomatic_sleep_seconds (1); } DCPOMATIC_ASSERT (!jm->errors()); + film->set_container (Ratio::nearest_from_ratio(dcp->video->size().ratio())); + string id = dcp::make_uuid (); dcp::Key key (AES_CTR_KEY_SIZE); shared_ptr job (new TranscodeJob(film)); job->set_encoder ( shared_ptr( - new FFmpegEncoder(film, job, output_file, EXPORT_FORMAT_H264, false, false, crf, key, id) + new FFmpegEncoder(film, job, output_file, EXPORT_FORMAT_H264_PCM, false, false, crf, key, id) ) ); jm->add (job); show_jobs_on_console (true); - write_kdm (id, output_file.filename().string(), key, kdm); + write_kdm (id, output_file, key); }