27 lines
779 B
Bash
Executable File
27 lines
779 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if all required arguments are provided
|
|
if [ $# -lt 4 ]; then
|
|
echo "Usage: $0 <input_file> <output_file> <start_time> <duration>"
|
|
echo ""
|
|
echo "Arguments:"
|
|
echo " <input_file> Path to the input video file."
|
|
echo " <output_file> Path to the output video file."
|
|
echo " <start_time> Start time in format HH:MM:SS or seconds."
|
|
echo " <duration> Duration of the segment in format HH:MM:SS or seconds."
|
|
echo ""
|
|
echo "Example:"
|
|
echo " $0 input.mp4 output.mp4 00:01:00 30"
|
|
echo ""
|
|
exit 1
|
|
fi
|
|
|
|
# Assign input arguments to variables
|
|
input_file=$1
|
|
output_file=$2
|
|
start_time=$3
|
|
duration=$4
|
|
|
|
# Run ffmpeg command
|
|
ffmpeg -i "$input_file" -ss "$start_time" -t "$duration" -vcodec copy -acodec copy "$output_file"
|