Youtube: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 275: Line 275:
=== '''ytfzf''': search & play or download ===
=== '''ytfzf''': search & play or download ===
* https://github.com/pystardust/ytfzf
* https://github.com/pystardust/ytfzf
* antiX-21 starts to use ytfzf to replace mps-youtube. See [https://antixlinux.com/antix-21-grup-yorum-released/ antiX-21 (Grup Yorum) released]
* [https://www.makeuseof.com/watch-youtube-videos-in-linux-terminal/ How to Watch YouTube Videos in the Linux Terminal With ytfzf]. It uses '''yt-dlp''' to download & stream the video to '''mpv'''.
* [https://www.makeuseof.com/watch-youtube-videos-in-linux-terminal/ How to Watch YouTube Videos in the Linux Terminal With ytfzf]. It uses '''yt-dlp''' to download & stream the video to '''mpv'''.
** It's useful to create an alias in ~/.bashrc e.g. '''alias youtube="ytfzf"'''
** It's useful to create an alias in ~/.bashrc e.g. '''alias youtube="ytfzf"'''
Line 288: Line 289:
<pre>
<pre>
sudo apt install jq mpv fzf  # youtube-dl  
sudo apt install jq mpv fzf  # youtube-dl  
cd github
sudo apt install build-essential  # neeed 'make'
~/github$ cd ytfzf/
cd ytfzf/
~/github/ytfzf$ sudo make install
sudo make install
~/github/ytfzf$ cd
sudo make install doc  # optional
# WARNING: The script ueberzug is installed in '/home/brb/.local/bin' which is not on PATH.
which ytfzf
sudo apt install python3-pip
# /usr/local/bin/ytfzf
pip3 install ueberzug
 
export PATH=/home/brb/.local/bin:$PATH
# sudo apt install python3-pip
ytfzf -t scRNA  # -t means thumbnails,  scRNA is an example of some keywords
# pip3 install ueberzug # not working now
# export PATH=/home/brb/.local/bin:$PATH
 
sudo apt install socat  # to use mpv as the thumbnail viewer
ytfzf -T mpv -t scRNA  # -t means thumbnails,  scRNA is an example of some keywords
            # Note two mpv windows will be opened.
            # resize the 'terminal'-like mpv window so the thumbnail window is
            #    next to the 'terminal'-like mpv window
ytfzf -d scRNA  # -d means download
ytfzf -d scRNA  # -d means download
ytfzf URL      # same as 'mpv URL'
$ mpv --version
mpv 0.35.1 Copyright 2000-2023 mpv/MPlayer/mplayer2 projects


$ ytfzf --version
$ ytfzf --version
ytfzf: 1.0.0
ytfzf: 2.5.5


$ ytfzf --help
$ ytfzf --help

Revision as of 07:00, 6 May 2023

Download videos

VLC

See VLC tips.

  1. Play the video in VLC
  2. On VLC, check Tools -> Codec information and find a URL there
  3. Open the URL on a browser. Right click the video and choose to save the video.

The method works for youtube and vimeo videos.

Firefox/Chrome add-on

3 Easy Ways to Download YouTube Videos in Ubuntu and Other Linux Distributions

Video DownloadHelper add-on works fine when I test it on Firefox and Chrome. I need to install an app Video DownloadHelper companion app (the source code is on Github) in order to use the extension. It saves the videos to ~/dwhelper folder.

Online websites

Host your own downloader

Youtube-dl

stuttering

https://github.com/ytdl-org/youtube-dl/issues/29326#issuecomment-966416070

VERSION=8e069597c658810567ced5f8046dc5d14ab93037
wget https://github.com/ytdl-org/youtube-dl/archive/$VERSION.zip
unzip $VERSION.zip
cd youtube-dl-$VERSION
sudo pip install .

mpsyt: mps-youtube (mp3 + stream + youtube)

By default, mps-youtube is basically a YouTube audio player (and downloader), but you can enable external video playback (via mpv or MPlayer) from its options. Check out

  • An article on webupd8.
  • More keyboard controls can be found on the webpage of mps.

Installation on Linux (works on Odroid with low CPU usage for audio stream from youtube but Odroid gives dirty noise when I played the music).

sudo apt-get install python3-pip
sudo pip3 install mps-youtube
sudo pip3 install youtube_dl

# On Ubuntu/Mint. Do not use mplayer. Use mpv instead.
# sudo add-apt-repository ppa:mc3man/mpv-tests
# sudo apt-get update && sudo apt-get install mpv

mpsyt   # launch
set player mpv
pl https://www.youtube.com/playlist?list=PL6h94tLpXv3LabUa7B0tCz7K0pI5ZzZEi   # a playlist
h       # help
Space   # pause
p       # play
q       # quit mpsyt

h search
url https://www.youtube.com/watch?v=hgIfZz8STLk   # retrieve specific youtube video by url or id

Installation on Windows

Some highlight

  • Search
  • Local playlist
  • support YouTube Playlists
  • Download
  • Music Album Matching

If something is wrong with using 'set' command, just run rm -rf ~/.config/mps-youtube/ and restart everything.

By default, it only streams audio. To watch the video, use set show_video true.

Below is what I got from the set command (as you can see the default player is mpv)

  Key                 Value                                                  
  order             : relevance
  user_order        : 
  max_res           : 2160p
  player            : mpv
  playerargs        : 
  encoder           : 0 [None]
  notifier          : 
  checkupdate       : True
  show_mplayer_keys : True
  fullscreen        : False
  show_status       : True
  columns           : 
  ddir              : /home/odroid/Downloads/mps
  overwrite         : True
  show_video        : False
  search_music      : True
  window_pos        : 
  window_size       : 
  download_command  : 
  audio_format      : auto
  api_key           : AIzaSyCIM4EzNqi1in22f4Z3Ru3iYvLaY8tc3bo

The screenshot shows mpsyt contains basic playing keyboard shortcuts.

Mps-youtube.png

[Update 4-7-2017]: to fix an error Signature extraction failed: Traceback (most recent call last):

sudo apt-get remove -y youtube-dl  # Removing youtube-dl (2014.02.17-1) ...
sudo pip3 install -U youtube-dl

$ youtube-dl --version
2017.04.11

mp3 download

mpv

  • Play youtube audio only
    mpv link_to_youtube_vid --no-video
    
  • Open YouTube (And More) Videos From Your Web Browser With mpv [Firefox, Chrome]. Using this is especially useful if your web browser doesn't support hardware-accelerated video playback.
    sudo apt install mpv
    mpv --ytdl-format="bestvideo[height<=?1080]+bestaudio/best" <URL_of_Video>
    
    mpv --start=56:00 Some_YT_URL    # include time
    mpv https://youtu.be/JlHsTd7nJW0?t=16  # embed time in the URL
    
  • Record live youtube video. For some reason, mp4 or mkv format does not work.
    mpv --stream-record=video.ts https://youtu.be/UCG1aXVO8H8
    
  • Keyboard shortcuts:
    • Shift+o: toggle show progress
    • volume control: 9/0
    • m: mute
    • Upper/down arrow: seek 60 seconds
    • Left/right arrow: seed 5 seconds
    • [: decrease speed
    • ]: increase speed
    • s: take a screenshot
    • q: quit, save current position

yt-dlp: download youtube video