Last active
August 22, 2024 12:58
-
-
Save danperrout/e1382ddd9e4eca3b2f0015216f070754 to your computer and use it in GitHub Desktop.
Record a video in OBS than automatically cut the silence part. Put this script in the directory of the video.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script selects the most recent .mp4 video file in the current directory (or a specified file), | |
# extracts video and audio bitrates using ffprobe, and runs auto-editor (https://github.com/WyattBlue/auto-editor) for automatic video processing. | |
# Set the directory to the current path | |
VIDEO_DIR="$(pwd)" | |
# Check if an argument is provided | |
if [ $# -eq 1 ]; then | |
LATEST_VIDEO="$1" | |
else | |
# Find the most recent .mp4 file | |
LATEST_VIDEO=$(find "$VIDEO_DIR" -type f -name "*.mp4" -print0 | xargs -0 ls -t | head -n 1) | |
fi | |
echo "O vídeo mais recente é: $LATEST_VIDEO" | |
# Check if a file was found | |
if [ -z "$LATEST_VIDEO" ]; then | |
echo "No MP4 video files found in the current directory." | |
exit 1 | |
fi | |
echo "Processing file: $LATEST_VIDEO" | |
# Get the video bitrate | |
VIDEO_BITRATE=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "$LATEST_VIDEO") | |
echo "Video Bitrate: ${VIDEO_BITRATE} bps" | |
# Get the video bitrate | |
VIDEO_BITRATE=$(ffprobe -v error -select_streams v:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "$LATEST_VIDEO") | |
echo "Video Bitrate: ${VIDEO_BITRATE} bps" | |
# Add 300000 to the video bitrate | |
NEW_VIDEO_BITRATE=$((VIDEO_BITRATE + 300000)) | |
# Echo the new value | |
echo "New Video Bitrate: ${NEW_VIDEO_BITRATE} bps" | |
# Get the audio bitrate | |
AUDIO_BITRATE=$(ffprobe -v error -select_streams a:0 -show_entries stream=bit_rate -of default=noprint_wrappers=1:nokey=1 "$LATEST_VIDEO") | |
echo "Audio Bitrate: ${AUDIO_BITRATE} bps" | |
# Run auto-editor to get video statistics | |
echo "Running auto-editor to generate statistics..." | |
auto-editor "$LATEST_VIDEO" --stats | |
echo "Running auto-editor" | |
auto-editor "$LATEST_VIDEO" -b:v $NEW_VIDEO_BITRATE --no-open |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment