Page 1 of 1

VLC speed up algorithm

Posted: 09 Jul 2015 07:38
by hayder78
I don't know where to ask, please forgive me if this is not the right place.

I am very curious, how is VLC increasing the video speed playback? I suppose the increase of audio speed is by skipping small parts of the audio.

What about the video speed up algorithm?

Is it by frame skipping or using a certain algorithm to speed up the h264 video playback like in this research paper for example:
A New Motion Vector Composition Algorithm for Fast-forward Video Playback in H.264
http://www.researchgate.net/profile/Ch ... 000000.pdf


Is the speed up of video playback handled by ffmpeg libraries, which can be obtained out of the box from the library? or VLC is implementing its own algorithm?
I searched a lot in ffmpeg documentation to apply speed increase/decrease but it seems nothing provides such playback speed control.

Appreciate any hint from the experts here...
My question is just out of curiosity that took from me ~1 months of reading and searching!
Many thanks...

Re: VLC speed up algorithm

Posted: 09 Jul 2015 08:43
by Rémi Denis-Courmont
There is no algorithm to speed up video. It just plays faster.

Re: VLC speed up algorithm

Posted: 10 Jul 2015 20:13
by hayder78
Thanks Remi for your reply.

So when playing in 10x speed, the decoder is decoding 300 frames/sec ? The VLC will choose to display 1 frame and skip 9 ?

I tried to benchmark the ffmpeg decoder with this command:

ffmpeg -benchmark -i INPUT -f null out.null

and I got :
for 480p h.264 video = 84x speed with 100% CPU utilization ( 8 logical cores CPU: core i7 3770k )
for 1080p h.264 video = 23x speed with 100% CPU utilization

However, in VLC the maximum playback speed that could be achieved in playing the same 480p video is ~12x (with 'Hurry Up' disabled in ffmpeg decoder settings in VLC). And it is strangely around the same speed achieved for 1080p video too. And the CPU utilization is less than 100% (~40-50%).

What is going on here?

Why the CPU utilization is less than 100% when the decoder benchmark showed that the decoder could indeed achieve much higher rate and 100% CPU utilization? This is why I thought VLC is using a certain algorithm and not just decoding faster.

Does this mean that there is something else other than the decoder as the bottleneck, because the fact that the fastest playback speed achieved in both 480p and 1080p is the same in VLC, and logically it should be different just like in the decoder benchmark?

Re: VLC speed up algorithm

Posted: 11 Jul 2015 09:44
by Rémi Denis-Courmont
I don't know where you are trying to get. The only general way to play faster is to decode faster accordingly. With an Intra-only source, it would be possible to just skip frames, but that is not generic and neither VLC nor FFmpeg will do so.

Which frames get dropped or duplicated depends on your monitor refresh rate anyway, not the source video rate.

Re: VLC speed up algorithm

Posted: 11 Jul 2015 16:14
by hayder78
Thanks for the interesting hints!
'Which frames get dropped or duplicated depends on your monitor refresh rate anyway, not the source video rate.'
I needed to hear that. Answers from experts like you is valuable and spare a lot of time. For ~1 month I was researching in the literature out of curiosity and read posts in the VLC developer mail list and github and found a lot of contribution from you back to the year 2006! Although I learned a lot but it did not answer my questions. Now with a few answers from you, most of my questions has been answered from an expert VLC developer.
I appreciate that really!

By the way, look what I have found:
The Thread count in the ffmpeg decoder setting in VLC is not good to leave it to the default (0). I changed it to 16 threads and got much better CPU utilization.

With hurry up disabled, the 1080p video fast playback speed enhanced from maximum of 12x (Thread=0) into 20x (Thread=16).

Increasing the thread count even more did not yield more speed up.

For the 480p video with Thread>12 was not good and affected the smoothness of the playback even at 1x speed.
The 480p video fast playback speed enhanced from maximum of 12x (Thread=0) into 16x (Thread=12). The enhancement was less in the 480p videos if compared to the enhancement of the fast playback performance of 1080p videos. The higher resolution video took more advantage from the increasing the thread count in the decoder settings than the lower resolution video.

The performance for the 1080p fast video playback is almost the same as the benchmark of ffmpeg in my previous post (23x for 1080p).
But for the 480p VLC achieved much less than the ffmpeg decoder's benchmark (VLC: only 16x fast playback; while benchmark of ffmpeg was 83x for 480p).

At least now I have a rough idea what was most likely the issue of the low VLC performance in fast playback. It was the Threading count settings. It seems the default thread count in the VLC setting is much less than the ffmpeg decoder's benchmark.

That means if anybody could buy a CPU with more cores, I think it will be with a better performance in fast playback.
I have an old Nvidia GPU, that did not perform well more than 8x when DXVA2.0 hardware acceleration enabled with 480p and nothing more than 1x with 1080p.

Does a better GPU can provide a better fast playback performance than the CPU (like an Nvidia Titan X) ? My old GPU got only 8x (half of my CPU's fast playback).
Does a XEON CPU with higher number of cores like with 16 cores perform better with fast playback?