47 lines
1.1 KiB
Bash
Executable File
47 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Check if the correct number of arguments is provided
|
|
if [ $# -ne 1 ]; then
|
|
echo "Usage: $0 <top-level-directory>"
|
|
exit 1
|
|
fi
|
|
|
|
# Get the top-level directory from the argument
|
|
TOP_DIR="$1"
|
|
|
|
# Define a temporary file to store the list of files
|
|
FILE_LIST="file_list.txt"
|
|
|
|
# Remove the temporary file if it exists
|
|
rm -f "$FILE_LIST"
|
|
|
|
# Find all segment directories and sort them numerically
|
|
dirs=$(find "$TOP_DIR" -maxdepth 1 -type d -name 'segment_*' | sort -V)
|
|
|
|
# Loop over the directories
|
|
for dir in $dirs; do
|
|
segment_name=$(basename "$dir")
|
|
segment_num=$(echo "$segment_name" | sed 's/segment_//')
|
|
|
|
#formatted_segment_number=$(printf "%03d" "$segment_num")
|
|
|
|
|
|
output_file="$dir/output_$segment_num.mp4"
|
|
#output_file="$dir/output_${formatted_segment_num}.mp4"
|
|
|
|
|
|
if [ -f "$output_file" ]; then
|
|
echo "file '$output_file'" >> "$FILE_LIST"
|
|
|
|
else
|
|
echo "No $output_file found in $dir"
|
|
fi
|
|
done
|
|
|
|
# Run ffmpeg to concatenate the videos
|
|
ffmpeg -f concat -safe 0 -i "$FILE_LIST" -c copy output_combined_test.mp4
|
|
|
|
# Remove the temporary file
|
|
rm "$FILE_LIST"
|
|
|