sandflow / ffmpeg-imf Goto Github PK
View Code? Open in Web Editor NEWAdds an IMF demuxer to FFMPEG (https://github.com/sandflow/ffmpeg-imf/blob/develop/README-IMF.md)
License: Other
Adds an IMF demuxer to FFMPEG (https://github.com/sandflow/ffmpeg-imf/blob/develop/README-IMF.md)
License: Other
I have an IMF package with videos and audios and of course the CPL.
Video file is a MJPEG2000 BT709 SDR 10bit muxed in mxf
The audio files are PCM lossless 24bit 48'000Hz muxed as .mxf
To differentiate them, each one has audio tagging inside, so if I use Mediainfo I can see for instance:
General | |||
Complete name : | Test.mxf | ||
Format : | MXF | ||
Format version : | 1.3 | ||
Format profile : | OP-1a | ||
Format settings : | Closed / Complete | ||
File size : | 6.10 GiB | ||
Duration : | 2 h 6 min | ||
Overall bit rate : | 6 912 kb/s | ||
Package name : | Material Package / File Package: SMPTE 382M clip wrapping of wave audio | ||
Encoded date : | 2022-05-03 22:48:00.768 | ||
Writing application : | Rohde and Schwarz Clipster 6.9.1.0.1 | ||
Writing library : | Windows 8 (64-bit) 2.38.0.20411.1 |
Audio | |||
ID : | 2 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Clip (BWF) | ||
Codec ID : | 0D01030102060200 | ||
Duration : | 2 h 6 min | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Channel layout : | L R C LFE Ls Rs | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 6.10 GiB (100%) | ||
Title : | FP Sound track | ||
Language : | Italian | ||
Locked : | Yes | ||
MCA Title : | MCA Title | ||
MCA Title Version : | MCA Title Version | ||
MCA Audio Content Kind : | MCA Audio Content Kind | ||
MCA Audio Element Kind : | MCA Audio Element Kind |
Other #1 | |||
ID : | 1-Material | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:59:30:00 | ||
Time code settings : | Material Package | ||
Time code, striped : | Yes | ||
Title : | Timecode track |
Other #2 | |||
ID : | 1-Source | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:59:30:00 | ||
Time code settings : | Source Package | ||
Time code, striped : | Yes | ||
Title : | Timecode track |
As you can see, there's the language tagging:
Language : Italian
same goes for other tracks that might have a different language like English:
General | |||
Complete name : | Test2.mxf | ||
Format : | MXF | ||
Format version : | 1.3 | ||
Format profile : | OP-1a | ||
Format settings : | Closed / Complete | ||
File size : | 6.10 GiB | ||
Duration : | 2 h 6 min | ||
Overall bit rate : | 6 912 kb/s | ||
Package name : | Material Package / File Package: SMPTE 382M clip wrapping of wave audio | ||
Encoded date : | 2022-05-03 22:48:00.768 | ||
Writing application : | Rohde and Schwarz Clipster 6.9.1.0.1 | ||
Writing library : | Windows 8 (64-bit) 2.38.0.20411.1 |
Audio | |||
ID : | 2 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Clip (BWF) | ||
Codec ID : | 0D01030102060200 | ||
Duration : | 2 h 6 min | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Channel layout : | L R C LFE Ls Rs | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 6.10 GiB (100%) | ||
Title : | FP Sound track | ||
Language : | English | ||
Locked : | Yes |
Other #1 | |||
ID : | 1-Material | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:59:30:00 | ||
Time code settings : | Material Package | ||
Time code, striped : | Yes | ||
Title : | Timecode track |
Other #2 | |||
ID : | 1-Source | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:59:30:00 | ||
Time code settings : | Source Package | ||
Time code, striped : | Yes | ||
Title : | Timecode track |
so:
Language : English
however when I do:
ffmpeg.exe -f imf -i "D:\Masterfiles\CPL_IMF.xml" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -c:v copy -c:a copy -f mxf -y "D:\Masterfiles\test.mxf"
pause
FFMpeg outputs an error in the language tagging, namely:
[imf @ 000001d283a12a00] Opening 'D:\Masterfiles\ASSETMAP.xml' for reading
[mxf @ 000001d283a689c0] local tag 0xdff5 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff4 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff3 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff2 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff5 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff4 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff3 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff2 with 0 size
The whole command line output is:
H:\MJPEG2000 DCP Hardsubber (x86) - Final>ffmpeg.exe -f imf -i "D:\Masterfiles\CPL_IMF.xml" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -c:v copy -c:a copy -f mxf -y "D:\Masterfiles\test.mxf"
ffmpeg version git-2022-01-28-f581139854-20220128 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 11.2.0 (crosstool-NG 1.24.0.498_5075e1f)
configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librist --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20220128
libavutil 57. 18.100 / 57. 18.100
libavcodec 59. 20.100 / 59. 20.100
libavformat 59. 17.101 / 59. 17.101
libavdevice 59. 5.100 / 59. 5.100
libavfilter 8. 25.100 / 8. 25.100
libswscale 6. 5.100 / 6. 5.100
libswresample 4. 4.100 / 4. 4.100
libpostproc 56. 4.100 / 56. 4.100
IMF CPL ContentTitle: Hitch
IMF CPL Id: urn:uuid:e945442e-aa35-4961-9b74-7c624fb9d232
[imf @ 000001d283a12a00] Opening 'D:\Masterfiles\ASSETMAP.xml' for reading
[mxf @ 000001d283a689c0] local tag 0xdff5 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff4 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff3 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff2 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff5 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff4 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff3 with 0 size
[mxf @ 000001d283a689c0] local tag 0xdff2 with 0 size
Input #0, imf, from 'D:\Masterfiles\CPL_IMF.xml':
Duration: 02:06:22.49, start: 0.000000, bitrate: 0 kb/s
Stream #0:0: Video: jpeg2000, yuv422p10le(tv, bt709, progressive), 3840x2160, 23.98 tbr, 23.98 tbn
Stream #0:1: Audio: pcm_s24le, 48000 Hz, downmix, s32 (24 bit), 2304 kb/s
Stream #0:2: Audio: pcm_s24le, 48000 Hz, downmix, s32 (24 bit), 2304 kb/s
Stream #0:3: Audio: pcm_s24le, 48000 Hz, 5.1(side), s32 (24 bit), 6912 kb/s
Stream #0:4: Audio: pcm_s24le, 48000 Hz, 5.1(side), s32 (24 bit), 6912 kb/s
Output #0, mxf, to 'D:\Masterfiles\test.mxf':
Metadata:
encoder : Lavf59.17.101
Stream #0:0: Video: jpeg2000, yuv422p10le(tv, bt709, progressive), 3840x2160, q=2-31, 23.98 tbr, 23.98 tbn
Stream #0:1: Audio: pcm_s24le, 48000 Hz, downmix, s32 (24 bit), 2304 kb/s (default)
Stream #0:2: Audio: pcm_s24le, 48000 Hz, downmix, s32 (24 bit), 2304 kb/s
Stream #0:3: Audio: pcm_s24le, 48000 Hz, 5.1(side), s32 (24 bit), 6912 kb/s
Stream #0:4: Audio: pcm_s24le, 48000 Hz, 5.1(side), s32 (24 bit), 6912 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (copy)
Stream #0:1 -> #0:1 (copy)
Stream #0:2 -> #0:2 (copy)
Stream #0:3 -> #0:3 (copy)
Stream #0:4 -> #0:4 (copy)
Press [q] to stop, [?] for help
frame= 3987 fps=793 q=-1.0 size= 3678208kB time=00:02:46.29 bitrate=181199.6kbits/s speed=33.1x
and indeed the final file lacks the audio tagging:
General | |||
Complete name : | D:\Masterfiles\test.mxf | ||
Format : | MXF | ||
Format version : | 1.3 | ||
Format profile : | OP-1a | ||
Format settings : | Closed / Complete | ||
File size : | 3.64 GiB | ||
Duration : | 2 min 52 s | ||
Overall bit rate : | 181 Mb/s | ||
Encoded date : | 0-00-00 00:00:00.000 | ||
Writing application : | FFmpeg OP1a Muxer 59.17.101.0.0 | ||
Writing library : | Lavf (mingw32) 59.17.101.0.0 |
Video | |||
ID : | 2 | ||
Format : | JPEG 2000 | ||
Format profile : | BCS@L5 | ||
Format settings, wrapping mode : | Frame | ||
Codec ID : | 0D010301020C0100-0401020203010100 | ||
Duration : | 2 min 52 s | ||
Bit rate : | 163 Mb/s | ||
Width : | 3 840 pixels | ||
Height : | 2 160 pixels | ||
Display aspect ratio : | 16:9 | ||
Frame rate : | 23.976 (24000/1001) FPS | ||
Color space : | YUV | ||
Chroma subsampling : | 4:2:2 | ||
Bit depth : | 10 bits | ||
Scan type : | Progressive | ||
Bits/(Pixel*Frame) : | 0.819 | ||
Stream size : | 3.27 GiB (90%) | ||
Color range : | Limited | ||
Color primaries : | BT.709 | ||
Transfer characteristics : | BT.709 | ||
Matrix coefficients : | BT.709 |
Audio #1 | |||
ID : | 3 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Frame (AES) | ||
Codec ID : | 0D01030102060300 | ||
Duration : | 2 min 52 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 2 304 kb/s | ||
Channel(s) : | 2 channels | ||
Sampling rate : | 48.0 kHz | ||
Frame rate : | 23.976 FPS (2002 SPF) | ||
Bit depth : | 24 bits | ||
Stream size : | 47.4 MiB (1%) | ||
Locked : | Yes |
Audio #2 | |||
ID : | 4 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Frame (AES) | ||
Codec ID : | 0D01030102060300 | ||
Duration : | 2 min 52 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 2 304 kb/s | ||
Channel(s) : | 2 channels | ||
Sampling rate : | 48.0 kHz | ||
Frame rate : | 23.976 FPS (2002 SPF) | ||
Bit depth : | 24 bits | ||
Stream size : | 47.4 MiB (1%) | ||
Locked : | Yes |
Audio #3 | |||
ID : | 5 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Frame (AES) | ||
Codec ID : | 0D01030102060300 | ||
Duration : | 2 min 52 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Sampling rate : | 48.0 kHz | ||
Frame rate : | 23.976 FPS (2002 SPF) | ||
Bit depth : | 24 bits | ||
Stream size : | 142 MiB (4%) | ||
Locked : | Yes |
Audio #4 | |||
ID : | 6 | ||
Format : | PCM | ||
Format settings : | Little | ||
Format settings, wrapping mode : | Frame (AES) | ||
Codec ID : | 0D01030102060300 | ||
Duration : | 2 min 52 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Sampling rate : | 48.0 kHz | ||
Frame rate : | 23.976 FPS (2002 SPF) | ||
Bit depth : | 24 bits | ||
Stream size : | 142 MiB (4%) | ||
Locked : | Yes |
Other #1 | |||
ID : | 1-Material | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:00:00:00 | ||
Time code settings : | Material Package | ||
Time code, striped : | Yes |
Other #2 | |||
ID : | 1-Source | ||
Type : | Time code | ||
Format : | MXF TC | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:00:00:00 | ||
Time code settings : | Source Package | ||
Time code, striped : | Yes |
Other #3 | |||
Type : | Time code | ||
Format : | SMPTE TC | ||
Muxing mode : | SDTI | ||
Frame rate : | 24.000 FPS | ||
Time code of first frame : | 00:00:00:00 |
Changing the remux to mov doesn't improve things either:
ffmpeg.exe -f imf -i "D:\Masterfiles\CPL_IMF.xml" -map 0:0 -map 0:1 -map 0:2 -map 0:3 -map 0:4 -c:v copy -c:a copy -f mov -y "D:\Masterfiles\test.mov"
pause
General | |||
Complete name : | D:\Masterfiles\test.mov | ||
Format : | MPEG-4 | ||
Format profile : | QuickTime | ||
Codec ID : | qt 0000.02 (qt ) | ||
File size : | 2.06 GiB | ||
Duration : | 1 min 42 s | ||
Overall bit rate mode : | Variable | ||
Overall bit rate : | 173 Mb/s | ||
Writing application : | Lavf59.17.101 |
Video | |||
ID : | 1 | ||
Format : | JPEG 2000 | ||
Codec ID : | mjp2 | ||
Duration : | 1 min 42 s | ||
Bit rate mode : | Variable | ||
Bit rate : | 155 Mb/s | ||
Width : | 3 840 pixels | ||
Height : | 2 160 pixels | ||
Display aspect ratio : | 16:9 | ||
Frame rate mode : | Constant | ||
Frame rate : | 23.976 (24000/1001) FPS | ||
Color space : | YUV | ||
Scan type : | Progressive | ||
Bits/(Pixel*Frame) : | 0.778 | ||
Stream size : | 1.84 GiB (89%) | ||
Color primaries : | BT.709 | ||
Transfer characteristics : | BT.709 | ||
Matrix coefficients : | BT.709 |
Audio #1 | |||
ID : | 2 | ||
Format : | PCM | ||
Format settings : | Little / Signed | ||
Codec ID : | in24 | ||
Duration : | 1 min 42 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 2 304 kb/s | ||
Channel(s) : | 2 channels | ||
Channel layout : | Lt Rt | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 28.1 MiB (1%) | ||
Default : | Yes | ||
Alternate group : | 1 |
Audio #2 | |||
ID : | 3 | ||
Format : | PCM | ||
Format settings : | Little / Signed | ||
Codec ID : | in24 | ||
Duration : | 1 min 42 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 2 304 kb/s | ||
Channel(s) : | 2 channels | ||
Channel layout : | Lt Rt | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 28.1 MiB (1%) | ||
Default : | No | ||
Alternate group : | 1 |
Audio #3 | |||
ID : | 4 | ||
Format : | PCM | ||
Format settings : | Little / Signed | ||
Codec ID : | in24 | ||
Duration : | 1 min 42 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Channel layout : | L R C LFE Ls Rs | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 84.3 MiB (4%) | ||
Default : | No | ||
Alternate group : | 1 |
Audio #4 | |||
ID : | 5 | ||
Format : | PCM | ||
Format settings : | Little / Signed | ||
Codec ID : | in24 | ||
Duration : | 1 min 42 s | ||
Bit rate mode : | Constant | ||
Bit rate : | 6 912 kb/s | ||
Channel(s) : | 6 channels | ||
Channel layout : | L R C LFE Ls Rs | ||
Sampling rate : | 48.0 kHz | ||
Bit depth : | 24 bits | ||
Stream size : | 84.2 MiB (4%) | ||
Default : | No | ||
Alternate group : | 1 |
libavformat/tests/imf.c:204:12: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
static int test_cpl_parsing() {
^~~~~~~~~~~~~~~~
libavformat/tests/imf.c:283:12: warning: function declaration isn’t a prototype [-Wstrict-prototypes]
static int test_asset_map_parsing() {
^~~~~~~~~~~~~~~~~~~~~~
The CPL at https://github.com/sandflow/ffmpeg-imf/blob/develop/libavformat/tests/imf.c does not use namespaces
The soundfields specified in the following specifications should be supported:
Soundfield | Channels | ||
---|---|---|---|
✅ | 5.1 | L, C, R, Ls, Rs, LFE | |
✅ | 7.1DS | L, C, R, Lss, Rss, Lrs, Rrs, LFE | |
✅ | Standard Stereo | L, R | |
❌ | Lt-Rt | Lt, Rt | Mapped as Stereo |
✅ | Hearing Accessibility | HI | Mapped as Mono, set AVAudioServiceType |
✅ | Visual Accessibility | VIN | Mapped as Mono, set AVAudioServiceType |
✅ | 1.0 Monaural | C |
Lower priority
Soundfield | Channels | ||
---|---|---|---|
✅ | 7.1SDS | L, Lc, C, Rc, R, Ls, Rs, LFE | |
✅ | 6.1 | L, R, C, Lss, Rss, Cs, LFE | |
✅ | 3.0 | L, C, R | |
✅ | 4.0 | L, C, R, S | |
✅ | 5.0 | L, C, R, Ls, Rs | |
✅ | 6.0 | L, C, R, Ls, Rs, Cs | |
✅ | 7.0DS | L, C, R, Lss, Rss, Rls, Rrs | |
✅ | 5.1EX | L, C, R, Lst, Rst, LFE | |
❌ | Dual Mono | M1, M2 | Mapped as Stereo |
❌ | 9.1OH | L, C, R, Lss, Rss, Lrs, Rrs, LFE, Lts, Rts | |
❌ | 9.1HT | L, C, R, Ls, Rs, LFE, Lh, Rh, Lsh, Rsh | |
❌ | 11.1HT | L, C, R, Ls, Rs, LFE, Lh, Ch, Rh, Lsh, Rsh, Ts | |
❌ | 13.1HT | L, C, R, Lss, Rss, Lrs, Rrs, LFE, Lh, Ch, Rh, Lsh, Rsh, Ts | |
❌ | 15.1HT | L, C, R, Lss, Rss, Lrs, Rrs, LFE, Lh, Ch, Rh, Lssh, Rssh, Lrsh, Rrsh, Ts | unable to generate a sample with asdcplib |
Headers should include:
* This file is part of FFmpeg.
Guards should be of the form:
#ifndef AVFORMAT_*
instead of
#ifndef AVCODEC_*
mxf_get_wrapping_kind()
at mxfdec.c
assumes that wrapping is determined based on whether byte wrapping_indicator_pos
in the Essence Container UL is 0x01
or 0x02
.
In the case of MXFGCP1FrameWrappedPictureElement
, there is no such byte.
This results in the duration of the essence container being miscomputed.
ffmpeg-imf/libavformat/mxfdec.c
Line 1474 in 477f975
Currently FFmpeg accepts an Asset Map as an input.
Instead the input file to the FFMPEG command line should be the CPL, and one of the following two should be provided as an additional command line option:
ffmpeg -i cpl.xml -assetmap <path to ASSETMAP>,<path to ASSETMAP>
ffmpeg-imf/libavformat/imfdec.c
Line 123 in 5cce96f
Errors during CPL parsing should be logged using av_log()
TEST lavf-mxf
--- ./tests/ref/lavf/mxf 2021-08-11 19:43:05.350780751 +0000
+++ tests/data/fate/lavf-mxf 2021-08-11 19:51:47.523970434 +0000
@@ -1,9 +1,9 @@
8938d5c4a396ff1b24d10d4f917ae1c9 *tests/data/lavf/lavf.mxf
526393 tests/data/lavf/lavf.mxf
-tests/data/lavf/lavf.mxf CRC=0x8dddfaab
+tests/data/lavf/lavf.mxf
93ea2cfdf5dda7fffdc0d2fdcfb6a9a4 *tests/data/lavf/lavf.mxf
561721 tests/data/lavf/lavf.mxf
-tests/data/lavf/lavf.mxf CRC=0x96ff1b48
+tests/data/lavf/lavf.mxf
87bdf844ae34bcc758e44419e80177a0 *tests/data/lavf/lavf.mxf
526393 tests/data/lavf/lavf.mxf
-tests/data/lavf/lavf.mxf CRC=0x8dddfaab
+tests/data/lavf/lavf.mxf
Test lavf-mxf failed. Look at tests/data/fate/lavf-mxf.err for details.
make: *** [fate-lavf-mxf] Error 1
tests/Makefile:255: recipe for target 'fate-lavf-mxf' failed
Error: Process completed with exit code 2.
Th AssetMap must contain a URL that points to any and all CPLs contained in an IMP. Therefore providing a URL to the CPL is duplicative since a URL is already provided to the AssetMap.
Recommend the following command line syntax:
ffmpeg -i <assetmap-url> ...
ffempeg should:
<Asset>
elements that contains <PackingList>true</PackingList>
<Asset>
elements that contain a <Type>
element with a value application/xml
When multiple CPLs are discovered, ffempg should treat each CPL exactly how it handles the case of multiple input streams provided with multiple -i
options.
Just wondering if this works on DCPs as well, considering they are a subset of IMF?
A IMF Composition can contain multiple soundfields. The user should have the ability to select which soundfield is used for processing, e.g.:
./ffmpeg -i CPL_da656e28-ae37-4734-8b8f-c5b2aa187783.xml -assetmaps ASSETMAP.xml -soundfield sg51 out.mp4
Structures to store the AssetMap source paths (or URLs, etc.), mapped by UUID, and resulting from the IMF AssetMap parsing.
Emit information on the CPL and its virtual tracks
ffmpeg-imf/libavformat/imf_cpl.c
Line 510 in f2e61d9
Unknown sequences should be ignored instead.
FFMPEG supports custom IO callbacks using AVFormatContext's io_open and io_close. This provides a place that users can support custom protocols, HTTP proxies, add additional HTTP args etc. The IMF code is bypassing these callbacks by calling avio_open2 directly, and not copying the parent contexts io_open/io_close when opening the tracks.
Additionally, the http options set in AVFormatContext is not propagated to the track_resources, meaning settings things like rw_timeout and http_proxy in the options will not work.
In my local ffmpeg I have tested a fix to both these issues (diff posted below).
If you would like, I can create a PR with these changes (but I don't believe I have permissions).
diff --git a/libavformat/imfdec.c b/libavformat/imfdec.c
index 1dee2ba8bb..4e76f862ed 100644
--- a/libavformat/imfdec.c
+++ b/libavformat/imfdec.c
@@ -246,7 +246,7 @@ static int parse_assetmap(AVFormatContext *s, const char *url, AVIOContext *in)
close_in = 1;
av_dict_copy(&opts, c->avio_opts, 0);
- ret = avio_open2(&in, url, AVIO_FLAG_READ, c->interrupt_callback, &opts);
+ ret = s->io_open(s, &in, url, AVIO_FLAG_READ, &opts);
av_dict_free(&opts);
if (ret < 0)
return ret;
@@ -294,8 +294,10 @@ static IMFAssetLocator *find_asset_map_locator(IMFAssetLocatorMap *asset_map, UU
}
static int open_track_resource_context(AVFormatContext *s, IMFVirtualTrackResourcePlaybackCtx *track_resource) {
+ IMFContext *c = s->priv_data;
int ret = 0;
int64_t entry_point;
+ AVDictionary *opts = NULL;
if (!track_resource->ctx) {
track_resource->ctx = avformat_alloc_context();
@@ -306,7 +308,17 @@ static int open_track_resource_context(AVFormatContext *s, IMFVirtualTrackResour
return ret;
}
- ret = avformat_open_input(&track_resource->ctx, track_resource->locator->absolute_uri, NULL, NULL);
+ track_resource->ctx->io_open = s->io_open;
+ track_resource->ctx->io_close = s->io_close;
+ track_resource->ctx->flags |= s->flags & ~AVFMT_FLAG_CUSTOM_IO;
+
+ if ((ret = ff_copy_whiteblacklists(track_resource->ctx, s)) < 0) {
+ goto cleanup;
+ }
+
+ av_dict_copy(&opts, c->avio_opts, 0);
+ ret = avformat_open_input(&track_resource->ctx, track_resource->locator->absolute_uri, NULL, &opts);
+ av_dict_free(&opts);
if (ret < 0) {
av_log(s, AV_LOG_ERROR, "Could not open %s input context: %s\n", track_resource->locator->absolute_uri, av_err2str(ret));
goto cleanup;
@@ -441,6 +453,28 @@ static int set_context_streams_from_tracks(AVFormatContext *s) {
return ret;
}
+static int save_avio_options(AVFormatContext *s)
+{
+ IMFContext *c = s->priv_data;
+ static const char * const opts[] = {
+ "headers", "http_proxy", "user_agent", "cookies", "referer", "rw_timeout", "icy", NULL };
+ const char * const * opt = opts;
+ uint8_t *buf;
+ int ret = 0;
+
+ while (*opt) {
+ if (av_opt_get(s->pb, *opt, AV_OPT_SEARCH_CHILDREN | AV_OPT_ALLOW_NULL, &buf) >= 0) {
+ ret = av_dict_set(&c->avio_opts, *opt, buf,
+ AV_DICT_DONT_STRDUP_VAL);
+ if (ret < 0)
+ return ret;
+ }
+ opt++;
+ }
+
+ return ret;
+}
+
static int open_cpl_tracks(AVFormatContext *s) {
IMFContext *c = s->priv_data;
int32_t track_index = 0;
@@ -470,7 +504,10 @@ static int imf_read_header(AVFormatContext *s) {
char *asset_map_path;
int ret;
+ c->interrupt_callback = &s->interrupt_callback;
c->base_url = av_dirname(av_strdup(s->url));
+ if ((ret = save_avio_options(s)) < 0)
+ goto fail;
av_log(s, AV_LOG_DEBUG, "start parsing IMF CPL: %s\n", s->url);
MXFDescriptor
in mxfdec.c does not expose MCA metadata (ST 377-4)
ffmpeg-imf/libavformat/mxfdec.c
Line 184 in 2422678
This is metadata is required for #10
Here is the free error if the input is an ASSETMAP, not an CPL
./dist/bin/ffmpeg -i ASSETMAP.xml output.mp4
ffmpeg version N-102613-g9e8926fcae Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 12.0.5 (clang-1205.0.22.9)
configuration: --enable-libxml2 --enable-static --prefix=/Users/marco/dev/sandflow/ffmpeg/dist
libavutil 57. 0.100 / 57. 0.100
libavcodec 59. 1.100 / 59. 1.100
libavformat 59. 2.100 / 59. 2.100
libavdevice 59. 0.100 / 59. 0.100
libavfilter 8. 0.101 / 8. 0.101
libswscale 6. 0.100 / 6. 0.100
libswresample 4. 0.100 / 4. 0.100
The root element of the CPL is not CompositionPlaylist
Cannot parse IMF CPL
ffmpeg(59764,0x11f804e00) malloc: *** error for object 0x7fe956d05540: pointer being freed was not allocated
ffmpeg(59764,0x11f804e00) malloc: *** set a breakpoint in malloc_error_break to debug
[1] 59764 abort ./dist/bin/ffmpeg -i ASSETMAP.xml output.mp4
CPLs can be written to files that don't end in .xml
. Additionally, URLs may contain query parameters such that the URL does not end in .xml
.
Relying on Content-Type
may be a better option for CPLs referenced by URL.
AssetMaps traditionally carry relative URLs. The Path elements should be resolved relative to the URL at which the AssetMap was originally found.
This behavior does not currently seem to be supported in FFmpeg.
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.