Youtube: Difference between revisions

From 太極
Jump to navigation Jump to search
Line 288: Line 288:
** Playlist (not yet)
** Playlist (not yet)
<pre>
<pre>
# Tested on new Ubuntu 22.04 Desktop x64
sudo apt install jq mpv fzf git python3-pip python3-wheel \
sudo apt install jq mpv fzf git python3-pip python3-wheel \
     python3-dev python3-xlib libx11-dev libxext-dev make
     python3-dev python3-xlib libx11-dev libxext-dev \
    libxres-dev make curl
git clone https://github.com/pystardust/ytfzf
cd ytfzf
sudo make install
 
# First test: failed
ytfzf  URL
# Got an error -
# [ytdl_hook] ERROR: [youtube] 5NJ6V8i1Xd8: Unable to extract uploader id
 
yt-dlp --version
sudo apt-get remove yt-dlp
sudo apt-get install python3-pip
pip3 install --user yt-dlp
nano ~/.bashrc
# add export PATH=$PATH:/home/brb/.local/bin
source ~/.bashrc
which yt-dlp
yt-dlp --version
 
# Handling ueberzug
# See https://github.com/WhiteBlackGoose/ueberzug-latest
pip install setuptools
git clone https://github.com/WhiteBlackGoose/ueberzug-latest && cd ueberzug-latest
sudo pip install -e .
 
# ytfzf -t cti   
# Works perfect!
</pre>
</pre>
<pre>
<pre>
Line 301: Line 330:
which ytfzf
which ytfzf
# /usr/local/bin/ytfzf
# /usr/local/bin/ytfzf
# sudo apt install python3-pip
# pip3 install ueberzug  # not working now
# export PATH=/home/brb/.local/bin:$PATH


sudo apt install socat  # to use mpv as the thumbnail viewer
sudo apt install socat  # to use mpv as the thumbnail viewer

Revision as of 14:16, 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