<p>Ok, looks like I solved the problem... Basically, I used relative paths in a couple of places where I should have used absolute ones instead.</p>

CC BY-SA 4.0
2020-02-07T19:02:50.317Z
2020-02-07T19:02:50.317Z
Red Elephant
<p>I'm trying to remux a set of encrypted <code>.ts</code> files (as a <code>.m3u8</code> playlist) into a single <code>.mp4</code> file with the next command:</p>

<pre><code>"C:\Users\~\Desktop\test\ffmpeg.exe" -allowed_extensions ALL \
    -i "C:\Users\~\Desktop\test\chunklist.m3u8" -c:v copy -c:a copy \
    "C:\Users\~\Desktop\test\output.mp4"
</code></pre>

<p>but getting the </p>

<blockquote>
  <p>Unable to open key file </p>
</blockquote>

<p>error. I tried the URI as “key” with and without quotes as well as the key in hex format but the error is still there... What I'm doing wrong?</p>

<p>Here is the cmd output:</p>

<pre><code>ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20181017
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 22.100 / 56. 22.100
      libavcodec     58. 35.100 / 58. 35.100
      libavformat    58. 20.100 / 58. 20.100
      libavdevice    58.  5.100 / 58.  5.100
      libavfilter     7. 40.101 /  7. 40.101
      libswscale      5.  3.100 /  5.  3.100
      libswresample   3.  3.100 /  3.  3.100
      libpostproc    55.  3.100 / 55.  3.100
    [hls,applehttp @ 00000215fa3a9f00] Opening 'key' for reading
    Unable to open key file key
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_0.ts' for reading
    [crypto @ 00000215fa3c6f80] Unable to open resource: media_b6000000_0.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 0 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_1.ts' for reading
    [crypto @ 00000215fa3c6f80] Unable to open resource: media_b6000000_1.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 1 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_2.ts' for reading
    [crypto @ 00000215fa3c6f00] Unable to open resource: media_b6000000_2.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 2 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Error when loading first segment 'media_b6000000_0.ts'
    C:\Users\~\Desktop\test\chunklist.m3u8: Invalid data found when processing input
</code></pre>

<p>The files I'm working with are in the <a href="https://www.mediafire.com/file/1ylixgqhcfummq0/test.zip/file" rel="nofollow noreferrer">test.zip</a> archive.</p>

<p>(The original playlist has more <code>.ts</code> files but I've included only first three, it shouldn't matter anyway).</p>

<p>Any help will be appreciated. Thanks!</p>

<ffmpeg><mp4><hls>
"Unable to open key file" error when remuxing a set of encrypted .ts files (as a .m3u8 playlist) into .mp4 with FFmpeg
Red Elephant
# "Unable to open key file" error when remuxing a set of encrypted .ts files (as a .m3u8 playlist) into .mp4 with FFmpeg

(Asked by: username_0 on 2020-02-05)

I'm trying to remux a set of encrypted .ts files (as a .m3u8 playlist) into a single .mp4 file with the next command:
"C:\Users\~\Desktop\test\ffmpeg.exe" -allowed_extensions ALL \
    -i "C:\Users\~\Desktop\test\chunklist.m3u8" -c:v copy -c:a copy \
    "C:\Users\~\Desktop\test\output.mp4"

but getting the 

Unable to open key file 

error. I tried the URI as “key” with and without quotes as well as the key in hex format but the error is still there... What I'm doing wrong?
Here is the cmd output:
ffmpeg version 4.1 Copyright (c) 2000-2018 the FFmpeg developers
      built with gcc 8.2.1 (GCC) 20181017
      configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
      libavutil      56. 22.100 / 56. 22.100
      libavcodec     58. 35.100 / 58. 35.100
      libavformat    58. 20.100 / 58. 20.100
      libavdevice    58.  5.100 / 58.  5.100
      libavfilter     7. 40.101 /  7. 40.101
      libswscale      5.  3.100 /  5.  3.100
      libswresample   3.  3.100 /  3.  3.100
      libpostproc    55.  3.100 / 55.  3.100
    [hls,applehttp @ 00000215fa3a9f00] Opening 'key' for reading
    Unable to open key file key
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_0.ts' for reading
    [crypto @ 00000215fa3c6f80] Unable to open resource: media_b6000000_0.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 0 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_1.ts' for reading
    [crypto @ 00000215fa3c6f80] Unable to open resource: media_b6000000_1.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 1 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Opening 'crypto:media_b6000000_2.ts' for reading
    [crypto @ 00000215fa3c6f00] Unable to open resource: media_b6000000_2.ts
    [hls,applehttp @ 00000215fa3a9f00] Failed to open segment 2 of playlist 0
    [hls,applehttp @ 00000215fa3a9f00] Error when loading first segment 'media_b6000000_0.ts'
    C:\Users\~\Desktop\test\chunklist.m3u8: Invalid data found when processing input

The files I'm working with are in the test.zip archive.
(The original playlist has more .ts files but I've included only first three, it shouldn't matter anyway).
Any help will be appreciated. Thanks!

**Tags:** ffmpeg, mp4, hls


---

## 1 answers

### Answer by username_0 on 2020-02-07. Score: 0 | Accepted answer

Ok, looks like I solved the problem... Basically, I used relative paths in a couple of places where I should have used absolute ones instead.


---

