Download encrypted m3u8 with ffmpeg "HTTP error 403 Forbidden" - ffmpeg

I have been using ffmepg and many tools to download online videos but I have the following case:
The main m3u8 file from the streaming server shows different resolutions:
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=133241,RESOLUTION=426x240, CODECS="avc1.42e00a,mp4a.40.2"
240.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=216379,RESOLUTION=640x360, CODECS="avc1.42e00a,mp4a.40.2"
360.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=239756,RESOLUTION=852x480, CODECS="avc1.42e00a,mp4a.40.2"
480.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=408978,RESOLUTION=1280x720, CODECS="avc1.42e00a,mp4a.40.2"
720.m3u8
Then for every resolution there are 2 files, for example let us pick the 720:
720.m3u8
720.key
The 720.m3u8 has the segments and the 720.key has base64 encrypted key
Now when I use ffmpeg I got the following error:
[https # 0x7fc00a40e0c0] HTTP error 403 Forbidden
[hls # 0x7fc00a204100] Unable to open key file https://hls2.videos.*****/video/720.key
I was sure that I added all the required headers in my ffmpeg command:
-user_agent
-referer
I am not sure what is the problem and I have tested all other tools like yt-dlp, yotube-dl and streamlink

Related

Why is ffmpeg and vlc able run RTSP stream but gstreamer is unable to?

I have a RTSP server streaming out h264 video. Both ffmpeg (ffplay uri)and vlc are able to stream the video but gstreamer is unable to.
Below is the output of gstreamer when gst-play uri is launched:
ERROR Your GStreamer installation is missing a plug-in. for rtsp://---- ERROR debug information: ../gst/playback/gsturidecodebin.c(1028): no_more_pads_full (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0: no suitable plugins found: ../gst/rtsp/gstrtspsrc.c(7691): gst_rtspsrc_setup_streams_start (): /GstPlayBin:playbin/GstURIDecodeBin:uridecodebin0/GstRTSPSrc:source Reached end of play list.
Am I missing certain gstreamer plugins or is my RTSP video stream set up wrongly?
Appreciate any advice! Thank you!

How to fix error "Encoding Failed" using FFMPEG?

I am using FFMPEG for converting mp4 to m3u8 format on an Ubuntu local machine. But I am facing an error Encoding Failed.
My controller code is:
FFMpeg::open(public_path()."/uploads/".$filename)
->exportForHLS()
->addFormat($lowBitrate)
->addFormat($midBitrate)
->addFormat($highBitrate)
->toDisk(env('APP_ENV'))
->save(public_path().'/converted/adaptive_steve.m3u8');
The error is:
Config file is
How can I solve this? Thanks

Pre signing AWS S3 files

I have a bucket that allows for open files. I have uploaded a test file called test.gsm and have tried to presign the file by doing
root#server2:~# aws s3 presign s3://dovid-ft/test.gsm --expires-in 604800
https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191
root#server2:~#
If I then try to grab that file I get a 403.
root#server2:~# wget 'https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191'
--2021-06-30 07:49:21-- https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B%2FKVrqgOXFQNTGh3gme%2Fo%3D&Expires=1625658191
Resolving dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)... 52.217.88.204
Connecting to dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)|52.217.88.204|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2021-06-30 07:49:21 ERROR 403: Forbidden.
root#server2:~#
I also tried to decode the HTML of the key to see if that would help and it did not.
root#server2:~# wget 'https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B/KVrqgOXFQNTGh3gme/o=&Expires=1625658191'
--2021-06-30 07:49:37-- https://dovid-ft.s3.amazonaws.com/test.gsm?AWSAccessKeyId=AKIAJSDPJKCCGAZ257VQ&Signature=0zbBU2B/KVrqgOXFQNTGh3gme/o=&Expires=1625658191
Resolving dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)... 52.217.32.100
Connecting to dovid-ft.s3.amazonaws.com (dovid-ft.s3.amazonaws.com)|52.217.32.100|:443... connected.
HTTP request sent, awaiting response... 403 Forbidden
2021-06-30 07:49:37 ERROR 403: Forbidden.
root#server2:~#
Is there any way to get logs or see what the issue is and why my request is being rejected? As of now the only way to be able to get the file is to make it publicly available which I don't want to do.
It turns out I was using the wrong credentials to presign the file. Why amazon didn't throw an error when I tried to presign them with the wrong credentials is beyond me.
The solution is in wget. after recreating the scenario I wasn't able to download a file via wget also.
wget -O test.gsm "https://yourURL" # and will do.
reference: Amazon AWS S3 signed URL via Wget

Fiware pep-proxy: Uploaded zip file's size changes when uploaded with PEP standing between client and REST API

I created REST web service using DjangoRestFramework that accepts some inputs and a zip file.
When i don't use PEP Proxy as a gateway between client(javascript app) and this web service, there are no problems, all data including zipped file are correct. But when I put PEP Proxy in the middle, my zip file size increases about 30MB and i get corrupted zip file, and the other data is ok.
Error message:
Zip file size: 73106015 bytes, number of entries: 1
error [/tmp/tmp1_GLtj.upload]: missing 3949084193 bytes in zipfile
(attempting to process anyway)
error [/tmp/tmp1_GLtj.upload]: start of central directory not found;
zipfile corrupt.
(please check that you have transferred or created the zipfile in the
appropriate BINARY mode and that you have compiled UnZip properly)
And real size of this file is 39055691 bytes.
How can PEP proxy change file that is being uploaded?

Is this format supported: avc1.77.40,mp4a.40.34

I'm getting this error when playing an m3u8 file on the Chromecast
Uncaught NotSupportedError: Failed to execute 'addSourceBuffer' on 'MediaSource': The type provided ('video/mp2t; codecs="avc1.77.40,mp4a.40.34"') is unsupported.
I know in the past I was given a line to replace avc1.66.* with .30 codecs when processing the manifest, should I do the same for this?
Thanks.

Resources