trek-view / gopro2gsv

Processes .jpg images and .mp4/.360 videos shot on GoPro MAX or Fusion cameras and uploads to Google Street View.
Apache License 2.0
4 stars 0 forks source link

Allow user to set maximum output video length #27

Closed himynamesdave closed 9 months ago

himynamesdave commented 9 months ago

Currently we pack video in image->video mode at a rate of 5FPS with each video no longer than 300 seconds.

https://github.com/trek-view/gopro2gsv#video-processing

We should continue to pack videos a 5FPS but allow user to set a max_output_video_secs flag in all modes (as videos will now be turned into images to recreate video #26).

This will have a few limitations.

Limitation 1

The output video should always be at least 4 seconds long (contain 20 frames/gps points).

For image mode, this requires a change because the minimum input size of frames is currently 10, thus needs to be increased to 20 (https://github.com/trek-view/gopro2gsv#validation).

For video mode the input video length secs * fps extracts must be greater than 20.

e.g. 20*5 = 100 frames extracted = pass e.g. 10*0.2 = 2 frames extracted = fail

Limitation 2

Currently max video length output is 300 frames (one min). If input photos is more than 300, then multiple videos will be produced: https://github.com/trek-view/gopro2gsv#video-track

As max_output_video_secs now becomes variable, this may result in more (or less) videos being created when compared to the default.

This alone is not a problem, however the logic to split videos becomes important, and will need to be slightly modified.

As such, a sequence with 720 images will create three videos; two with 300 frames (1 min each) and one with 120 frames (24 seconds long). Each video name is appended with a number based on order, e.g. timelapse_0001.mp4, timelapse_0002.mp4.

Now we should always ensure that an output video is 20 frames, 4 secs long.

As such if the final video in the timelapse should always be >= 20 frames.

If the final video is 20 frames or more, then all earlier videos are packed to max_output_video_secs, and the last one is >=20 secs.

If it is calculated the final video is less than 20 frames or more, then the second to last video (penultimate video), is shortened by 20 frames (4 seconds). These 20 frames are then used in the final video, meaning the final video is the sum of the 20 frames carried over, and the frames for the last video already calculated (which were less than 20).

fqrious commented 9 months ago

sooo, after extracting as say 10fps, we still pack as 5fps?

himynamesdave commented 9 months ago

@fqrious correct.

We should not change how videos are packed. This already works well.

In your example, that output video will be twice as long as the input video, but it is correct.

himynamesdave commented 9 months ago

closing and tracking individual bugs seperately