project-slippi / slippi-launcher

The way to play Slippi Online and watch replays.
GNU General Public License v3.0
241 stars 125 forks source link

Export Clip to Video File Directly #318

Open TrevorBrunette opened 2 years ago

TrevorBrunette commented 2 years ago

Short Summary

I think it would be worthwhile to add a feature where a user can simply (i.e. in less than 10 mouse clicks) export (part of) a Slippi replay to an mp4, avi, gif, or really whatever video format would be easiest to implement.

User Interface

My idea for a user interface would be as simple as the dolphin window showing the current frame of the game above a window to control it. The window would have a pause/play button and a slider to seek specific locations in the replay and a selector where you can drag the start and stop frames of the video. For instance if "[" is the start of the recording, "|" is the current frame, and "]" is the end of the recording, each of these could be adjusted by dragging it with a left click.

[|-----------------------------------------------------------------] ----[---|----------------------------------------------------------] --------[----------|-----------------------------------]------------

With this, the user would be able to seek forwards and backwards in the replay to select which region of it they would like to record. After the user has selected the duration, perhaps the could click a box which brings up a system dialog to choose where and with what name to save the file. After that, the preview of Dolphin to close and the GUI would display a progress bar of the recording progress.

It also makes sense that a queue could be made of files and their start and end frames so that a user can queue more videos to output while one is processing. A small text display could be used to show the status of the queue i.e. "Processing recording 1/3".

Technical Details

Would it be possible to start and use a headless Dolphin instance for this? That seems like the most unobtrusive way to complete the recording. It seems like it would also be reasonable to run the emulation an uncapped framerate to increase the speed of recording and allow for a user configurable resolution, bitrate, ISO (for texture packs), etc. The framerate of the output video could also be configured here but that has more to do with FFmpeg.

Implementation Using Existing Software

Dolphin already supports frame dumping, and with FFmpeg, creating the video file would likely become as simple as combing the video and audio files. IIRC, Dolphin frame dumping with FFmpeg outputs the video (avi) and audio (Audio/dspdump) into separate files. Encoding the video into different formats (e.g. mp4, webm, flv) could also be a feature, and FFmpeg would do a majority of the work for this as well.

slp-to-mp4 and slp-to-video seem to have been built to serve these purposes, however it does not seem as if they are being actively maintained, and it would be an extremely useful feature to have in the base Slippi Launcher. It may be possible to use some of their existing code to aid in this (licensing permitting).

Another issue (which might be better off closed and linked to this) was opened similar to this, and Jas Laferriere recommended using Clippi, nonetheless this seems like a potentially very useful feature to have and (time permitting) I may begin to do more research to see if I might be able to work in implementing it.

Concerns

I don't know how difficult it would be to start Dolphin for frame dumping headlessly, however it would make this the least intrusive to the user. I figure this would be a lot of work, particularly integrating the HTML/CSS user interface to interact with the Dolphin emulator for seeking and previewing when setting up the recording; I do not know how possible this would be.

NikhilNarayana commented 2 years ago

my biggest concern, and probably the only one that matters, is that users will experience huge computer performance drops while frame dumping because encoding is a strenuous task and then complain about the feature. I don't know if there is any amount of signposting that will stop that though.

that is a big reason I recommend Clippi, it has the relatively small barrier to entry but using OBS helps users understand their issues better.