This commit is contained in:
2026-04-12 20:20:35 +03:00
parent 503136d067
commit 189177f6bc
5 changed files with 70 additions and 85 deletions
+6
View File
@@ -53,6 +53,7 @@ TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
# Create output filename with timestamp prefix
OUTPUT_FILE="${DIRNAME}/${TIMESTAMP}_${FILENAME}.${EXTENSION}"
AUDIO_OUTPUT_FILE="${DIRNAME}/${TIMESTAMP}_${FILENAME}.mp3"
# Calculate duration
DURATION=$(echo "$END_SECONDS - $START_SECONDS" | bc)
@@ -62,11 +63,16 @@ echo "Start: ${START_SECONDS}s"
echo "End: ${END_SECONDS}s"
echo "Duration: ${DURATION}s"
echo "Output file: $OUTPUT_FILE"
echo "Audio output file: $AUDIO_OUTPUT_FILE"
echo ""
# Run ffmpeg to extract the portion
# Using -ss before -i for fast seeking, and -t for duration
ffmpeg -y -ss "$START_SECONDS" -i "$VIDEO_FILE" -t "$DURATION" -c copy "$OUTPUT_FILE"
# Extract audio only
ffmpeg -y -ss "$START_SECONDS" -i "$VIDEO_FILE" -t "$DURATION" -vn -q:a 2 "$AUDIO_OUTPUT_FILE"
echo ""
echo "Done! Output saved to: $OUTPUT_FILE"
echo "Audio saved to: $AUDIO_OUTPUT_FILE"