2

I'm trying to download a clip from a YouTube video, and I've gone the route of command line tools after I found out websites aren't cut out for this task.

Thanks to this AskUbuntu thread, I've got the following command:

ffmpeg -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=EkTHhk07nv4) -ss 00:05:12.70 -t 00:00:08.10 -c:v copy -c:a copy hamster.mp4

However, after running it with ffmpeg and youtube-dl in the same directory, and cmd running in the same directory, I get this output:

ffmpeg version git-2020-02-06-343ccfc Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20200122
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 39.100 / 56. 39.100
  libavcodec     58. 68.100 / 58. 68.100
  libavformat    58. 38.100 / 58. 38.100
  libavdevice    58.  9.103 / 58.  9.103
  libavfilter     7. 74.100 /  7. 74.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100

Followed by this error:

Unrecognized option '-get-url'.
Error splitting the argument list: Option not found

I've been unable to make sense of the error message, and searching for the error didn't give me any answers either. What could be wrong with the command?

0

1 Answer 1

0

I've been unable to make sense of the error message, and searching for the error didn't give me any answers either. What could be wrong with the command?

ffmpeg is attempting to parse the --get-url option intended for youtube-dl.

Explanation

The youtube-dl portion embedded in the ffmpeg command ex.:

$(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=EkTHhk07nv4)

is intended to:

  1. Execute the youtube-dl command (which returns a URL necessary to access the YouTube video).

  2. Substitute the results (i.e. the video URL returned) at the given point in the ffmpeg command.

Your issue seems to be that the $() syntax isn't being used to obtain/substitute the correct URL. So ffmpeg is reading the raw youtube-dl command and attempting to parse youtube-dl options that weren't intended for it.

A Possible Solution

One thing to be aware of is that $() isn't part of ffmpeg. That is, ffmpeg is not what is running youtube-dl or substituting the results.

In the case of Linux, whichever shell Linux is using does the execution and substitution before passing things along to ffmpeg.

It isn't clear to me which OS you're using, but I notice that you make a reference to "cmd" in your original post. If you are on Windows, cmd (the native Windows command prompt) doesn't support using $(). Instead, you should try your command with powershell:

powershell ffmpeg -i $(youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=EkTHhk07nv4) -ss 00:05:12.70 -t 00:00:08.10 -c:v copy -c:a copy hamster.mp4

Path Notes

Please note that using the powershell option above "as-is" assumes that ffmpeg and youtube-dl are available system-wide (i.e. the folders in which their respective executables reside are part of your Windows Path settings).

If you wish to add these folders to your Path, you can find a quick tutorial on how to do that here. Just make sure to add them to your System variables. Also, as a side note, you should restart Windows Explorer before attempting to use either ffmpeg or youtube-dl (this is often done with a reboot).

If you don't wish to make ffmpeg and youtube-dl available system-wide, you can modify the powershell command above with the respective paths to ffmpeg.exe and youtube-dl.exe. For instance, to use everything in the same folder, you could add .\ in front of each executable name:

powershell .\ffmpeg -i $(.\youtube-dl -f 22 --get-url https://www.youtube.com/watch?v=EkTHhk07nv4) -ss 00:05:12.70 -t 00:00:08.10 -c:v copy -c:a copy hamster.mp4
4
  • Ah! I didn't know the substitution syntax wasn't supported! In hindsight, the fact that I found it on AskUbuntu should've tipped me off... Though I'm having problems using this answer as well: powershell, even when ran in the same directory, doesn't recognise either ffmpeg or youtube-dl as a cmdlet, function, script file, or operable program, even when I use the exact command you sent in the exact same directory as before. Adding .exe doesn't change the error either. Is there something I'm missing?
    – user1086723
    Commented Feb 9, 2020 at 11:11
  • 1
    I've updated my answer. But in short, the powershell command above assumes that ffmpeg and youtube-dl are part of your Windows Path settings (environment variables). Or rather, the folders that contain them are. If this isn't the case, you'll need to add the paths to each executable in the command. For the "current folder", you can use .\ instead of typing out the full path (if you wish). Commented Feb 9, 2020 at 12:13
  • Ah, that worked, thank you so much for helping!
    – user1086723
    Commented Feb 9, 2020 at 15:03
  • 1
    Glad to assist. =) Commented Feb 9, 2020 at 21:42

You must log in to answer this question.