2

I have MPEG dash video files created with Bento4 mp4-dash.py. The files have encription, but I have the MPD and the audio and video segments. I am trying to get my original MP4 file back from those segments without success.

My tentatives: 1) Convert directly from the MPD file:

ffmpeg -i stream.mpd  -c copy output.mp4

2) Concatenate audio and video and use ffmpeg to merge them:

cat videos/init.mp4 $(ls -1v videos/seg*.m4s) > video.mp4
cat audios/init.mp4 $(ls -1v audios/seg*.m4s) > audio.m4a
ffmpeg -i video.mp4 -i audio.m4a -c copy output.mp4

The error:

ffmpeg version 4.2.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8.3.0 (Alpine 8.3.0)
  configuration: --pkg-config-flags=--static --extra-cflags=-fopenmp --extra-ldflags='-static -fopenmp' --toolchain=hardened --disable-debug --disable-shared --disable-ffplay --enable-static --enable-gpl --enable-nonfree --enable-openssl --enable-iconv --enable-libxml2 --enable-libmp3lame --enable-libfdk-aac --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvpx --enable-libx264 --enable-libx265 --enable-libwebp --enable-libwavpack --enable-libspeex --enable-libaom --enable-libvidstab --enable-libkvazaar --enable-libfreetype --enable-fontconfig --enable-libfribidi --enable-libass --enable-libzimg --enable-libsoxr --enable-libopenjpeg --enable-libdav1d
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555564ad840] Failed to seek for auxiliary info, will only parse senc atoms for encryption info
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555564c4100] could not find corresponding trex (id 2)
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555564c4100] could not find corresponding track id 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555564c4100] trun track id unknown, no tfhd was found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x5555564c4100] error reading header
stream.mpd: Invalid data found when processing input

I tried a few other options I do not remember, but the error persists and I do not know what could be the causes. I believe the concatenation step will not work due to the encryption, but I do not know how to get the key information from the MPD file neither how to decrypt before.

The following link says it should be easy, but something is not working (probably missing a decryption step): How to download and encode a video from a MPD manifest?

Could you help me to solve such issue?

3
  • 1
    I think you should also have an initialization file that you need to append to the chunks. I am also trying to do the same but in my case, I am trying to download the files manually using the manifest.mpd file and concatenate them together and eventually re-create the original file but so far, I was not able to make it. Nov 18, 2019 at 9:29
  • @GeorgеStoyanov Lets try to help each other then :D I was trying to find the key to use with bento4.com/documentation/mp4decrypt. I found the KID into the MPD file, but I do not know what is the key. Maybe it is possible to decrypt before appending the chunks. I do not know much about how it works, but the key must be in one of those files, or media players could not play such files. Nov 18, 2019 at 11:30
  • if I am not wrong the URL to the keystore should be included in the manifest file from where you can download the key to decrypt the MPEG-Dash segments. I think you can only retrieve the key for the decryption if you have authorized the player in your case the ffmpeg by providing username and password or some other way for authorization. Nov 18, 2019 at 12:38

1 Answer 1

1

After you have made concat with your method 2:

You need the decryption key value (not the KID) for each track (I will not explain how to find the key value;) and then from your video and audio files use mp4decrypt from bento4 (just google it if you don't have it yet):

mp4decrypt --key KID:00112233445566778899AABBCCDDEEFF audio.m4a audio_decrypted.mp4

mp4decrypt --key 1:00112233445566778899AABBCCDDEEFF video.mp4 video_decrypted.mp4

you will have to replace KID with your 16 bytes hex key ID and 00112233445566778899AABBCCDDEEFF with your real key value

then ffmpeg will work (as expected) with your decrypted tracks :

fmpeg -i video_decrypted.mp4 -i audio_decrypted.m4a -c copy output.mp4

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.