diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 9b30f9f..1cec6fa 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -55,18 +55,27 @@ jobs: - name: Move necessary files to Danser directory shell: bash run: | + echo "Moving necessary files to Danser directory..." mkdir -p "$DANSER_SKINS_DIR" mv "$SKINS_DIR"/* "$DANSER_SKINS_DIR" mkdir -p "$DANSER_MAPS_DIR" find "$MAPS_DIR" -type f -name '*.osz' -exec mv -t "$DANSER_MAPS_DIR" {} + + echo "Files moved." - name: Generate Danser videos shell: bash run: | + set +e + JSON_FILE="$TIMESTAMPS_JSON" mapfile -t REPLAYS < <(find "$REPLAY_DIR" -type f -name "*.osr") - [ ! -f "$JSON_FILE" ] && exit 0 + if [ ! -f "$JSON_FILE" ]; then + echo "WARNING: Timestamps JSON file not found at $JSON_FILE - skipping video generation" + exit 0 + fi + + echo "Found $(echo "${REPLAYS[@]}" | wc -w) replay files" choose_skin() { local name="$1" @@ -81,71 +90,132 @@ jobs: esac } + processed=0 + skipped=0 + for REPLAY in "${REPLAYS[@]}"; do - [ ! -f "$REPLAY" ] && continue + if [ ! -f "$REPLAY" ]; then + echo "WARNING: Replay file not found: $REPLAY" + continue + fi + REPLAY_NAME=$(basename "$REPLAY" .osr) STAGE="${REPLAY_NAME%%_*}" + echo "Processing replay: $REPLAY_NAME" + ENTRY=$(jq -c --arg name "$REPLAY_NAME" ' - .[] | map(select(.name == $name)) | .[]' "$JSON_FILE") + .[] | map(select(.name == $name)) | .[]' "$JSON_FILE" 2>/dev/null) if [ -z "$ENTRY" ]; then + echo " No timestamp entry found for $REPLAY_NAME - skipping" + ((skipped++)) continue fi - DONE=$(echo "$ENTRY" | jq -r '.done') + DONE=$(echo "$ENTRY" | jq -r '.done' 2>/dev/null) if [ "$DONE" = "true" ]; then + echo " Already processed $REPLAY_NAME - skipping" + ((skipped++)) continue fi - START=$(echo "$ENTRY" | jq -r '.start') - END=$(echo "$ENTRY" | jq -r '.end') + START=$(echo "$ENTRY" | jq -r '.start' 2>/dev/null) + END=$(echo "$ENTRY" | jq -r '.end' 2>/dev/null) + + if ! [[ "$START" =~ ^[0-9]+$ ]] || ! [[ "$END" =~ ^[0-9]+$ ]]; then + echo " Invalid timestamp format for $REPLAY_NAME - skipping" + ((skipped++)) + continue + fi + + if [ "$START" -eq 0 ] && [ "$END" -eq 0 ]; then + echo " Invalid timestamps (0,0) for $REPLAY_NAME - skipping" + ((skipped++)) + continue + fi OUT_VIDEO_DIR="$OUTPUT_DIR/$STAGE" OUT_VIDEO_FILE="$OUT_VIDEO_DIR/$REPLAY_NAME.mp4" - mkdir -p "$OUT_VIDEO_DIR" + mkdir -p "$OUT_VIDEO_DIR" 2>/dev/null SKIN=$(choose_skin "$REPLAY_NAME") + echo " Using skin: $SKIN" + echo " Timestamps: ${START}s - ${END}s" + echo " Generating video with danser-cli..." - xvfb-run -a "$DANSER_DIR/danser-cli" \ + if ! xvfb-run -a "$DANSER_DIR/danser-cli" \ -replay "$REPLAY" -record -skip -settings="tourneypreview" -skin="$SKIN" -start=$START -end=$END -noupdatecheck \ - -out="$REPLAY_NAME" + -out="$REPLAY_NAME" >/dev/null 2>&1; then + echo " ERROR: Danser failed for $REPLAY_NAME" + ((skipped++)) + continue + fi if [ -f "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" ]; then - mv "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" "$OUT_VIDEO_FILE" + echo " Moving video to output directory..." + mv "$DANSER_VIDEO_DIR/$REPLAY_NAME.mp4" "$OUT_VIDEO_FILE" 2>/dev/null - ffmpeg -hide_banner -loglevel error \ + echo " Post-processing with ffmpeg..." + ffmpeg_output=$(ffmpeg -hide_banner -loglevel error \ -ss 5 \ -i "$OUT_VIDEO_FILE" \ -c:v h264_nvenc -preset slow -rc vbr -cq 19 -b:v 10M -maxrate 20M \ -c:a aac -b:a 192k \ - "${OUT_VIDEO_FILE}.tmp.mp4" + "${OUT_VIDEO_FILE}.tmp.mp4" 2>&1) - mv "${OUT_VIDEO_FILE}.tmp.mp4" "$OUT_VIDEO_FILE" + if [ $? -ne 0 ]; then + echo " ERROR: FFmpeg failed for $REPLAY_NAME:" + echo "$ffmpeg_output" + ((skipped++)) + continue + fi + mv "${OUT_VIDEO_FILE}.tmp.mp4" "$OUT_VIDEO_FILE" 2>/dev/null + + echo " Marking as completed in timestamps..." tmp=$(mktemp) jq --arg name "$REPLAY_NAME" ' (.. | objects | select(has("name")) | select(.name == $name)) - |= (.done = true)' "$JSON_FILE" > "$tmp" && mv "$tmp" "$JSON_FILE" + |= (.done = true)' "$JSON_FILE" > "$tmp" && mv "$tmp" "$JSON_FILE" 2>/dev/null + + echo " Successfully generated: $OUT_VIDEO_FILE" + ((processed++)) + else + echo " Failed to generate video for $REPLAY_NAME" fi done + echo "" + echo "Summary:" + echo " Videos processed: $processed" + echo " Files skipped: $skipped" + + exit 0 + - name: Configure Git shell: bash run: | + echo "Configuring Git user settings..." git config user.email "arlind@sulej.ch" git config user.name "ci-bot" + echo "Git user configured." - name: Add and Commit changes shell: bash run: | + echo "Configuring Git settings..." git config advice.addIgnoredFile false + echo "Adding output files to Git..." git add outputs/ + echo "Committing changes..." git commit -m "[ci skip] push back from pipeline" -q || echo "No changes to commit" - name: Push changes and create tag shell: bash - run: git push origin main || echo "No changes to push" + run: | + echo "Pushing changes to repository..." + git push origin main || echo "No changes to push" diff --git a/.gitea/workflows/timestamps.json b/.gitea/workflows/timestamps.json index 5dc1a99..112b6be 100644 --- a/.gitea/workflows/timestamps.json +++ b/.gitea/workflows/timestamps.json @@ -59,7 +59,7 @@ { "name": "GF_HD2", "start": 0, "end": 0, "done": false }, { "name": "GF_HR1", "start": 0, "end": 0, "done": false }, { "name": "GF_HR2", "start": 0, "end": 0, "done": false }, - { "name": "GF_HR3", "start": 100, "end": 120, "done": false }, + { "name": "GF_HR3", "start": 0, "end": 0, "done": false }, { "name": "GF_DT1", "start": 0, "end": 0, "done": false }, { "name": "GF_DT2", "start": 0, "end": 0, "done": false }, { "name": "GF_DT3", "start": 0, "end": 0, "done": false }, diff --git a/maps/QF/.gitkeep b/maps/GF/.gitkeep similarity index 100% rename from maps/QF/.gitkeep rename to maps/GF/.gitkeep diff --git a/maps/GF/GF_HR3.osz b/maps/GF/GF_HR3.osz deleted file mode 100644 index bc13354..0000000 --- a/maps/GF/GF_HR3.osz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:7cf6609fc3de77b8a076b7f79c8a75b5b3f7f44712fb204a29b5ee1ca113d548 -size 5098771 diff --git a/maps/QF/QF_DT1.osz b/maps/QF/QF_DT1.osz new file mode 100644 index 0000000..676d6d6 --- /dev/null +++ b/maps/QF/QF_DT1.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9779bf623d0335fe478b7a0046c7ed0cb89fa79bb5a96cf6d6c2418f894d2d49 +size 6165315 diff --git a/maps/QF/QF_DT2.osz b/maps/QF/QF_DT2.osz new file mode 100644 index 0000000..98f31d8 --- /dev/null +++ b/maps/QF/QF_DT2.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ee2024025387faaea9c31925d536d7cd1d7ca2434772e0b80d17090fc792d38f +size 10209536 diff --git a/maps/QF/QF_DT3.osz b/maps/QF/QF_DT3.osz new file mode 100644 index 0000000..5ee5397 --- /dev/null +++ b/maps/QF/QF_DT3.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7334e5ca09fa54d1e22f4ed5eb754537b01411d9195dc6737df1f6e1084d85d9 +size 4273235 diff --git a/maps/QF/QF_FM1.osz b/maps/QF/QF_FM1.osz new file mode 100644 index 0000000..f7f9489 --- /dev/null +++ b/maps/QF/QF_FM1.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4d4dec47f146f0dd0057b2953c939be279b21d046d79b8f1bcba70667bda098 +size 9408786 diff --git a/maps/QF/QF_FM2.osz b/maps/QF/QF_FM2.osz new file mode 100644 index 0000000..caf2dff --- /dev/null +++ b/maps/QF/QF_FM2.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5288535e6f9326eee1a91995b269cc717a1959164066fd9f3b2743d4250f594c +size 8516698 diff --git a/maps/QF/QF_FM3.osz b/maps/QF/QF_FM3.osz new file mode 100644 index 0000000..1ba259c --- /dev/null +++ b/maps/QF/QF_FM3.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:815fe6eca2cff715e3c590907c2d5fd3b3f808a3c97bd26136bb535321db9690 +size 30904540 diff --git a/maps/QF/QF_FM4.osz b/maps/QF/QF_FM4.osz new file mode 100644 index 0000000..2fe295f --- /dev/null +++ b/maps/QF/QF_FM4.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2a021045bf7bbbc5ac1c9a0f76f112d9be86f88d6615a72ef5a07e3d3a3d529f +size 4982331 diff --git a/maps/QF/QF_FM5.osz b/maps/QF/QF_FM5.osz new file mode 100644 index 0000000..e0e5b3a --- /dev/null +++ b/maps/QF/QF_FM5.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cd9e9301f0f7495a3aa97a9b61f43f2a80775b9722ed8dcd07416ed2ddf3eb6d +size 3882337 diff --git a/maps/QF/QF_HD1.osz b/maps/QF/QF_HD1.osz new file mode 100644 index 0000000..981d024 --- /dev/null +++ b/maps/QF/QF_HD1.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:87bc7f55f27505defd92b8f32c4053099dd69f233081ddc7656fff2a8e13bebb +size 8925989 diff --git a/maps/QF/QF_HD2.osz b/maps/QF/QF_HD2.osz new file mode 100644 index 0000000..a0a075e --- /dev/null +++ b/maps/QF/QF_HD2.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:48625e893b5494c3d070599b51a60b2144a5b75ea02d0214e2c7f613ca508d44 +size 13226143 diff --git a/maps/QF/QF_HR1.osz b/maps/QF/QF_HR1.osz new file mode 100644 index 0000000..008c78a --- /dev/null +++ b/maps/QF/QF_HR1.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fe4e21640c85ac3dd15e021a3c0abd98ac535d8c3c6e26169904c8b9b739cdbe +size 11137063 diff --git a/maps/QF/QF_HR2.osz b/maps/QF/QF_HR2.osz new file mode 100644 index 0000000..a35b869 --- /dev/null +++ b/maps/QF/QF_HR2.osz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4fee1ccbcf55aa6ddc7029216657b7fcad5fa87542de0838e1112ad483fb1b17 +size 3330003 diff --git a/outputs/GF/GF_HR3.mp4 b/outputs/GF/GF_HR3.mp4 new file mode 100644 index 0000000..3cb4b69 --- /dev/null +++ b/outputs/GF/GF_HR3.mp4 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:03464951037bb4bb8b2daf6df859e2b17a70cb1a1fd2f2fd7d29d20522799fa4 +size 37816088 diff --git a/replays/GF/.gitkeep b/replays/GF/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/replays/GF/GF_FM1.osr b/replays/GF/GF_FM1.osr deleted file mode 100644 index 4fa6f32..0000000 --- a/replays/GF/GF_FM1.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:f811e9bac195a63b84836107427e870f9cd0dafc97315cce18bdcc046176a35a -size 75712 diff --git a/replays/GF/GF_HR3.osr b/replays/GF/GF_HR3.osr deleted file mode 100644 index 166e311..0000000 --- a/replays/GF/GF_HR3.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:80724c1c47f290af1c68565585a97bf42b54a47d46f6dcec706d7b9385bd1fbb -size 47771 diff --git a/replays/QF/QF_FM3.osr b/replays/QF/QF_FM3.osr new file mode 100644 index 0000000..037bf51 --- /dev/null +++ b/replays/QF/QF_FM3.osr @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fa8640e95e8e5985e186246cb15e86ae39fae219edb98d6805ef58aaa12ed73e +size 50603 diff --git a/replays/Ro16/.gitkeep b/replays/Ro16/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/replays/Ro16/Ro16_EZ1.osr b/replays/Ro16/Ro16_EZ1.osr deleted file mode 100644 index 7a4c3c2..0000000 --- a/replays/Ro16/Ro16_EZ1.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:19e3c88850187797c5a74af8cc089515881c7b6331f7e0c91540eecbdef45c6c -size 35460 diff --git a/replays/Ro16/Ro16_FM2.osr b/replays/Ro16/Ro16_FM2.osr deleted file mode 100644 index a499e6c..0000000 --- a/replays/Ro16/Ro16_FM2.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:153ab75c39b2c2d0691902da04af6210f2286927b61084782af3578c430b8257 -size 62771 diff --git a/replays/Ro16/Ro16_FM6.osr b/replays/Ro16/Ro16_FM6.osr deleted file mode 100644 index 0bab58f..0000000 --- a/replays/Ro16/Ro16_FM6.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:c93b776ac084f523828967c862714fe3110108d0cdf56816aedc7dd56eeaface -size 37795 diff --git a/replays/SF/.gitkeep b/replays/SF/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/replays/SF/SF_EZ1.osr b/replays/SF/SF_EZ1.osr deleted file mode 100644 index 8e68526..0000000 --- a/replays/SF/SF_EZ1.osr +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:81e93b0756d05e6e0b6b796e5bef15990df677677444d3695d9e9a874dd2c1c0 -size 27116