15. February 2018 4 min read

Download videos from YouTube and convert to mp3 from terminal

Did you ever wanted to download video from YouTube to listen of it on your mobile while you do not have internet access? And of course you are in Linux as it is simplest to work with Andorid phones. To download video from Youtube the good program is youtube-dl and to convert it you will use avconv (former ffmpeg). It is very simple to download YouTube video from terminal as well as conversion. In 2018 it is reduced to 1 simple command.

# youtube-dl can now directly  use avconv to convert to mp3
youtube-dl --extract-audio --audio-format mp3 --prefer-avconv --embed-thumbnail https://url_to_video

Because YouTube is constantly updating the interface might change so you will occasionally get errors like:


[youtube] aAiVsqfbn5g: Downloading js player vfl5C38RC
ERROR: Signature extraction failed: Traceback (most recent call last):
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1380, in _decrypt_signature
    video_id, player_url, s
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1293, in _extract_signature_function
    cache_res = res(test_string)
  File "/home/cmo/.local/lib/python3.7/site-packages/youtube_dl/extractor/youtube.py", line 1356, in 
    return lambda s: initial_function([s])
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/jsinterp.py", line 258, in resf
    res, abort = self.interpret_statement(stmt, local_vars)
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/jsinterp.py", line 56, in interpret_statement
    v = self.interpret_expression(expr, local_vars, allow_recursion)
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/jsinterp.py", line 92, in interpret_expression
    m.group('expr'), local_vars, allow_recursion - 1)
  File "/home/user/.local/lib/python3.7/site-packages/youtube_dl/jsinterp.py", line 211, in interpret_expression
    raise ExtractorError('Unsupported JS expression %r' % expr)
youtube_dl.utils.ExtractorError: Unsupported JS expression '[16668072,null,function(c,d){for(var e=64,f=[]'; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
 (caused by ExtractorError("Unsupported JS expression '[16668072,null,function(c,d){for(var e=64,f=[]'; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.")); please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.

need to keep your youtube-dl up-to-date with


pip3 install -U youtube-dl

Newest from this category: