Funscript Compilation Maker

Hehe, I did the reverse and called out on Monday so I had some time to play around with it. It just sorta came to me last night and I nailed it in like 2 or 3 total code runs.

I think the great thing is that your tool still exports the clip_.mp4 files, so I can just combine those using mmg on my own and make a lossless result, I think, for when I’m just using 1 vid. It only works when videos are similarly encoded - you can just append them together with ffmpeg losslessly.

All right, I’ve enhanced the code yet again.

I really wanted that lossless clip combining functionality, so I added it in.

Now, if the source for all the clips comes from 1 video file, it directly calls ffmpeg using subprocess, and combines all the cut_.mp4 files sequentially, losslessly. Otherwise, it does the encode combine using moviepy. The file is named to indicate that it’s Lossless, and there’s a printout.

I also changed some dumb thing with the base path name, but realized that files were only saving to the wrong spot because of my IDE, so it didn’t really change anything lol.

I also fixed a bug where your second checkbox option for “Combine Scripts and Cut Videos” didn’t really provide the combined scripts.
I added another cool feature to make this second checkbox useful.
Now you’ll also have the .funscript file that belongs to each clip_.mp4 file, so you can use them individually if you want. Could be good for clipping apart compilation videos and such.

New code:

2 Likes

Okay so I’m finally getting some time to look at this and everything you did was excellent for the video + funscript generation, that works perfectly in my tests.

There is a problem with trying to generate only the funscript without doing any work on the videos. Since the duration of the clips is being used to set the offset, if the clips aren’t made there’s no offset to use. I don’t understand video processing enough to know why but the duration ends up being longer than just subtracting start time from end time.

I’ve disabled that checkbox for now while I see if I can figure out a way to calculate the offset without generating the clips.

1 Like

Yeahh, and the annoying part is that the video combining itself can still add in some time here and there, so it’s never quite perfect by calculating the offset the current way. I would almost need to like append clip1 to clip2 first, get the time of clip1+2 and subtract clip1’s time to calculate the offset, then add clip3 to clip1+2, subtract away the time from clip1+2 to get the offset, get 1+2+3+4 minus 1+2+3, etc. I’m assuming the time added is in between the clips, which is why it’s still a frame or two off. So much space usage though :pensive:

Also it seems like there are some artifacts/lost video in between the video clips with this ffmpeg method, so I’m playing around with it some more… I feel like this has to do with how the cut_ clips are created, because I can’t assemble them back with tools like mkvmerge mmg without the visual/audio issues.

I’ve always had a good experience with mkvmerge, so I’ll see if I can switch over to this library - https://pypi.org/project/pymkv/

so did u implement the update yet @charz1060 ? thanks to @hentaiprodigy69 and his quick guide I managed to get htis working. It may have already be stating something already known but, in terms of syncing the video to the funscript the tool does it perfectly. What is odd is the weird 500ms pausing of the video it just transitioned too.

1 Like

We still have to fix some of the stuff with combining the video, and the little glitchiness that occurs - I guess that’s the 500ms transition thing you’re referring to. I think @charz1060 put my latest updates in, but I gotta try the different library sometime.

I forget if this transition issue persists when you’re using 2 different videos, since an encode is enforced.

yeah thats what happend with me, I combined 2 different videos and got that weird lag.

All right, by some miracle, I finally solved the problem!

I tried that library, tried doing the ffmpeg python library, and nothing.
The trick was to just use mkvmerge itself by using subprocess, to do the clip splitting.
I knew for a while that it was the clips themselves that were messed up, the way ffmpeg creates them. They can’t even be reassembled using any tool - they always come out messed up.

Anyway, now, just install mkvmerge (I’m using Windows)
https://mkvtoolnix.download/downloads.html#windows

I basically just wrote a new version of the cut_video method that uses mkvmerge instead. I also changed the way the OS paths work a bit, and the new files will go to their original folder now.

The code:

I’m also banking on mkvmerge creating clips that are at least as long as the video length specified. If for some reason a 19 second clip is spat out when a 20 second clip is specified, it could mess up the funscript points here and there, but idk. Seems good so far.