Skip to content

Instantly share code, notes, and snippets.

@pavelfomin
Last active February 28, 2024 00:35
Show Gist options
  • Save pavelfomin/24a3ad56501c2cfee24a887696cf46c7 to your computer and use it in GitHub Desktop.
Save pavelfomin/24a3ad56501c2cfee24a887696cf46c7 to your computer and use it in GitHub Desktop.
Download portion of video / audio with youtube-dl / ffmpeg

Download the audio only

  • utlink='https://www.youtube.com/watch?v=bn9F19Hi1Lk'
  • get all video and audio links for the video
    • youtube-dl -F "$utlink"
    • pick the best mp4a audio only option (e.g. 140)
  • get a download link
    • audio=$(youtube-dl -f 140 -g "$utlink")
  • use audio download link in ffmpeg to download portion of the audio
    • download first 5 mins of the audio
      • ffmpeg -i "$audio" -t 300 -c:a libmp3lame waves300.mp3

Notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment