cth103 / libdcp Goto Github PK
View Code? Open in Web Editor NEWLibrary for reading and writing Digital Cinema Packages (DCPs).
License: GNU General Public License v2.0
Library for reading and writing Digital Cinema Packages (DCPs).
License: GNU General Public License v2.0
Hi,
I reverse engineer the DCI Encryption right now, just for fun and educational purposes.
I've created a small encrypted DCP with DCP-o-Matic (thank you for that great tool btw). I was able to extract and decrypt the first encrypted frame.
Hexdump:
00000000 3a f0 b7 f5 53 49 eb b7 c0 c0 cb a5 c9 2f 35 19 |:...SI......./5.|
00000010 00 00 00 00 00 00 00 00 00 00 07 ce 00 00 04 38 |...............8|
00000020 00 00 00 00 00 00 00 00 00 03 0b 01 01 0b 01 01 |................|
00000030 0b 01 01 ff 52 00 12 01 04 00 01 01 05 03 03 00 |....R...........|
00000040 00 77 88 88 88 88 88 ff 5c 00 23 22 97 20 96 f0 |.w......\.#". ..|
00000050 96 f0 96 c0 8f 00 8f 00 8e e0 87 50 87 50 87 68 |...........P.P.h|
00000060 70 05 70 05 70 47 77 d3 77 d3 77 62 ff 55 00 13 |p.p.pGw.w.wb.U..|
00000070 00 50 00 00 00 4d 40 00 00 00 00 49 00 00 00 00 |[email protected]....|
00000080 49 ff 64 00 0a 00 01 6c 69 62 64 63 70 ff 90 00 |I.d....libdcp...|
00000090 0a 00 00 00 00 4d 40 00 03 ff 93 ef fe 2c 71 ff |.....M@......,q.|
Now I would like to export the frame as JPEG2000 / jpg image.
Is this easy possible or do I mix things here? Could you give me a hint where I can find the decoding logic for a single frame in libdcp?
Thank you
Christian
Hi Carl,
this issue is a enhancement suggestion because I know in some cases it will be useful.
According to ST 429-16:2014, CPLs can have additional composition metadatas like luminance, soundconfiguration, subtitlelanguagelist, etc. In cpl.h I can see that most of these information can be written into CPLs by using libdcp. However, it did not provide a universal method to write ExtensionMetadata
data, defined in ST 429-16:2014 4.4.2.15.
I'm sure that libdcp can write such a data because the Bv2.1 label (defined in RDD52:2020) like this:
<cpl-meta:ExtensionMetadata scope="http://isdcf.com/ns/cplmd/app">
<cpl-meta:Name>Application</cpl-meta:Name>
<cpl-meta:PropertyList>
<cpl-meta:Property>
<cpl-meta:Name>DCP Constraints Profile</cpl-meta:Name>
<cpl-meta:Value>SMPTE-RDD-52:2020-Bv2.1</cpl-meta:Value>
</cpl-meta:Property>
</cpl-meta:PropertyList>
</cpl-meta:ExtensionMetadata>
and the sign-language video language label like this:
<ExtensionMetadata scope="http://isdcf.com/2017/10/SignLanguageVideo">
<Name>Sign Language Video</Name>
<PropertyList>
<Property>
<Name>Language Tag</Name>
<Value>DESCRIPTION</Value>
</Property>
</PropertyList>
</ExtensionMetadata>
are all this kind of data, and libdcp can write them.
What I know is, for Dolby Vision DCPs played in Dolby Cinema, it also uses this kind of data to write a Dolby EDR metadata like this into the CPL:
<cpl-meta:ExtensionMetadata scope="http://www.dolby.com/schemas/2014/EDR-Metadata">
<cpl-meta:Name>Dolby EDR</cpl-meta:Name>
<cpl-meta:PropertyList>
<cpl-meta:Property>
<cpl-meta:Name>image transfer function</cpl-meta:Name>
<cpl-meta:Value>PQ10K</cpl-meta:Value>
</cpl-meta:Property>
</cpl-meta:PropertyList>
</cpl-meta:ExtensionMetadata>
As Dolby will make more theaters available in Dolby Vision, I believe if libdcp can provide a method like CPL::set_dolby_edr_metadata(), or a universal CPL::add_extensionmetadata() for some other applications, it will be very helpful.
If necessary I can provide an example CPL file. Thank you for your hard work.
../src/mono_picture_asset.cc:131:2: error: statement after '#pragma omp parallel for' must be a for loop
shared_ptr<MonoPictureAssetReader> reader = start_read ();
^
../src/mono_picture_asset.cc:141:49: error: use of undeclared identifier 'reader'
shared_ptr<const MonoPictureFrame> frame_A = reader->get_frame (i);
^
2 errors generated.
libdcp/src/mono_picture_asset.cc
Line 128 in 9a0c89b
Moving lines 131-132
shared_ptr<MonoPictureAssetReader> reader = start_read ();
shared_ptr<MonoPictureAssetReader> other_reader = other_picture->start_read ();
before the openmp statement makes it compile - but I'm not familiar with openmp, so I don't know if that would break something (but openmp wouldn't work anyways, as it doesn't compile?)
Apple's clang compiler does not support openmp out of the box, so trying to waf configure --enable-openmp
will fail at the first compiler test checking the boost version and thus giving a misleading error message Please install boost version 1.45 or higher.
(introducing a seperate check for openmp support might be an idea)
Fails:
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
using the llvm compiler provided through homebrew (brew install llvm
) would resolve the issue, but requires making sure the waf script selects the correct binary and has the right includes etc. This can be done according to what homebrew states (brew info llvm
):
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
The linker and compiler flags would have to be added to the configuration script.
Also the rather basic includes would have to be accessible by adding the headers and include path:
open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
(once the command line tools/xcode are installed)
As explained in: https://stackoverflow.com/a/48746939/1982142
Hi, I am a new user trying to convert DVDs to DCP.
My fastest computers run Arch / Manjaro (g++-12, libc 2.36-6) and libdcp fails to build.
The issues I have encountered so far are
j2k_transcode.cc needs a patch which is included in the AUR build. See attachment.
0001-fix-compile-with-openjp25.patch.txt
smpte_subtitle_asset.cc:112:83 This gives an ambiguous overload error. I am not too familiar with C++ so don't really know where to start looking. Possibly this is a gcc-12 feature? The option --force-cpp11 is not available in the newest commit.
While trying to compile libdcp I'm getting the following error:
../src/j2k_transcode.cc:318:13: error: no member named 'numgbits' in 'opj_cparameters'
parameters.numgbits = fourk ? 2 : 1;
This line was added in 9b1b653 but the only mention of numgbits
in openjpeg.h
is in the opj_tccp_info
struct, at least in https://github.com/uclouvain/openjpeg/blob/0bda7188b7b545232a341f1d978b1e4feda46fc2/src/lib/openjp2/openjpeg.h#L922. Are you perhaps using a patched version of OpenJPEG, or am I missing something else?
Hi, the previously solved ambiguos overload error in smpte_subtitle_asset.cc:112 has appeared again on my rolling release Arch system. So opening a new issue about the same problem.
I'm installing it from AUR. PKGBUILD and patch files included.
../src/smpte_subtitle_asset.cc:112:83: error: call of overloaded ‘make_shared<dcp::DecryptionContext> (boost::optional<dcp::Key>, dcp::Standard)’ is ambiguous
112 | read_mxf_resources (reader, make_shared<DecryptionContext>(optional<Key>(), Standard::SMPTE));
# Maintainer: Markus Kalb <[email protected]>
# Maintainer: Benjamin Radel <[email protected]>
# Contributor: Stefan Karner <[email protected]>
pkgname=libdcp-git
pkgver=1.8.27.r1.gb36f9bf7
pkgrel=1
_branch=v1.8.x
pkgdesc="A small C++ library which can create and read Digital Cinema Packages using JPEG2000 and WAV files"
arch=('i686' 'x86_64')
url="https://carlh.net/libdcp"
license=('GPL')
depends=('libxml++2.6' 'xmlsec' 'imagemagick' 'openjpeg2>=2.5' 'libcxml-git' 'libsigc++>=2.0' 'boost-libs>=1.72.0' 'libasdcp-cth-git')
makedepends=('git' 'python' 'boost>=1.72.0' 'gcc' 'pkg-config')
provides=('libdcp')
conflicts=('libdcp')
source=("${pkgname}::git+git://git.carlh.net/git/libdcp.git#branch=${_branch}"
"0001-fix-compile-with-openjp25.patch")
sha256sums=('SKIP'
'671046a87eaf567ca94cde72a92497239155d7cb12450ee12b41b2eed13c78fb')
pkgver() {
cd "$pkgname"
git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}
prepare() {
cd $srcdir/${pkgname}
### Patch libdcp for openjpeg>2.5 ###
for p in "${source[@]}"; do
if [[ "$p" =~ \.patch$ ]]; then
echo "Applying patch ${p##*/}"
patch -p1 -N -i "${srcdir}/${p##*/}"
fi
done
}
build() {
### Configure libdcp ###
cd "${srcdir}/${pkgname}"
python waf configure --prefix=/usr --disable-tests
python waf build
}
package() {
cd "${srcdir}/${pkgname}"
python waf install --destdir=$pkgdir
cd "${pkgdir}"
if [ -d usr/lib64 ]
then
mv usr/lib64 usr/lib
fi
}
--- a/src/j2k_transcode.cc 2022-05-17 10:07:44.525679224 +0200
+++ b/src/j2k_transcode.cc 2022-05-17 10:04:18.846330309 +0200
@@ -46,7 +46,7 @@
#include <openjpeg.h>
#include <cmath>
#include <iostream>
-
+#include <string>
using std::min;
using std::pow;
@@ -315,10 +315,13 @@
parameters.max_comp_size = parameters.max_cs_size / 1.25;
parameters.tcp_numlayers = 1;
parameters.tcp_mct = 1;
- parameters.numgbits = fourk ? 2 : 1;
+ string numgbits = "GUARD_BITS=";
+ numgbits.append(std::to_string(fourk ? 2 : 1));
+ const char* extraopt[] { numgbits.data(), nullptr };
/* Setup the encoder parameters using the current image and user parameters */
opj_setup_encoder (encoder, ¶meters, xyz->opj_image());
+ opj_encoder_set_extra_options(encoder, extraopt);
auto stream = opj_stream_default_create (OPJ_FALSE);
if (!stream) {
Hi Carl,
first things first: thanks so much for building and maintaining libdcp and friends -- highly appreciated!
Some information regarding my environment:
/usr/local/src/libcxml$ git log HEAD --oneline --no-walk
f29b074 (HEAD -> master, tag: 00.17.0, origin/master, origin/HEAD) Fix formatting of versions in .pc files (they were being written as b'0.1.2')
/usr/local/src/asdcplib$ git log HEAD --oneline --no-walk
ae75eb4 (HEAD -> carl, origin/carl) Fix writing of versions to .pc files.
/usr/local/src/libdcp$ git log HEAD --oneline --no-walk
76ff8c70 (HEAD -> main, origin/main, origin/HEAD) Remove old jpeg option reference in cscript.
$ cat /etc/os-release | head -n 1
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
/usr/local/src/ImageMagick$ git log HEAD --oneline --no-walk
fe219dc96 (HEAD -> main, origin/main, origin/HEAD) latest documentation
$ apt list --installed | grep -e g++ -e libboost -e libxml -e openssl -e sndfile -e xerces-c
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
g++-10/stable,now 10.2.1-6 amd64 [installed,automatic]
g++/stable,now 4:10.2.1-1 amd64 [installed,automatic]
libboost-date-time1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-date-time1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-filesystem1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-filesystem1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-iostreams1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-locale1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-log1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-nowide1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-program-options1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-regex1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-serialization1.74-dev/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-serialization1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-system1.74-dev/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-system1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-test1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libboost-test1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost-thread1.74.0/stable,now 1.74.0-9 amd64 [installed,automatic]
libboost1.74-dev/stable,now 1.74.0-9 amd64 [installed]
libgnutls-openssl27/stable,stable-security,now 3.7.1-5+deb11u2 amd64 [installed,automatic]
libsndfile1-dev/stable,now 1.0.31-2 amd64 [installed]
libsndfile1/stable,now 1.0.31-2 amd64 [installed,automatic]
libxerces-c-dev/stable,now 3.2.3+debian-3 amd64 [installed]
libxerces-c3.2/stable,now 3.2.3+debian-3 amd64 [installed]
libxml++2.6-2v5/stable,now 2.40.1-3 amd64 [installed]
libxml++2.6-dev/stable,now 2.40.1-3 amd64 [installed]
libxml2-dev/stable-security,now 2.9.10+dfsg-6.7+deb11u3 amd64 [installed,automatic]
libxml2/stable-security,now 2.9.10+dfsg-6.7+deb11u3 amd64 [installed,automatic]
libxmlsec1-dev/stable,now 1.2.31-1 amd64 [installed]
libxmlsec1-gcrypt/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-gnutls/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-nss/stable,now 1.2.31-1 amd64 [installed,automatic]
libxmlsec1-openssl/stable,now 1.2.31-1 amd64 [installed]
libxmlsec1/stable,now 1.2.31-1 amd64 [installed]
openssl/stable,stable-security,now 1.1.1n-0+deb11u3 amd64 [installed,automatic]
As per the title of this issue, I'm running into problems if using read_dcp
against a DCP which contains a sound reel:
$ /usr/local/src/libdcp/build/examples/read_dcp
Segmentation fault (core dumped)
The core file is attached; I needed to add a .txt
extension to overcome GitHubs limitation regarding which files they allow to be uploaded. strace
shows what seems to be a problem while seeking into the audio reel. The relevant log is attached as well. Also, the bt
of gdb
is attached. There is also a screenshot attached of the gdb
output with colors included.
core-read_dcp.51288.dev.1670857179.txt
strace.log
gdb.log
One problem seems to be:
Thread 1 (Thread 0x7fe53b1ebe80 (LWP 51288)):
#0 0x00007fe53e77e899 in ASDCP::Dictionary::Type(ASDCP::MDD_t) const (this=0x0, type_id=ASDCP::MDD_SoundfieldGroupLabelSubDescriptor) at ../src/Dict.cpp:245
__PRETTY_FUNCTION__ = "const ASDCP::MDDEntry& ASDCP::Dictionary::Type(ASDCP::MDD_t) const"
rii = non-dereferenceable iterator for associative container
Again, as per the title of this issue, read_dcp
works with a DCP which doesn't include a sound reel:
$ /usr/local/src/libdcp/build/examples/read_dcp
DCP is not encrypted.
DCP has 1 CPLs.
DCP has 2 assets.
CPL
cpl_c966c3f9-0466-408f-8cbb-f1047fed2a75.xml
2D picture
j2c_03b04c59-3f09-465c-815e-98a57b6ac3d3.mxf
In contrast, dcpinfo
is able to handle both DCPs:
$ dcpinfo /usr/local/share/SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
DCP: /usr/local/share/SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
CPL: SilentDCP_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV c0283c7e-0778-491c-9ce9-94802f095804
Reel 1
Picture ID: a5803429-7824-4780-8652-c8dd833b1be4 entry 0 duration 1906 (00:01:19:10) intrinsic 1906
Picture: 2048x858
Sound ID: 57d97d51-0bb1-4756-b413-8e9140602ccc entry 0 duration 1906 intrinsic 1906
Sound: 6 channels at 48000Hz
Total: 00:01:19:10
$ dcpinfo /usr/local/share/DCPWithoutSoundReel_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
DCP: /usr/local/share/DCPWithoutSoundReel_SHR_S-239_XX-XX_INT_00_2K_IFB_20221209_IFB_SMPTE_OV/
CPL: MBMV_SHR-1-25_S_FR-XX_51_2K_20221004_SMPTE_OV c966c3f9-0466-408f-8cbb-f1047fed2a75
Reel 1
Picture ID: 03b04c59-3f09-465c-815e-98a57b6ac3d3 entry 0 duration 15083 (00:10:03:08) intrinsic 15083
Picture: 2048x858
Total: 00:10:03:08
In case that's helpful, I'm able to provide both DCPs, and also whatever else might be helpful in debugging this.
Any ideas, pointers, things I could try?
Thanks again & all the best!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.