Outils pour utilisateurs

Outils du site


Ceci est une ancienne révision du document !

Youtube HD 1080 (DASH)

required: `youtube-dl` and `ffmpeg`

This script creates a folder in /tmp/ (which I have mounted as ramdisk), downloads the separate video and audio streams (see about DASH), copies them into a Matroska container, sets the modtime and moves the resulting file in the current directory.

hashfold=$(echo "$1" | md5sum)
mkdir -p "/tmp/youtube-dash/$hashfold"
cd "/tmp/youtube-dash/$hashfold"
# downloading the video stream (MP4 1080p, else fallback 720p)
youtube-dl -f 137/136 -o "/tmp/youtube-dash/$hashfold/%(title)s.zvideo" "$1"
# downloading the audio stream (MP4A-AAC)
youtube-dl -f 140 -o "/tmp/youtube-dash/$hashfold/%(title)s.zaudio" "$1"
for file in *.zvideo; do
	filemtime=$(stat -c %Y "$file")
	ffmpeg -i "$file" -i "${file%.??????}.zaudio" -c:v copy -c:a copy "${file%.??????}.mkv"
	touch -d "@$filemtime" "${file%.??????}.mkv"
	mv "${file%.??????}.mkv" "$outdir/"
	rm -r "/tmp/youtube-dash/$hashfold"
bash/youtube-dash.1411165024.txt.gz · Dernière modification: 2014-09-20 00:17 de mitsu