Last active
January 10, 2025 14:58
-
-
Save adrianjagielak/0dee9b9cb0bbf9194e7cdce592cde9db to your computer and use it in GitHub Desktop.
A shell script that uses ffmpeg to convert your video files into the correct format for the TinyTV2. This script takes one input parameter (the path to the video file), checks if the file is already an .avi, and then converts it with the appropriate settings.
This file contains hidden or 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 | |
# Check if the input parameter is provided | |
if [ -z "$1" ]; then | |
echo "Error: No video file specified." | |
echo "Usage: $0 <video_file>" | |
exit 1 | |
fi | |
INPUT_FILE="$1" | |
EXT="${INPUT_FILE##*.}" | |
BASENAME="${INPUT_FILE%.*}" | |
OUTPUT_FILE="${BASENAME}.avi" | |
# Check if the file already has an .avi extension | |
if [ "$EXT" == "avi" ]; then | |
echo "Error: The file is already an AVI file." | |
exit 1 | |
fi | |
# Convert the video | |
ffmpeg -i "$INPUT_FILE" \ | |
-vf "scale=210:135:force_original_aspect_ratio=increase,crop=210:135" \ | |
-c:v mjpeg -q:v 4 \ | |
-c:a pcm_u8 -ar 10000 -ac 1 \ | |
-r 24 \ | |
"$OUTPUT_FILE" | |
# Check if the conversion was successful | |
if [ $? -eq 0 ]; then | |
echo "Conversion successful: $OUTPUT_FILE" | |
else | |
echo "Error: Conversion failed." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Key Details of the Script:
Resolution and Aspect Ratio:
210x135
with aspect ratio preservation usingscale=210:135:force_original_aspect_ratio=increase
.crop=210:135
.Video Codec:
mjpeg
(Baseline) with a quality setting of-q:v 4
.Audio Codec:
pcm_u8
with a sample rate of10000 Hz
and 1 channel.Frame Rate:
24 fps
.Error Handling:
.avi
or if the conversion fails.Usage:
convert_to_tinytv2.sh
.path/to/video.avi
.