Skip to content

Commit 56e3e01

Browse files
committed
will now also take a frame and save it to images, rendering the other tool useless (good)
1 parent 43ae42b commit 56e3e01

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

generate_mp4_media.sh

+19
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ if [[ -f "$CONFIG_FILE" ]]; then
7070

7171
TABLE_VIDEO=$(get_ini_value "CustomMedia" "TableVideo")
7272
echo -e "${YELLOW}TABLE_VIDEO: $TABLE_VIDEO${NC}"
73+
74+
TABLE_IMAGE=$(get_ini_value "CustomMedia" "TableImage") # ref for images folder
75+
echo -e "${YELLOW}TABLE_IMAGE: $TABLE_IMAGE${NC}"
7376
else
7477
echo -e "${RED}ERROR: config.ini not found. Exiting...${NC}"
7578
exit 1
@@ -143,6 +146,22 @@ capture_window_to_mp4() {
143146
# Capture a screenshot of the window
144147
import -window "$WINDOW_ID" "$FRAME_FILE"
145148
sleep "$FRAME_INTERVAL"
149+
150+
# Save the middle frame with the same base name as OUTPUT_FILE
151+
152+
if [[ $i -eq $((FRAME_COUNT / 2)) ]]; then
153+
local BASE_NAME
154+
local BASE_NAME=$(basename "$OUTPUT_FILE" .mp4)
155+
local IMAGE_DIR
156+
local IMAGE_DIR=$(dirname "$TABLE_IMAGE")
157+
mkdir -p "$IMAGE_DIR" # Ensure the directory exists
158+
cp "$FRAME_FILE" "${TABLE_DIR}/${IMAGE_DIR}/${BASE_NAME}.png"
159+
if [[ $? -ne 0 ]]; then
160+
echo "${RED}Error: Failed to copy frame to ${TABLE_DIR}/${IMAGE_DIR}/${BASE_NAME}.png${NC}" >&2
161+
else
162+
echo -e "Frame saved to ${GREEN}${TABLE_DIR}/${IMAGE_DIR}/${BASE_NAME}.png${NC}"
163+
fi
164+
fi
146165
done
147166

148167
# Assemble the screenshots into an MP4 video using ffmpeg

0 commit comments

Comments
 (0)