Skip to content

Commit dd53290

Browse files
authored
Clip extraction (#11)
2 parents 2a0dc99 + 1b0c0fb commit dd53290

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ To get started, check out the table of contents below and follow these steps:
6868
- [Convert video to WebM](#convert-video-to-webm)
6969
- [Edit two images and/or videos to display next to each other, horizontally](#create-a-horizontal-stack)
7070
- [Resize an image](#resize-an-image)
71+
- [Extract clip from a video](#extract-clip-from-a-video)
7172
- [Extract frames from a video](#extract-frames-from-a-video)
7273
- [Modify video speed](#modify-video-speed)
7374

@@ -172,6 +173,15 @@ Usage:
172173
```bash
173174
sh index.sh resize assets/image.png 0.5
174175
```
176+
### Extract clip from a video
177+
178+
This command will extract a clip from the video using timestamps. The command requires a start and end timestamp following this format: HH:MM:SS.
179+
180+
Usage:
181+
182+
```bash
183+
sh index.sh extract-clip assets/video.mp4 00:00:05 00:00:20
184+
```
175185
176186
### Extract frames from a video
177187

library/extract-clip.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
if [ "$#" -lt 3 ]; then
4+
echo "Error: Insufficient args provided."
5+
echo "Usage: ./script.sh <filename1> 00:00:05 00:00:10..."
6+
exit 1
7+
fi
8+
9+
arguments=("$@")
10+
11+
video_file_name="${arguments[0]}"
12+
extension="${video_file_name##*.}"
13+
14+
startTime="${arguments[1]}"
15+
endTime="${arguments[2]}"
16+
17+
ffmpeg -loglevel quiet -i "$video_file_name" -ss "$startTime" -to "$endTime" -c:v copy -c:a copy assets/clip."${extension}"

library/gif.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#!/bin/bash
22

33
# Check if the script is called with the correct number of arguments
4-
if [ "$#" -eq 0 ]; then
5-
echo "Error: No filenames provided."
6-
echo "Usage: ./script.sh <filename1> <filename2> ..."
7-
exit 1
8-
fi
9-
104
if [ "$#" -lt 1 ]; then
115
echo "Error: Insufficient number of arguments for filenames. Need at least one file."
126
echo "Usage: ./script.sh <filename1>"

0 commit comments

Comments
 (0)