Talk: yt-dlp usage

#+topic : yt-dlp usage
#+date : 13-4-25
#+author : Krishna Subramaniyan

* YT-DLP Installation
** dependency
*** ffmpeg
** debian based distro
#+begin_src sh
  sudo apt update
  sudo apt install yt-dlp -y
#+end_src
** Arch based distro
#+begin_src sh
  sudo pacman -S yt-dlp
#+end_src
** Python pip package
#+begin_src sh
  pip install yt-dlp==2025.3.31
#+end_src
* Video Download
** Check Available Format
#+begin_src sh
  yt-dlp -F <Video-URL>
#+end_src

** Audio only
*** Download
#+begin_src sh
  yt-dlp -f 140 -o 'weeklyNews.m4a' https://www.youtube.com/live/FK_0VV2XmRM?feature=shared
#+end_src

*** Convert Format
#+begin_src sh
  yt-dlp -f 140 -x --audio-format mp3 -o test.mp3 https://www.youtube.com/live/FK_0VV2XmRM?feature=shared
#+end_src

** Video-Subtitle
*** List Available Subtitles
#+begin_src sh
  # Example 1
  yt-dlp --list-subs https://youtu.be/WZO8heIHlPk?feature=shared
  
  # Example 2
  yt-dlp --list-subs https://youtu.be/rfscVS0vtbw?feature=shared
#+end_src

*** Download Video
#+begin_src sh
  yt-dlp -f 399+140 --sub-langs 'en,ta' --write-auto-subs --embed-subs --merge-output-format mkv -o avengersTrailer.mkv https://youtu.be/eOrNdBpGMv8?feature=shared
#+end_src

*** Subtitle Alias
#+begin_src bash
  alias yt-dlp-sub="yt-dlp --sub-langs 'en' --write-auto-subs --embed-subs --merge-output-format mkv"
#+end_src

* PlayList
** Check Available Format
#+begin_src sh
  # first video url
  https://youtu.be/MPpF1A90N5U?feature=shared

  # Command
  yt-dlp -F https://youtu.be/MPpF1A90N5U?feature=shared
#+end_src
** Download Playlist
#+begin_src sh
  yt-dlp -f 614+140 -o '%(playlist_index)s %(title)s.%(ext)s' --playlist-items 1 https://youtube.com/playlist?list=PL0vwHm0AGyYNZuWKTJ6-4XlRYHzGNmeFn&feature=shared
#+end_src
* Direct Stream
** Example 1
#+begin_src sh
    # source link
    https://archive.org/details/tiruvalluva_1807_librivox/tiruvalluva_001_thiruvalluvar_128kb.mp3
  
    # list available format
    yt-dlp -F https://archive.org/details/tiruvalluva_1807_librivox/tiruvalluva_001_thiruvalluvar_128kb.mp3

    # stream video
    yt-dlp -f 3 -o -  https://archive.org/details/tiruvalluva_1807_librivox/tiruvalluva_001_thiruvalluvar_128kb.mp3 | vlc -
#+end_src
** Example 2
#+begin_src sh
  # video source
  https://www.youtube.com/live/H999s0P1Er0?feature=shared

  # list formats
  yt-dlp -F https://www.youtube.com/live/H999s0P1Er0?feature=shared

  # stream video
  yt-dlp -f 300 -o - https://www.youtube.com/live/H999s0P1Er0?feature=shared | vlc -
#+end_src
* Resource
** link 2 [[https://ostechnix.com/yt-dlp-tutorial/][stechnix]]
** link 1 [[https://github.com/yt-dlp/yt-dlp][yt-dlp official doc]]