Youtube2Audio: Difference between revisions

From JoBaPedia
Jump to navigation Jump to search
Line 26: Line 26:
   echo "<$a><$t>"
   echo "<$a><$t>"
   mkdir -p "meta/$a"
   mkdir -p "meta/$a"
   ffmpeg -i "$f" -acodec copy -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.opus" </dev/zero
   ffmpeg -v 0 -i "$f" -acodec copy -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.opus" </dev/zero
   ffmpeg -i "$f" -acodec mp3  -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.mp3" </dev/zero
   ffmpeg -v 0 -i "$f" -acodec mp3  -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.mp3" </dev/zero
  done
  done


The redirects are necessary because ffmpeg encoders seem to read from stdin and garble the "while read f" loop input
The redirects are necessary because ffmpeg encoders seem to read from stdin and garble the "while read f" loop input

Revision as of 12:56, 3 June 2020

Youtube to Audio

Download youtube-dl or update to latest

sudo youtube-dl -U

Commands for DL a playlist

mkdir -p artist/album
cd artist/album
youtube-dl --extract-audio --keep-video 'album-playlist-url'

Option --embed-thumbnail seems useful, but did not work. Maybe retry later...

Commands for adding metadata

will need adapting to actual yt title audio formats. This playlist only contained video with opus (ogg vorbis) audio tracks.

mkdir meta
find . -name '*.opus' -print | while read f; do
  t=${f%-???????????.opus}
  t=${t/Roger Waters - /}
  t=${t#*/}
  a=${t%/*}
  t=${t#*/}
  echo "<$a><$t>"
  mkdir -p "meta/$a"
  ffmpeg -v 0 -i "$f" -acodec copy -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.opus" </dev/zero
  ffmpeg -v 0 -i "$f" -acodec mp3  -metadata title="$t" -metadata artist="Roger Waters" -metadata album="$a" "meta/$a/$t.mp3" </dev/zero
done

The redirects are necessary because ffmpeg encoders seem to read from stdin and garble the "while read f" loop input