mediasnacks 0.12.2 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.zsh/completions/_mediasnacks +3 -2
- package/README.md +2 -1
- package/package.json +1 -1
- package/src/cli.js +2 -1
- package/src/vsplit.sh +46 -0
- package/src/vtrim.sh +32 -0
- package/src/vcut.sh +0 -28
|
@@ -12,13 +12,14 @@ _mediasnacks_commands=(
|
|
|
12
12
|
'framediff:ffplay with a filter for diffing adjacent frames'
|
|
13
13
|
'vdiff:Plays a video with the difference of two videos'
|
|
14
14
|
'vconcat:Concatenates videos'
|
|
15
|
+
'vtrim:Trims video from start to end time'
|
|
15
16
|
'dlaudio: yt-dlp best audio'
|
|
16
17
|
'dlvideo: yt-dlp best video'
|
|
17
18
|
'unemoji:Removes emojis from filenames'
|
|
18
19
|
'rmcover:Removes cover art'
|
|
19
20
|
'curltime:Measures request response timings'
|
|
20
21
|
'gif:Video to GIF'
|
|
21
|
-
'
|
|
22
|
+
'vsplit:Split video at multiple time points'
|
|
22
23
|
'flattendir:Moves unique files to the top dir and deletes empty dirs'
|
|
23
24
|
)
|
|
24
25
|
|
|
@@ -29,7 +30,7 @@ fi
|
|
|
29
30
|
|
|
30
31
|
local cmd="$words[2]"
|
|
31
32
|
case "$cmd" in
|
|
32
|
-
avif|resize|sqcrop|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|vdiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|
|
|
33
|
+
avif|resize|sqcrop|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|vdiff|vconcat|vtrim|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|vsplit|flattendir)
|
|
33
34
|
_files
|
|
34
35
|
;;
|
|
35
36
|
qdir)
|
package/README.md
CHANGED
|
@@ -23,6 +23,7 @@ Commands:
|
|
|
23
23
|
- `framediff`: Plays a video of adjacent frames diff
|
|
24
24
|
- `vdiff`: Plays a video with the difference of two videos
|
|
25
25
|
- `vconcat`: Concatenates videos
|
|
26
|
+
- `vtrim`: Trims video from start to end time
|
|
26
27
|
|
|
27
28
|
- `dlaudio`: yt-dlp best audio
|
|
28
29
|
- `dlvideo`: yt-dlp best video
|
|
@@ -32,7 +33,7 @@ Commands:
|
|
|
32
33
|
|
|
33
34
|
- `curltime`: Measures request response timings
|
|
34
35
|
- `gif`: Video to GIF
|
|
35
|
-
- `
|
|
36
|
+
- `vsplit`: Split video at multiple time points
|
|
36
37
|
|
|
37
38
|
- `flattendir`: Moves unique files to the top dir and deletes empty dirs
|
|
38
39
|
|
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -20,6 +20,7 @@ const COMMANDS = {
|
|
|
20
20
|
vdiff: ['vdiff.sh', 'Plays a video with the difference of two videos'],
|
|
21
21
|
|
|
22
22
|
vconcat: ['vconcat.sh', 'Concatenates videos'],
|
|
23
|
+
vtrim: ['vtrim.sh', 'Trims video from start to end time'],
|
|
23
24
|
|
|
24
25
|
dlaudio: ['dlaudio.sh', 'yt-dlp best audio'],
|
|
25
26
|
dlvideo: ['dlvideo.sh', 'yt-dlp best video'],
|
|
@@ -29,7 +30,7 @@ const COMMANDS = {
|
|
|
29
30
|
|
|
30
31
|
curltime: ['curltime.sh', 'Measures request response timings'],
|
|
31
32
|
gif: ['gif.sh', 'Video to GIF'],
|
|
32
|
-
|
|
33
|
+
vsplit: ['vsplit.sh', 'Split video at multiple time points'],
|
|
33
34
|
flattendir: ['flattendir.sh', 'Moves all files to top dir and deletes dirs']
|
|
34
35
|
}
|
|
35
36
|
|
package/src/vsplit.sh
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
if [ "$#" -lt 2 ]; then
|
|
4
|
+
cat << EOF
|
|
5
|
+
Usage:
|
|
6
|
+
$(basename $0) <split-time-1> [split-time-2 ...] <video-file>
|
|
7
|
+
|
|
8
|
+
Examples:
|
|
9
|
+
$(basename $0) 123.45 input.mp4
|
|
10
|
+
$(basename $0) 60 120 180 video.mov
|
|
11
|
+
$(basename $0) 00:01:00 00:02:00 00:03:00 input.mkv
|
|
12
|
+
EOF
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
VIDEO="${@[-1]}"
|
|
17
|
+
SPLITS=("${@[1,-2]}")
|
|
18
|
+
|
|
19
|
+
if [ ! -f "$VIDEO" ]; then
|
|
20
|
+
echo "Error: file not found: $VIDEO"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
BASENAME=$(basename "$VIDEO")
|
|
25
|
+
DIRNAME=$(dirname "$VIDEO")
|
|
26
|
+
EXT="${BASENAME##*.}"
|
|
27
|
+
NAME="${BASENAME%.*}"
|
|
28
|
+
|
|
29
|
+
SEGMENT_COUNT=$((${#SPLITS[@]} + 1))
|
|
30
|
+
|
|
31
|
+
for (( i=1; i<=$SEGMENT_COUNT; i++ )); do
|
|
32
|
+
OUTFILE="$DIRNAME/${NAME}_${i}.$EXT"
|
|
33
|
+
|
|
34
|
+
if [ $i -eq 1 ]; then
|
|
35
|
+
# First segment: from start to first split
|
|
36
|
+
ffmpeg -v error -y -i "$VIDEO" -t "${SPLITS[1]}" -c copy "$OUTFILE"
|
|
37
|
+
elif [ $i -eq $SEGMENT_COUNT ]; then
|
|
38
|
+
# Last segment: from last split to end
|
|
39
|
+
ffmpeg -v error -y -ss "${SPLITS[-1]}" -i "$VIDEO" -c copy "$OUTFILE"
|
|
40
|
+
else
|
|
41
|
+
# Middle segments: from split[i-1] to split[i]
|
|
42
|
+
PREV_SPLIT="${SPLITS[$((i-1))]}"
|
|
43
|
+
CURR_SPLIT="${SPLITS[$i]}"
|
|
44
|
+
ffmpeg -v error -y -ss "$PREV_SPLIT" -to "$CURR_SPLIT" -i "$VIDEO" -c copy "$OUTFILE"
|
|
45
|
+
fi
|
|
46
|
+
done
|
package/src/vtrim.sh
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
if [ "$#" -ne 3 ]; then
|
|
4
|
+
cat << EOF
|
|
5
|
+
Usage:
|
|
6
|
+
$(basename $0) <start-time> <end-time> <video-file>
|
|
7
|
+
|
|
8
|
+
Examples:
|
|
9
|
+
$(basename $0) 10 30 input.mp4
|
|
10
|
+
$(basename $0) 00:00:10 00:00:30 input.mkv
|
|
11
|
+
$(basename $0) 1:23.5 2:45.0 video.mov
|
|
12
|
+
EOF
|
|
13
|
+
exit 1
|
|
14
|
+
fi
|
|
15
|
+
|
|
16
|
+
START="$1"
|
|
17
|
+
END="$2"
|
|
18
|
+
VIDEO="$3"
|
|
19
|
+
|
|
20
|
+
if [ ! -f "$VIDEO" ]; then
|
|
21
|
+
echo "Error: file not found: $VIDEO"
|
|
22
|
+
exit 1
|
|
23
|
+
fi
|
|
24
|
+
|
|
25
|
+
BASENAME=$(basename "$VIDEO")
|
|
26
|
+
DIRNAME=$(dirname "$VIDEO")
|
|
27
|
+
EXT="${BASENAME##*.}"
|
|
28
|
+
NAME="${BASENAME%.*}"
|
|
29
|
+
|
|
30
|
+
OUTFILE="$DIRNAME/${NAME}.trim.$EXT"
|
|
31
|
+
|
|
32
|
+
ffmpeg -v error -y -ss "$START" -to "$END" -i "$VIDEO" -c copy "$OUTFILE"
|
package/src/vcut.sh
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
#!/bin/zsh
|
|
2
|
-
|
|
3
|
-
if [ "$#" -ne 2 ]; then
|
|
4
|
-
echo "Usage: $0 <video-file> <split-time>"
|
|
5
|
-
echo "Example:"
|
|
6
|
-
echo " $0 input.mp4 123.45"
|
|
7
|
-
echo " $0 input.mkv 00:02:03.500"
|
|
8
|
-
exit 1
|
|
9
|
-
fi
|
|
10
|
-
|
|
11
|
-
INPUT="$1"
|
|
12
|
-
SPLIT="$2"
|
|
13
|
-
|
|
14
|
-
if [ ! -f "$INPUT" ]; then
|
|
15
|
-
echo "Error: file not found: $INPUT"
|
|
16
|
-
exit 1
|
|
17
|
-
fi
|
|
18
|
-
|
|
19
|
-
BASENAME=$(basename "$INPUT")
|
|
20
|
-
DIRNAME=$(dirname "$INPUT")
|
|
21
|
-
EXT="${BASENAME##*.}"
|
|
22
|
-
NAME="${BASENAME%.*}"
|
|
23
|
-
|
|
24
|
-
OUT1="$DIRNAME/${NAME}_a.$EXT"
|
|
25
|
-
OUT2="$DIRNAME/${NAME}_b.$EXT"
|
|
26
|
-
|
|
27
|
-
ffmpeg -v error -y -i "$INPUT" -t "$SPLIT" -c copy "$OUT1"
|
|
28
|
-
ffmpeg -v error -y -ss "$SPLIT" -i "$INPUT" -c copy "$OUT2"
|