Last active
July 12, 2023 08:23
-
-
Save seanghay/c04cf5f661dfa21114fb284e1a1c548c to your computer and use it in GitHub Desktop.
Download & Trim Video using yt-dlp and ffmpeg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Download & Trim Video | |
# ./run.sh video_id out.mp4 00:00 1:00 | |
OUTPUT_FILE=$2 | |
VIDEO_ID=$1 | |
yt-dlp --quiet --force-overwrites \ | |
-f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best" \ | |
--output $OUTPUT_FILE $VIDEO_ID | |
ffmpeg -hide_banner \ | |
-loglevel error \ | |
-y -ss 00:$3 -to 00:$4 \ | |
-i $OUTPUT_FILE \ | |
-c copy "${OUTPUT_FILE%.*}.trim.mp4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment