question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Increase speed by parallel execution

See original GitHub issue

We can speed up the process if we do all three steps at the same time - first ffmpeg process creates sound and images (sound should be in some sort of streaming container), python stuff does it’s job frame by frame and feeds those frames to the second ffmpeg. This shouldn’t be too hard to implement with pipes.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
carykhcommented, Apr 11, 2019

That’s true, and I definitely think this would help more for really long videos. It might even work on livestreamed videos! (Although… that doesn’t really make sense since the timeline is cut.) Anyway, I’ll definitely work on piping the processes together when I get some free time again.

(One thing to note is that the python stuff (analyzing the audio) happens much faster than ffmpeg. So as the parallelized code is running, there will essentially be the two ffmpeg processes churning away, and the Python process waiting for 95% of the time.)

3reactions
Tinguelycommented, Apr 11, 2019

@carykh

In response to live-streaming:

As an aside to write speed, I think the benefit to a purely in memeory implementation is that you could then stitch in memory instead of offloading to ffmpeg. I’m going to rewrite this in go, I’m pretty sure you could then preform this live with a reasonable buffer instead of having to parse then restitch to view. A buffer would allow the process to run in a way where audio and video is preprocessed a few seconds ahead, since the video doesn’t care about what happened before and after u could apply an algorithm as such:

Define i = 0 Calculate avg audio output for given chunk X (a predetermined Length of audio equal to 1 frame) If X avg audio value < threshold Then Remove audio (doesn’t seem to be needed at 20x)

If i++ % 20 == 0 Then Added frame to video buffer End if

Else Apply same logic as above but keep audio, speed up audio for given frame, if the frame % speed up multiplyier is 0 then add frame to buffer but regardless add the sped up audio to buffer. End else

The advantages of this approach is it doesn’t have to look ahead and the image/audio can be separated into two streams and never has to be encoded (unless being saved but it looks like you have that logic down). Another advantage to this approach is it has no disk write ops which will bottle beck unlike stated above. Hard drives have limited write speed, writing a ton of images is going to take time. I don’t u derstand why there are other comments stating that wouldn’t be the case, any modern cpu is going to be able to rip through images faster than they can be written.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Computing Speed: Parallel Processing - Science 2.0
There is a common misconception when assessing computers in suggesting that parallel processing increases speed. This simply isn't true.
Read more >
Improving Performance with Parallel Computing - MathWorks
Factors That Affect Speed. Some factors may affect the speed of execution of parallel processing: Parallel overhead. There is overhead in calling parfor...
Read more >
Speed-up your codes by parallel computing in Python (codes ...
Parallel computing is a way of diving the tasks into all the processes available on the system and achieve speed ups.
Read more >
Speed Up Your Code: Parallel Processing with multidplyr
Parallelizing code can drastically improve speed on multi-core machines. It makes the most sense in situations involving many iterative ...
Read more >
increasing the speed of computation or parallel processing
In cluster computing you gotta do your own adjustments for parallel computing. You can find those adjustment relatively from help or any manual....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found