Repository: yt-dlp
Issue: RAI2 live stream error "HTTP error 403 Forbidden" when using ffmpeg downloader
Labels: bug,geo-blocked,core:downloader

### DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

- [X] I understand that I will be **blocked** if I remove or skip any mandatory\* field

### Checklist

- [X] I'm reporting a broken site
- [X] I've verified that I'm running yt-dlp version **2022.11.11** ([update instructions](https://github.com/yt-dlp/yt-dlp#update)) or later (specify commit)
- [X] I've checked that all provided URLs are playable in a browser with the same IP and same login details
- [X] I've checked that all URLs and arguments with special characters are [properly quoted or escaped](https://github.com/yt-dlp/yt-dlp/wiki/FAQ#video-url-contains-an-ampersand--and-im-getting-some-strange-output-1-2839-or-v-is-not-recognized-as-an-internal-or-external-command)
- [X] I've searched the [bugtracker](https://github.com/yt-dlp/yt-dlp/issues?q=) for similar issues **including closed ones**. DO NOT post duplicates
- [X] I've read the [guidelines for opening an issue](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#opening-an-issue)
- [X] I've read about [sharing account credentials](https://github.com/yt-dlp/yt-dlp/blob/master/CONTRIBUTING.md#are-you-willing-to-share-account-details-if-needed) and I'm willing to share it if required

### Region

Italy

### Provide a description that is worded well enough to be understood

RAI2 channel live stream is selectable at: http://www.replaytvmhp.rai.it/hbbtv/launcher/RemoteControl/index.html
This is an HBBTV site intended for smart TVs, but it works from Chrome browser using keys (at least when from an italian IP address).

Since yt-dlp does not support the site, I extracted the stream initializer URL, which is:
http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16
This URL is directly playable with HLSPlayer extension for Chrome.

It works even with youtube-dl:
```
youtube-dl -o RAI2.ts "http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16"
[generic] relinkerServlet: Requesting header
[redirect] Following redirect to https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/playlist_ma.m3u8?hdnea=st=1669568134~exp=1669568284~acl=/*~hmac=007635c2a28d23ac1c803e3912bb24dce17746ba79cf3c7cf00b5d76ed2bb5c6
[generic] *~hmac=007635c2a28d23ac1c803e3912bb24dce17746ba79cf3c7cf00b5d76ed2bb5c6: Requesting header
[generic] *~hmac=007635c2a28d23ac1c803e3912bb24dce17746ba79cf3c7cf00b5d76ed2bb5c6: Downloading m3u8 information
[download] Destination: RAI2.ts.f2793
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
......
```

yt-dlp works somewhat when not using ffmpeg downloader:
```
yt-dlp -o RAI2.ts "http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16"
[generic] relinkerServlet: Downloading webpage
[redirect] Following redirect to https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/playlist_ma.m3u8?hdnea=st=1669568276~exp=1669568426~acl=/*~hmac=37529951881dc6bcb3028442bd8cde4b2762166b41d2510a4d4f407de98e33cd
[generic] *~hmac=37529951881dc6bcb3028442bd8cde4b2762166b41d2510a4d4f407de98e33cd: Downloading webpage
[generic] *~hmac=37529951881dc6bcb3028442bd8cde4b2762166b41d2510a4d4f407de98e33cd: Downloading m3u8 information
[info] *~hmac=37529951881dc6bcb3028442bd8cde4b2762166b41d2510a4d4f407de98e33cd: Downloading 1 format(s): 2793+aac-Lingua_Originale
[hlsnative] Downloading m3u8 manifest
WARNING: Live HLS streams are not supported by the native downloader. If this is a livestream, please add "--downloader ffmpeg --hls-use-mpegts" to your command
[hlsnative] Total fragments: 1440
[download] Destination: RAI2.ts.f2793.mp4
[download]   0.7% of ~   4.61GiB at    3.55MiB/s ETA 21:59 (frag 10/1440)ERROR: Data must be padded to 16 byte boundary in CBC mode
```

yt-dlp fails with `[https @ 0000027818edf780] HTTP error 403 Forbidden` when using ffmpeg downloader. See below.


### Provide verbose output that clearly demonstrates the problem

- [X] Run **your** yt-dlp command with **-vU** flag added (`yt-dlp -vU <your command line>`)
- [X] Copy the WHOLE output (starting with `[debug] Command-line config`) and insert it below

### Complete Verbose Output

```shell
c:\Users\colem\Downloads\corry>yt-dlp -vU --downloader ffmpeg --hls-use-mpegts "http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16"
[debug] Command-line config: ['-vU', '--downloader', 'ffmpeg', '--hls-use-mpegts', 'http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.11.11 [8b64402] (win_exe)
[debug] Python 3.8.10 (CPython AMD64 64bit) - Windows-10-10.0.19044-SP0 (OpenSSL 1.1.1k  25 Mar 2021)
[debug] exe versions: ffmpeg 4.3.1, ffprobe 4.2.2, phantomjs 2.1.1
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.09.24, mutagen-1.46.0, sqlite3-2.6.0, websockets-10.4
[debug] Proxy map: {}
[debug] Loaded 1723 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.11.11, Current version: 2022.11.11
yt-dlp is up to date (2022.11.11)
[debug] [generic] Extracting URL: http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=308718&output=16
[generic] relinkerServlet: Downloading webpage
[redirect] Following redirect to https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/playlist_ma.m3u8?hdnea=st=1669568581~exp=1669568731~acl=/*~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443
[debug] [generic] Extracting URL: https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/playlist_ma.m3u8?hdnea=st=1669568581~exp=1669568731~acl=/*~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443
[generic] *~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443: Downloading webpage
[debug] Identified a direct video link
[generic] *~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443: Downloading m3u8 information
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), channels, acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] *~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443: Downloading 1 format(s): 2793+aac-Lingua_Originale
[debug] Invoking ffmpeg downloader on "https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/rai2_2400/exp=1669654981~acl=%2fhls%2flive%2f598310%2fraidue1%2f*!%2fhls%2flive%2f598310-b%2fraidue1%2f*!%2f*.key~data=hdntl~hmac=a27d26f40c35805a7f1cc532a6cebbb70cc1233d91ac5cfe745d6acd99a3594b/chunklist.m3u8?aka_me_session_id=AAAAAAAAAADF6YRjAAAAACaYFCDrnHxkLu%2fIY6dxEzv+I0rMPmaNCaTZMKeImRQWGYy%2fFhG4HKjSPFqz446nUrJUxFYWtG%2fz&aka_media_format_type=hls", "https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/engrai2_160/exp=1669654981~acl=%2fhls%2flive%2f598310%2fraidue1%2f*!%2fhls%2flive%2f598310-b%2fraidue1%2f*!%2f*.key~data=hdntl~hmac=a27d26f40c35805a7f1cc532a6cebbb70cc1233d91ac5cfe745d6acd99a3594b/chunklist_ao.m3u8?aka_me_session_id=AAAAAAAAAADF6YRjAAAAACaYFCDrnHxkLu%2fIY6dxEzv+I0rMPmaNCaTZMKeImRQWGYy%2fFhG4HKjSPFqz446nUrJUxFYWtG%2fz&aka_media_format_type=hls"
[download] Destination: playlist_ma [*~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443].mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -i "https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/rai2_2400/exp=1669654981~acl=%2fhls%2flive%2f598310%2fraidue1%2f*!%2fhls%2flive%2f598310-b%2fraidue1%2f*!%2f*.key~data=hdntl~hmac=a27d26f40c35805a7f1cc532a6cebbb70cc1233d91ac5cfe745d6acd99a3594b/chunklist.m3u8?aka_me_session_id=AAAAAAAAAADF6YRjAAAAACaYFCDrnHxkLu%2fIY6dxEzv+I0rMPmaNCaTZMKeImRQWGYy%2fFhG4HKjSPFqz446nUrJUxFYWtG%2fz&aka_media_format_type=hls" -i "https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/engrai2_160/exp=1669654981~acl=%2fhls%2flive%2f598310%2fraidue1%2f*!%2fhls%2flive%2f598310-b%2fraidue1%2f*!%2f*.key~data=hdntl~hmac=a27d26f40c35805a7f1cc532a6cebbb70cc1233d91ac5cfe745d6acd99a3594b/chunklist_ao.m3u8?aka_me_session_id=AAAAAAAAAADF6YRjAAAAACaYFCDrnHxkLu%2fIY6dxEzv+I0rMPmaNCaTZMKeImRQWGYy%2fFhG4HKjSPFqz446nUrJUxFYWtG%2fz&aka_media_format_type=hls" -c copy -map "0:0" -map "1:0" -f mp4 "file:playlist_ma [*~hmac=c2a9072ffbd178b077d0492c7acb3186cb8a9dbb2b84019e97526fd3e35b6443].mp4.part"
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10.2.1 (GCC) 20200726
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --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-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100
[tcp @ 000002aa49cf2c80] Starting connection attempt to 2.20.252.147 port 443
[tcp @ 000002aa49cf2c80] Successfully connected to 2.20.252.147 port 443
[https @ 000002aa49cef880] HTTP error 403 Forbidden
https://raidue1-live.akamaized.net/hls/live/598310/raidue1/raidue1/rai2_2400/exp=1669654981~acl=%2fhls%2flive%2f598310%2fraidue1%2f*!%2fhls%2flive%2f598310-b%2fraidue1%2f*!%2f*.key~data=hdntl~hmac=a27d26f40c35805a7f1cc532a6cebbb70cc1233d91ac5cfe745d6acd99a3594b/chunklist.m3u8?aka_me_session_id=AAAAAAAAAADF6YRjAAAAACaYFCDrnHxkLu%2fIY6dxEzv+I0rMPmaNCaTZMKeImRQWGYy%2fFhG4HKjSPFqz446nUrJUxFYWtG%2fz&aka_media_format_type=hls: Server returned 403 Forbidden (access denied)


ERROR: ffmpeg exited with code 1
  File "yt_dlp\__main__.py", line 17, in <module>
  File "yt_dlp\__init__.py", line 968, in main
  File "yt_dlp\__init__.py", line 958, in _real_main
  File "yt_dlp\YoutubeDL.py", line 3322, in download
  File "yt_dlp\YoutubeDL.py", line 3297, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1474, in extract_info
  File "yt_dlp\YoutubeDL.py", line 1485, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1582, in __extract_info
  File "yt_dlp\YoutubeDL.py", line 1661, in process_ie_result
  File "yt_dlp\YoutubeDL.py", line 1474, in extract_info
  File "yt_dlp\YoutubeDL.py", line 1485, in wrapper
  File "yt_dlp\YoutubeDL.py", line 1582, in __extract_info
  File "yt_dlp\YoutubeDL.py", line 1641, in process_ie_result
  File "yt_dlp\YoutubeDL.py", line 2737, in process_video_result
  File "yt_dlp\YoutubeDL.py", line 3147, in process_info
  File "yt_dlp\YoutubeDL.py", line 2924, in dl
  File "yt_dlp\downloader\common.py", line 446, in download
  File "yt_dlp\downloader\external.py", line 73, in real_download
  File "yt_dlp\YoutubeDL.py", line 1004, in report_error
  File "yt_dlp\YoutubeDL.py", line 933, in trouble
```