Skip to content

A lifesaver for anyone who is doing video clipping/translating or any need to download segments from Youtube. (.NET 8 Winform)

License

Notifications You must be signed in to change notification settings

jim60105/YoutubeSegmentDownloader

Repository files navigation

Youtube Segment Downloader

What's this?

A lifesaver for anyone who is doing video clipping/translating or any need to download segments from Youtube.

GitHub release (latest SemVer) GitHub Release Date GitHub all releases

Preview

Windows .NET 7.0 GitHub

The software can only be run on Windows x64 platforms.

Feature

Download Youtube video in segment
In detail, you can download only one segment in the middle of the video instead of downloading the whole video.

This software is built on yt-dlp and FFmpeg.
If you don't have them installed, this software will download them automatically at startup.

Can accept Youtube clips too!
Try to put this in the Youtube Link textbox: https://youtube.com/clip/UgkxdTb9o6I2pTr87wKgpO0kLEaZbYrkMDFv
It will be converted to id, start, and end time immediately.

Use the Youtube login status in your browser.
Select your login browser and download the membership video/your private video.

The output video format conforms to the Youtube recommendation for uploading!
Recommended upload encoding settings - YouTube Help

The download format can be specified.
Input the format such as 303+251

Note: The video will be downloaded in this format and will ALWAYS be re-encoded to mp4 format.
Re-encoded is needed after cutting the video. Please read the details below.

I18n 多國語系
我做了中文介面
I only speak Chinese. Give me PR if you make more languages!

It can accept any yt-dlp supported site.
I only support Youtube, but this application can theoretically be used on any site supported by yt-dlp.
The actual situation depends on the video format and whether ffmpeg can index it correctly, but it's still worth a try.
For reference, I have had success with Youtube, Twitch, and niconico.

Install

Get the latest release GitHub release (latest SemVer)

Please download and install with the setup.exe

  • Automatically check for upgrades when launching this software update
  • Setup installer will install .NET 7.0 Runtime for you
  • Setting shortcuts on the Desktop and Start Up Menu

Or you can just download YoutubeSegmentDownloader.exe, if you don't care about the above.

Why not just use yt-dlp with ffmpeg -ss -to?

Nope, not enough.

According to FFmpeg docs about -ss:

Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.

Then the download is actually a streaming copy, so you won't get an accurate cut of it.

For example, downloading this video from 230s ~ 250s

yt-dlp --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 230 -to 250" 89kXyUCenD0 

yt-dlp --download-sections "*230-250" is actually equivalent to --downloader ffmpeg --downloader-args "ffmpeg_i:-ss 230 -t 20" *ref

would result in a video duration of 29.98 seconds, with the first 7 seconds being corrupted. This is inaccurate by, well, about 10 seconds. This is because the last seek point is around 220s, so it cuts off 220s ~ 250s.

To solve this, use ffmpeg to seek it again with transcoding.

ffmpeg -sseof -20 -i just_downloaded.webm good.webm

-sseof likes the -ss option but relative to the "end of file".

So, you have to do two steps, plus a simple math calculation. It's not that much of a hassle, but it's enough to get a lazy programmer move.

LICENSE

This software is distributed under GPLv3.
Website: https://github.com/jim60105/YoutubeSegmentDownloader
Author: jim60105

This software uses FFmpeg licensed under the GPLv3.
FFmpeg binary distributions will be downloaded from here.
FFmpeg source code can be found here.

This software uses yt-dlp licensed under the Unlicense License.
yt-dlp binary distribution will be downloaded from here.

This software uses Xabe.FFmpeg licensed under the License Agreement with Non-commercial use - Attribution-NonCommercial-ShareAlike 3.0 Unported (CC BY-NC-SA 3.0).

This software uses Beautiful Flat Icons licensed under the GPLv2.
Icon source can be found here.


A winform project written in .NET 6 7 and CI/CD the ClickOnce installer on the github workflow.
Anyone want to turn it into MAUI? ¯\_(ツ)_/¯