How to convert encrypted mpeg dash created with Bento4 mp4-dash.py to MP4 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) &gt; video.mp4
cat audios/init.mp4 $(ls -1v audios/seg*.m4s) &gt; 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?
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