Skip to content

Commit

Permalink
Clip extraction (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
correa-brian authored Jun 21, 2023
2 parents 2a0dc99 + 1b0c0fb commit dd53290
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ To get started, check out the table of contents below and follow these steps:
- [Convert video to WebM](#convert-video-to-webm)
- [Edit two images and/or videos to display next to each other, horizontally](#create-a-horizontal-stack)
- [Resize an image](#resize-an-image)
- [Extract clip from a video](#extract-clip-from-a-video)
- [Extract frames from a video](#extract-frames-from-a-video)
- [Modify video speed](#modify-video-speed)

Expand Down Expand Up @@ -172,6 +173,15 @@ Usage:
```bash
sh index.sh resize assets/image.png 0.5
```
### Extract clip from a video
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.
Usage:
```bash
sh index.sh extract-clip assets/video.mp4 00:00:05 00:00:20
```
### Extract frames from a video
Expand Down
17 changes: 17 additions & 0 deletions library/extract-clip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

if [ "$#" -lt 3 ]; then
echo "Error: Insufficient args provided."
echo "Usage: ./script.sh <filename1> 00:00:05 00:00:10..."
exit 1
fi

arguments=("$@")

video_file_name="${arguments[0]}"
extension="${video_file_name##*.}"

startTime="${arguments[1]}"
endTime="${arguments[2]}"

ffmpeg -loglevel quiet -i "$video_file_name" -ss "$startTime" -to "$endTime" -c:v copy -c:a copy assets/clip."${extension}"
6 changes: 0 additions & 6 deletions library/gif.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/bash

# Check if the script is called with the correct number of arguments
if [ "$#" -eq 0 ]; then
echo "Error: No filenames provided."
echo "Usage: ./script.sh <filename1> <filename2> ..."
exit 1
fi

if [ "$#" -lt 1 ]; then
echo "Error: Insufficient number of arguments for filenames. Need at least one file."
echo "Usage: ./script.sh <filename1>"
Expand Down

0 comments on commit dd53290

Please sign in to comment.