Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First-class movie creation mode #542

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Debilski
Copy link
Member

@Debilski Debilski commented Nov 12, 2018

Please do not yet merge. The new code as well as the surrounding old Tk code needs some more polishing.

This adds the highly sought-after (#531, #524 (comment)) ‘automatic replay movie creation mode’ to Pelita, which uses Tk’s Canvas.postscript function to write a postscript representation. As the generated postscript depends on what is shown on the screen, this mode also activates a few changes in the UI representation.

  1. The canvas size will be resized such that each square has a size of 24x24 (open for discussion),
  2. the status part of the UI will be hidden during the replay as it cannot be transformed to Postscript (it is not a Canvas) and hiding it makes some of the calculations needed for proper resizing easier.

Usage:

$ pelita --dump replay.json --null   # I think we should rename --dump though
...
$ pelita --replay replay.json --snapshot-folder my_replay/
$ ninja -C my_replay/
$ vlc my_replay/movie.mp4

For personal convenience, I am creating a ninja.build automatically. Not strictly needed since we are only expected to convert it once (except for testing, where it is useful) and a bash script should do just fine. But parallelisation is nice. :)

Current drawbacks:

  • The snapshot mode creates two ps files. For the header and the game canvas. Both of them need to be converted to a png with Image Magic with proper settings to have the right amount of anti-aliasing.
  • The status bar is missing. So e.g. the name of the layout is not shown.
  • It is not clear which font will be used, so it is potentially very ugly looking.
  • The first few frames should not be snapshotted (at least not before the game knows the names of the teams).
  • ffmpeg needs to know the output dimensions and introduces some further rescaling.
  • If the game window is resized during snapshotting, things will get weird.
  • Creating the movie has to be done with external tools.

@codecov-io
Copy link

codecov-io commented Nov 12, 2018

Codecov Report

Merging #542 into master will decrease coverage by 0.62%.
The diff coverage is 2.12%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #542      +/-   ##
==========================================
- Coverage   62.87%   62.24%   -0.63%     
==========================================
  Files          33       33              
  Lines        4611     4656      +45     
==========================================
- Hits         2899     2898       -1     
- Misses       1712     1758      +46
Impacted Files Coverage Δ
pelita/scripts/pelita_main.py 0% <0%> (ø) ⬆️
pelita/ui/tk_viewer.py 0% <0%> (ø) ⬆️
pelita/ui/tk_canvas.py 0% <0%> (ø) ⬆️
pelita/scripts/pelita_tkviewer.py 0% <0%> (ø) ⬆️
pelita/libpelita.py 51.95% <33.33%> (-0.38%) ⬇️
pelita/player/RandomExplorerPlayer.py 84.21% <0%> (-5.27%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 57f2cb0...2541ae1. Read the comment docs.

@Debilski
Copy link
Member Author

  • Converting on macOS is really slow…

@Debilski
Copy link
Member Author

Debilski commented Jan 26, 2019

Currently I would much prefer looking into a solution that just uses a Qt interface (or we hand-craft a direct-to-png writer) and directly saves the canvas to png. Converting ps to png takes maybe 10 seconds per frame which is far too much time.

@Debilski
Copy link
Member Author

Let’s go full svg. It looks very all right and is quite fast to export (ie. not noticeable). That means we can export it already while the tournament is running.

image

@Debilski
Copy link
Member Author

Additional open idea: Do we actually need mp4 video files? Maybe an animated Javascript canvas is the better solution for presenting the matches after the tournament anyway. Obviously low priority.

@Debilski Debilski force-pushed the feature/create_movie branch 2 times, most recently from 8e17c7f to 2299359 Compare August 13, 2019 17:54
@codecov-commenter
Copy link

codecov-commenter commented Aug 17, 2021

Codecov Report

Merging #542 (088bfaa) into main (98d4810) will decrease coverage by 0.07%.
The diff coverage is 40.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #542      +/-   ##
==========================================
- Coverage   85.39%   85.32%   -0.08%     
==========================================
  Files          21       21              
  Lines        2301     2303       +2     
==========================================
  Hits         1965     1965              
- Misses        336      338       +2     
Impacted Files Coverage Δ
pelita/game.py 86.06% <40.00%> (-0.48%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98d4810...088bfaa. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants