X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg.cc;h=0668f9f37b381707b726cee11086ec4511845bca;hb=fea83d9ef5d02149f857a11de79ed266773fd5a1;hp=ab5148cfa0295e79f8e838282dc943974989b4db;hpb=c4403784febdbdd42e9c32e67fadb147f11fe566;p=dcpomatic.git diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index ab5148cfa..0668f9f37 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013-2016 Carl Hetherington + Copyright (C) 2013-2019 Carl Hetherington This file is part of DCP-o-matic. @@ -27,8 +27,10 @@ #include "dcpomatic_log.h" #include "ffmpeg_subtitle_stream.h" #include "ffmpeg_audio_stream.h" +#include "decrypted_ecinema_kdm.h" #include "digester.h" #include "compose.hpp" +#include "config.h" #include extern "C" { #include @@ -123,13 +125,16 @@ FFmpeg::setup_general () */ av_dict_set (&options, "analyzeduration", raw_convert (5 * 60 * 1000000).c_str(), 0); av_dict_set (&options, "probesize", raw_convert (5 * 60 * 1000000).c_str(), 0); - if (_ffmpeg_content->decryption_key()) { - av_dict_set (&options, "decryption_key", _ffmpeg_content->decryption_key()->c_str(), 0); +#ifdef DCPOMATIC_VARIANT_SWAROOP + if (_ffmpeg_content->kdm()) { + DecryptedECinemaKDM kdm (_ffmpeg_content->kdm().get(), Config::instance()->decryption_chain()->key().get()); + av_dict_set (&options, "decryption_key", kdm.key().hex().c_str(), 0); } +#endif int e = avformat_open_input (&_format_context, 0, 0, &options); if (e < 0) { - throw OpenFileError (_ffmpeg_content->path(0).string(), e, true); + throw OpenFileError (_ffmpeg_content->path(0).string(), e, OpenFileError::READ); } if (avformat_find_stream_info (_format_context, 0) < 0) { @@ -160,6 +165,11 @@ FFmpeg::setup_general () _video_stream = video_stream_undefined_frame_rate.get(); } + /* Ignore video streams with crazy frame rates. These are usually things like album art on MP3s. */ + if (_video_stream && av_q2d(av_guess_frame_rate(_format_context, _format_context->streams[_video_stream.get()], 0)) > 1000) { + _video_stream = optional(); + } + /* Hack: if the AVStreams have duplicate IDs, replace them with our own. We use the IDs so that we can cope with VOBs, in which streams move about in index but remain with the same ID in different