Perusal, Synthesis, Bliss

April 12, 2021: télécharger une vidéo sur une page du site de France Info (https://www.francetvinfo.fr) ou France TV (https://www.france.tv/france-2/complement-d-enquete/)

Premier cas: audio et vidéo à la même adresse web

Depuis quelques années j’ai pris l’habitude de télécharger toute vidéo vue et de prendre des notes au visionnage. Pour ARTE j’utilise l’outil Qarte, et plus généralement sur Youtube et autres j’utilise l’excellent youtube-dl en ligne de commande. Il m’arrive de temps en temps d’utiliser Video DownloadHelper.
Aujourd’hui je regarde un court reportage sur la reconstruction de Notre Dame sur le site de France Info à l’adresse ici. youtube-dl ne marche pas directement:
$ youtube-dl -F "https://www.francetvinfo.fr/culture/patrimoine/incendie-de-notre-dame-de-paris/notre-dame-une-cathedrale-de-metal-pour-reconstruire-la-cathedrale_4368399.html"[francetvinfo.fr] notre-dame-une-cathedrale-de-metal-pour-reconstruire-la-cathedrale_4368399: Downloading webpage
ERROR: Unable to extract video id; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; type  youtube-dl -U  to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
$ youtube-dl -U
youtube-dl is up-to-date (2021.04.07)
Et ce n’est pas mieux avec Video DownloadHelper (version 7.4.0 à ce jour):
video_downloadhelper_and_fragmented_video.png
L’option "Download" proposée ne fonctionne pas comme attendu, elle ne télécharge que le fragment sur lequel l’opération est réalisée.
video_downloadhelper_and_fragmented_video_2.png
Le problème est visiblement que la vidéo est "fragmentée" et qu’au moins dans ce cas-ci l’assemblage n’est pas géré. Cela semble confirmé ici:
DownlodHelper ne peut pas télécharger les vidéos à partir de Pluzz, car elles sont fragmentées.
En cliquant sur "Details", on obtient une valeur "url", mais qui ne donne non plus rien du tout avec youtube-dl (cette méthode alternative a déjà fonctionné il me semble):
$ youtube-dl -F "https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/ZXhwPTE2MTgyMjI1OTB+YWNsPSUyZmU5ZWRhMjNiNDM3MDYlMmY3OTY4NWFiZS05YWZhLTExZWItYTA1NS0wMDBkM2EyNDI3YWJfbW9uZGVfVEEuaXNtKn5obWFjPTA4MWNkYTU5YzhlNTZlYWE2MDliNzIyNDQwMTYyYjI4NTUxNDk1ZjliZWRiZWVhZjM4NzZhZDcwNWUzNThjY2U=/dash/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA-video=950000.dash"
[generic] 79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA-video=950000: Requesting header
[info] Available formats for 79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA-video=950000:
format code  extension  resolution note
mp4          dash       unknown   

$ youtube-dl -f mp4 "https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/ZXhwPTE2MTgyMjI1OTB+YWNsPSUyZmU5ZWRhMjNiNDM3MDYlMmY3OTY4NWFiZS05YWZhLTExZWItYTA1NS0wMDBkM2EyNDI3YWJfbW9uZGVfVEEuaXNtKn5obWFjPTA4MWNkYTU5YzhlNTZlYWE2MDliNzIyNDQwMTYyYjI4NTUxNDk1ZjliZWRiZWVhZjM4NzZhZDcwNWUzNThjY2U=/dash/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA-video=950000.dash"
[generic] 79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA-video=950000: Requesting header
ERROR: requested format not available
Une solution que j’ai trouvée est d’utiliser l’extension YouTube & HLS Stream Sniper (update: un internaute m’a informé que cette extension ne semble plus disponible en mars 2023, mais l’extension The Stream Detector peut être utilisée en remplacement, probablement le même code source à l’origine). A la lecture de la vidéo sur le site de France Info, il détecte deux fichiers "manifest.mpd"
stream_sniper.png
En cliquant sur l’un ou l’autre de ces fichiers les adresses correspondantes sont copiées dans le presse-papier:
https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/ZXhwPTE2MTgyMjQyNjJ+YWNsPSUyZmU5ZWRhMjNiNDM3MDYlMmY3OTY4NWFiZS05YWZhLTExZWItYTA1NS0wMDBkM2EyNDI3YWJfbW9uZGVfVEEuaXNtKn5obWFjPWQ5YWYzNDNiNGZiYzEzY2I4YzUwYWJhMzc4MzlhYWFlM2QyMjExOGJmMDVkMjY1ODlkNTI1OTcxZjhkZTFhNTk=/manifest.mpd

https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/manifest.mpd?hdnea=exp=1618203261~acl=%2fe9eda23b43706%2f79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism*~hmac=8ed4e10dd82b951c49dbe4f42842e9d31210c94e7c6ef2c2bd95c0b9548d6fdb
L’une ou l’autre peut être utilisée avec Youtube-dl. Cependant, vidéo et audio sont séparés:
$ youtube-dl -F "https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/ZXhwPTE2MTgyMjQyNjJ+YWNsPSUyZmU5ZWRhMjNiNDM3MDYlMmY3OTY4NWFiZS05YWZhLTExZWItYTA1NS0wMDBkM2EyNDI3YWJfbW9uZGVfVEEuaXNtKn5obWFjPWQ5YWYzNDNiNGZiYzEzY2I4YzUwYWJhMzc4MzlhYWFlM2QyMjExOGJmMDVkMjY1ODlkNTI1OTcxZjhkZTFhNTk=/manifest.mpd"
[generic] manifest: Requesting header
WARNING: Falling back on generic information extractor.
[generic] manifest: Downloading webpage
[generic] manifest: Extracting information
[info] Available formats for manifest:
format code      extension  resolution note
audio_fre=96000  m4a        audio only [fr] DASH audio   96k , m4a_dash container, mp4a.40.2 (48000Hz)
video=400000     mp4        384x216    DASH video  400k , mp4_dash container, avc1.42C01E, 25fps, video only
video=950000     mp4        640x360    DASH video  950k , mp4_dash container, avc1.4D401F, 25fps, video only
video=1400000    mp4        960x540    DASH video 1400k , mp4_dash container, avc1.4D401F, 25fps, video only
video=2000000    mp4        1280x720   DASH video 2000k , mp4_dash container, avc1.64001F, 25fps, video only (best)
Il faut donc "assembler" l’audio et la vidéo. Fort heureusement cela se fait très facilement avec youtube-dl:
$ youtube-dl --merge-output-format mp4 -o notre-dame-paris-france-info-12-avril-2021.mp4 -f video=950000+audio_fre=96000 "https://cloudingest.ftven.fr/e9eda23b43706/79685abe-9afa-11eb-a055-000d3a2427ab_monde_TA.ism/ZXhwPTE2MTgyMjQyNjJ+YWNsPSUyZmU5ZWRhMjNiNDM3MDYlMmY3OTY4NWFiZS05YWZhLTExZWItYTA1NS0wMDBkM2EyNDI3YWJfbW9uZGVfVEEuaXNtKn5obWFjPWQ5YWYzNDNiNGZiYzEzY2I4YzUwYWJhMzc4MzlhYWFlM2QyMjExOGJmMDVkMjY1ODlkNTI1OTcxZjhkZTFhNTk=/manifest.mpd"
[generic] manifest: Requesting header
WARNING: Falling back on generic information extractor.
[generic] manifest: Downloading webpage
[generic] manifest: Extracting information
[dashsegments] Total fragments: 126
[download] Destination: notre-dame-paris-france-info-12-avril-2021.fvideo=950000.mp4
[download] 100% of 27.95MiB in 00:11
[dashsegments] Total fragments: 126
[download] Destination: notre-dame-paris-france-info-12-avril-2021.mp4.faudio_fre=96000
[download] 100% of 2.92MiB in 00:25
[ffmpeg] Merging formats into "notre-dame-paris-france-info-12-avril-2021.mp4"
Deleting original file notre-dame-paris-france-info-12-avril-2021.fvideo=950000.mp4 (pass -k to keep)
Deleting original file notre-dame-paris-france-info-12-avril-2021.mp4.faudio_fre=96000 (pass -k to keep)
Comme on peut le voir il est utile de choisir le nom de la vidéo (avec son) finale, sinon un nom par défaut est proposé. Le résultat se lit parfaitement avec VLC.

Deuxième cas: audio et vidéo à des adresses web différentes

Premier exemple

Voir la vidéo située ici. Video DownloadHelper donne plusieurs possibilités:
video_download_helper_ARTE.png
La première ligne correspond au son de la vidéo, la deuxième à la vidéo, et les quatres lignes suivantes contiennent seulement de la vidéo. La technique que j’ai utilisée est de télécharger l’audio, la vidéo, puis de joindre les deux avec mencoder:
$ youtube-dl -f mp4 "https://arte-cmafhls.akamaized.net/am/cmaf-webonly/103000/103900/103908-004-A_VOF/210520164550/medias/103908-004-A_aud_VOF.mp4"
[generic] 103908-004-A_aud_VOF: Requesting header
[download] Destination: 103908-004-A_aud_VOF-103908-004-A_aud_VOF.mp4
[download] 100% of 1.63MiB in 00:01

$ youtube-dl -f mp4 "https://arte-cmafhls.akamaized.net/am/cmaf-webonly/103000/103900/103908-004-A_VOF/210520164550/medias/103908-004-A_v720.mp4"
[generic] 103908-004-A_v720: Requesting header
[download] Destination: 103908-004-A_v720-103908-004-A_v720.mp4
[download] 100% of 24.29MiB in 00:16
$
Première tentative avec mencoder, inspirée de la solution donné ici:
$ mencoder -oac copy -ovc copy -audiofile 103908-004-A_aud_VOF-103908-004-A_aud_VOF.mp4 -o fichier_out.avi 103908-004-A_v720-103908-004-A_v720.mp4
MEncoder 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team
success: format: 0  data: 0x0 - 0x184b503
libavformat version 58.29.100 (external)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa712fac600]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: video (h264), -vid 0
VIDEO:  [H264]  1280x720  24bpp  25.000 fps  1945.3 kbps (237.5 kbyte/s)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fa712fac600]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: audio (aac), -aid 0, -alang fra
[V] filefmt:65536  fourcc:0x34363248  size:1280x720  fps:25.000  ftime:=0.0400
videocodec: framecopy (1280x720 24bpp fourcc=34363248)
Audio format 0x4134504d is incompatible with ’-oac copy’, please try ’-oac pcm’ instead or use ’-fafmttag’ to override it.
Exiting...
1        Command failure: error 1 !
$ echo $?
1
Code d’erreur égal à 1, cela n’a pas fonctionné. La deuxième tentative correspondant à la recommandation de mencoder est la bonne:
$ mencoder -oac pcm -ovc copy -audiofile 103908-004-A_aud_VOF-103908-004-A_aud_VOF.mp4 -o fichier_out.avi 103908-004-A_v720-103908-004-A_v720.mp4    
MEncoder 1.3.0 (Debian), built with gcc-9 (C) 2000-2016 MPlayer Team
success: format: 0  data: 0x0 - 0x184b503
libavformat version 58.29.100 (external)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f130097b600]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: video (h264), -vid 0
VIDEO:  [H264]  1280x720  24bpp  25.000 fps  1945.3 kbps (237.5 kbyte/s)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f130097b600]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: audio (aac), -aid 0, -alang fra
[V] filefmt:65536  fourcc:0x34363248  size:1280x720  fps:25.000  ftime:=0.0400
==========================================================================
Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders
libavcodec version 58.54.100 (external)
AUDIO: 44100 Hz, 2 ch, floatle, 128.9 kbit/4.57% (ratio: 16113->352800)
Selected audio codec: [ffaac] afm: ffmpeg (FFmpeg AAC (MPEG-2/MPEG-4 Audio))
==========================================================================
videocodec: framecopy (1280x720 24bpp fourcc=34363248)
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Pos: 104.6s   2615f (100%)  0.00fps Trem:   0min  41mb  A-V:-0.053 [1946:1411]
Writing index...
Writing header...
ODML: Aspect information not (yet?) available or unspecified, not writing vprp header.
Video stream: 1946.074 kbit/s  (243259 B/s)  size: 25444920 bytes  104.600 secs  2615 frames
Audio stream: 1411.200 kbit/s  (176400 B/s)  size: 18423808 bytes  104.443 secs
$ echo $?
0

Deuxième exemple

Voir la vidéo à ici ("Complément d’enquête"). On est tenté de faire, puisque le site demande à être loggé pour voir la vidéo:
$ youtube-dl --verbose -u "USERNAME" -p PASSWORD -F "https://www.france.tv/france-2/complement-d-enquete/2738309-penuries-de-medicaments-a-quoi-jouent-les-labos.html"
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [’--restrict-filenames’, ’--verbose’, ’-u’, ’PRIVATE’, ’-p’, ’PRIVATE’, ’-F’, ’https://www.france.tv/france-2/complement-d-enquete/2738309-penuries-de-medicaments-a-quoi-jouent-les-labos.html’]
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2021.06.06
[debug] Python version 3.6.13 (CPython) - Linux-5.3.18-59.5-default-x86_64-with-glibc2.3.4
[debug] exe versions: ffmpeg 4.4, ffprobe 4.4
[debug] Proxy map: {}
[FranceTVSite] 2738309-penuries-de-medicaments-a-quoi-jouent-les-labos: Downloading webpage
[FranceTV] 0c13b518-b893-472f-94f8-054d49f1bfd7: Downloading video JSON
ERROR: Unable to download JSON metadata: HTTP Error 404: Not Found (caused by <HTTPError 404: ’Not Found’>);
Cela ne fonctionne pas. Mais Video DownloadHelper dans Firefox fait tout le boulot de détection: l’audio est l’item du bas (cliquer sur les trois petits points à sa droite et après sur "Copy URL"), et la video est par exemple la version 960x540 que j’ai entourée en vert:
video_downloadhelper_complement_d_enquete.png
Ensuite l’audio et la vidéo sont téléchargés séparément en utilisant youtube-dl:
$ youtube-dl "https://cloudreplay.ftven.fr/6d95b77c8a316/1033750310_france-domtom_TA.ism/ZXhwPTE2MzE1ODY1NDJ+YWNsPSUyZjZkOTViNzdjOGEzMTYlMmYxMDMzNzUwMzEwX2ZyYW5jZS1kb210b21fVEEuaXNtKn5obWFjPTk2NGEyMzQxYjA0Nzc1OTI4OTM2MjMxNjdkNjdjNzdjMmJhNWMyNDQ1MDU3NDNjOWI1NmFhYTU0YmE0YmUxOTk=/1033750310_france-domtom_TA-audio_fre=96000.m3u8"
$ youtube-dl "https://cloudreplay.ftven.fr/6d95b77c8a316/1033750310_france-domtom_TA.ism/ZXhwPTE2MzE1ODY1NDJ+YWNsPSUyZjZkOTViNzdjOGEzMTYlMmYxMDMzNzUwMzEwX2ZyYW5jZS1kb210b21fVEEuaXNtKn5obWFjPTk2NGEyMzQxYjA0Nzc1OTI4OTM2MjMxNjdkNjdjNzdjMmJhNWMyNDQ1MDU3NDNjOWI1NmFhYTU0YmE0YmUxOTk=/1033750310_france-domtom_TA-video=1400000.m3u8"
créant les deux fichiers suivants:
-rw-r----- 1 jscordi users    46M 2021-09-13 23:01 1033750310_france-domtom_TA-audio_fre=96000-1033750310_france-domtom_TA-audio_fre=96000.mp4
-rw-r----- 1 jscordi users   640M 2021-09-13 23:14 1033750310_france-domtom_TA-video=1400000-1033750310_france-domtom_TA-video=1400000.mp4
Audio et vidéo sont ensuite assemblés avec mencoder, comme dans le premier exemple:
$ mencoder -oac pcm -ovc copy -audiofile 1033750310_france-domtom_TA-audio_fre=96000-1033750310_france-domtom_TA-audio_fre=96000.mp4 -o "COMPLEMENT_D_ENQUETE_penuries_de_medicaments_a_quoi_jouent_les_labos.mp4" 1033750310_france-domtom_TA-video=1400000-1033750310_france-domtom_TA-video=1400000.mp4
Et on a vu au passage qu’il n’est pas nécessaire de se logger pour télécharger audio et vidéo avec youtube-dl.
Update le lendemain: le streaming HLS n’est plus détecté par Video DownloadHelper sur cette vidéo, et les commandes de téléchargement ci-dessus ne fonctionnent plus. Seuls les petits bouts sont détectés:
video_downloadhelper_and_fragmented_video_3.png
Est-ce que ceci a été détecté et des contre-mesures adoptées? Sur d’autres vidéos de Complément d’enquête cela fonctionne.