0

We've been trying to crack this code all week, reaching out to everyone to see if you have any solutions?

  1. We want the user to upload a video and in the next step he will select a small 5 second loop of the video which will be made as a gif.
  2. Old developer was able to do this by splicing the video at 10 seconds instead of 5 but not re-encoding it meant that it would sometimes be beyond 12 seconds and in some cases less than 7.
  3. We changed the code to force keyframes with re encoding so that it splices the video at exactly 5 seconds to show the loop.
  4. These slices are shown to the user using html5 video player.
  5. Upon selection of the loop that sliced video is converted to gif.

Everything is working in the vice order. The issue is when the user uploads a large sized and length video this slicing and re-encoding takes forever and that cause the user to feel the site is not working properly.

What we want is very simple:

  1. Show 5 second portion of the video on loop.
  2. If user wants to select another loop he/she clicks the next button and is taken to the next 5 second loop which would be either at 25% of the video or some other
  3. On selection of that portion it converts it into gif.
  • with a large video you're always going to have this problem. easiest suggestion would to maybe create a lower resolution proxy (again, will take time but not as long as the full re-encode/leyframe) that they can view and select the 5s clip and then apply the full fidelity re-encode/keyframe/export process asynchronously – Offbeatmammal Oct 17 '19 at 03:26
  • Ah, I believe someone told us about possibly doing this : "You can try -preset help from command line and choose something like ultrafast. This is for preview only so you don't need much quality anyway. And you can compensate with more bitrate." I will have our developer look at your comment and respond accordingly, thank you! – Christopher Neil Oct 17 '19 at 19:24

2 Answers2

0

Don’t encode the whole video, just seek the the closest key frame, start decoding, throw away the frames until the frame you want, then start encoding at that frame. Ffmpeg can do this by specifying seek parameters before and after the input.

szatmary
  • 29,969
  • 8
  • 44
  • 57
  • Thank you! I will relay this to our developer! We may paste code for some help? – Christopher Neil Oct 17 '19 at 19:22
  • The ffmpeg documentation is sufficient to answer that. There have also been suggestions given to you (or someone on your team) in slack. If that is not enough, please make your question more specific. – szatmary Oct 17 '19 at 21:03
0

We hired a developer that created a solution to the problem. Thank you for your help!