How to Cut and Download Youtube Videos using Command Line

In some of my free time, I am actively using Instagram, not to show off or seeing people’s life that I don’t even care about. For me, this social media is perfect for everyday reminders for positive feeds. Usually, people choose a youtube video at the best moment, then re-post it on Instagram as a short one-minute clip, and sometimes I do so.

Well, the process of downloading, cutting, then re-posting it on Instagram is easy but not a quick task, especially if you do it on your phone. Then I thought it would be better for us (people who loved to share short clips from youtube) if we can do that in just one step. But first, let’s check what are the tools available for this task.

In Search of Youtube Downloader

So I did a little search, and then found a popular youtube downloader repository on Github, youtube-dl. Unfortunately, it is not a mobile app, it’s made for PC, works on Linux, Mac, and Windows. It works well and is easy enough for me to download the youtube videos that I want. As simple as:

$ youtube-dl

And let the youtube-dl handle the rest.

Cut on The Best Moment

So now we have our video. Let’s cut it at the best moment that we want. For this, I found that FFmpeg has easy cut commands (source). Make sure it is already installed on your system.

$ ffmpeg -i source.mp4 -ss 00:00:05 -t 00:00:10 -c copy cut_video.mp4

The -i param is for input video, -s is for the starting point to cut, -t is for the length, and -c is for the output. Having these tools, we are able to combine and make our automation script to download and cut. However, there’s still a problem with this approach.

Another Problem

Most of the time, the clip that we want is short. The problem appears when we need a small clip from super-duper HD really long video. Download time will increase. It’s really wasteful if you just need a small part of it. Then, what can we do?


By the time I am writing this post, apparently, Youtube is capping download speed on any downloader including the youtube-dl to around 80KBps.

Then I search around and found another downloader. Meet yt-dlp which is the fork of youtube-dl, it contains various fixes and additional features. What surprised me is that it can download only part of the interval using ffmpeg using this command:

$ yt-dlp --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 00:41:21.00 -to 00:41:31.00" --no-check-certificate

Below is me downloading a part of a 57 minutes video only from minutes 41:21 to 41:31 is done in seconds, awesome! No need to download the whole part of the videos.

ibndias@xps15:~$ yt-dlp --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 00:41:21.00 -to 00:41:31.00" --no-check-certificate
[1] 197204
ibndias@xps15:~$ [youtube] dqvPzbO__bQ: Downloading webpage
[youtube] dqvPzbO__bQ: Downloading android player API JSON
[info] dqvPzbO__bQ: Downloading 1 format(s): 248+251
[download] Destination: Shahihu Fiqhis Sunnah  - Syarat-Syarat Tayamum l Ustadz Dr. Musyaffa Ad Dariny [dqvPzbO__bQ].webm
Input #0, matroska,webm, from '':
    encoder         : google/video-file
  Duration: 00:57:48.40, start: 0.000000, bitrate: 1514 kb/s
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1080, SAR 1:1 DAR 16:9, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
Input #1, matroska,webm, from '':
    encoder         : google/video-file
  Duration: 00:57:48.44, start: -0.007000, bitrate: 107 kb/s
    Stream #1:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Output #0, webm, to 'file:Shahihu Fiqhis Sunnah  - Syarat-Syarat Tayamum l Ustadz Dr. Musyaffa Ad Dariny [dqvPzbO__bQ].webm.part':
    encoder         : Lavf58.45.100
    Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 25 fps, 25 tbr, 1k tbn, 1k tbc (default)
    Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, fltp (default)
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame=  275 fps=0.0 q=-1.0 Lsize=    2414kB time=00:00:09.98 bitrate=1981.2kbits/s speed=23.7x    
video:2257kB audio:150kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.263868%
[ffmpeg] Downloaded 2471757 bytes
[download] 100% of 2.36MiB in 00:06

Now that we have this quick way to download part of youtube videos, I am wondering if we can have this on mobile apps or web apps.

I personally prefer web apps, whether it is through a VPS or maybe even just a pure PHP script is enough, let’s see if we can make it. ๐Ÿ™‚

Update: We Made It! Please Try! ๐Ÿ™‚

Finally, in some of my free time, I was able to create my own web service to cut the portion of youtube videos. Go to to try! Please try it a lot and give us some useful feedback. You can also add some captions for your trimmed videos for videos title, but if you just want to cut the videos, just leave the title fields empty. ๐Ÿ™‚

SHAVIQ stands for Share Videos Quickly

In the future, I am planning to add some style templates for captions. It will be good for sharing personalization. See you later! ๐Ÿ™‚

Leave a Reply

Your email address will not be published. Required fields are marked *