aajanki / yle-dl

Download videos from Yle servers
https://aajanki.github.io/yle-dl/index-en.html
GNU General Public License v3.0
302 stars 52 forks source link

Download fails due to wrong program_id being chosen #292

Closed pekkarr closed 2 years ago

pekkarr commented 2 years ago

Downloading https://areena.yle.fi/1-3554229 with ffmpeg backend fails with the following error and nothing is downloaded.

$ yle-dl --backend ffmpeg --verbose https://areena.yle.fi/1-3554229
yle-dl 20211207: Download media files from Yle Areena and Elävä Arkisto
[...]
DEBUG: Executing:
DEBUG: ffmpeg -y -headers 'X-Forwarded-For: 91.157.238.25
' -loglevel warning -thread_queue_size 1024 -seekable 0 -strict experimental -stats -i 'https://cdnsecakmi.kaltura.com/p/1955031/sp/195503100/playManifest/entryId/1_sgs3u14y/flavorId/1_uvjdl5ga/format/applehttp/protocol/https/a.m3u8?uiConfId=43362851&referrer=aHR0cHM6Ly9hcmVlbmEueWxlLmZpLzEtMzU1NDIyOQ==&playSessionId=11111111-1111-1111-1111-111111111111&clientTag=html5:v0.39.4' -metadata:s:v:0 'description=Väinö Linnan romaaniin perustuva, 2017 valmistunut ja miljoonayleisön teattereissa kerännyt, elokuva jalkaväkiosaston tiestä Suomen jatkosodassa. N: Eero Aho, Johannes Holopainen, Jussi Vatanen, Aku Hirviniemi. O: Aku Louhimies. Kuvailutulkkausmahdollisuus TV-esityksessä.' -metadata creation_time=2021-11-02T00:01:00+02:00 -bsf:a aac_adtstoasc -vcodec copy -acodec copy -scodec srt -map '0:p:1:s?' -map 0:p:1:v -map 0:p:1:a -dn 'file:Tuntematon sotilas: Aku Louhimies filmatisering från 2017: 2021-11-02T00:01.mkv'
[webvtt @ 0x55c32075cd40] Dropping 414 duplicated subtitle events
[webvtt @ 0x55c32089cbc0] Dropping 497 duplicated subtitle events
Stream map '0:p:1:v' matches no streams.
To ignore this, add a trailing '?' to the map.

(--backend ffmpeg prevents falling back to wget backend)

The ffmpeg command uses maps -map '0:p:1:s?' -map 0:p:1:v -map 0:p:1:a i.e. yle-dl chose to map streams from program_id 1. However, ffprobe with the stream URL tells that program_id 1 does not have a video stream but program_id 0 has, which is the reason why map 0:p:1:v fails.

The program_id is chosen here by selecting the largest program_id available. In this case however selecting program_id 0 would allow the stream to be downloaded and this was the behavior before commit 327b0baf815c30e2da319f3ffcad4eaab421ef4c.

aajanki commented 2 years ago

Good catch! It seems that in some cases the highest quality stream is the first one and in other cases the last one. I changed the selection logic on the master branch to choose the program ID with highest bitrate and both video and audio streams. At least Tuntematon sotilas is now downloaded correctly.