Opened 7 years ago

Last modified 7 years ago

#2059 new defect

Multithreading multiplies audio sync problems

Reported by: subjunk@… Owned by: reimar
Priority: normal Component: core
Version: HEAD Severity: normal
Keywords: Cc: temp0@…
Blocked By: Blocking:
Reproduced by developer: Analyzed by developer:


My CPU takes up to 8 threads but the more I use the more the audio sync is negatively affected, at 8 it's very noticeable.
For testing I used the following:

mencoder input.mkv -oac copy -of mpeg -mpegopts format=mpeg2:muxrate=500000:vbuf_size=1194:abuf_size=64 -ovc lavc -channels 6 -lavdopts debug=0:threads=8 -lavcopts autoaspect=1:vcodec=mpeg2video:acodec=ac3:abitrate=448:threads=8:keyint=5:vqscale=1:vqmin=2:vqmax=3 -aid 0 -ofps 24000/1001 -lavdopts fast -af lavcresample=48000 -srate 48000 -o out.mpg

I've also noticed that it coincides with the message:
1 duplicate frame(s)!
Muxer frame buffer cannot allocate memory!

and that the more threads there are, the more errors. On the sample I tested I get:

11 errors with 8 threads
9 errors with 7 threads
7 errors with 6 threads
5 errors with 5 threads
4 errors with 4 threads
3 errors with 3 threads
2 errors with 2 threads
1 error with 1 thread

If you want the sample I used I can upload it, but the bug seems to happen with all files.
The fact that it happens even with 1 thread was surprising to me but hopefully it makes it easier to pinpoint the problem.

Change History (2)

comment:1 Changed 7 years ago by temp0@…

  • Cc temp0@… added

I reproduced this problem on my dualcore(no HT). When I set "-lavdopts debug=0:threads=1 or 2", output was OK=audio synced. When I used more than 2 threads, A/V sync got worse and more "1 duplicate frame" messages generated with growing number of threads used.
On my sample I can see with 1 or 2 threads none or few "SKIPPING 1 frame" and great A/V sync.
When I used 4,6 or 8 (more than my system supports), A/V sync goes worse and worse with different messages "1 DUPLICATE frame". More cores, more messages, more A/V sync problems.
"-mc 0 -noskip" stops to generate these duplicate frame messages for me and audio is OK but these parameters ignores audio delay set in stream so I can't use it.
It seems when more threads are used, decoder wrongly synchronize all threads so "duplicate frame" are logged?
Will try to test it on my other system, quadcore without HT(4cores,4threads).
Unfortunately I can't test on system with HT = more threads than cores. I know that Klaus Burton has 4core with HT so 8 threads used and what I understood up to 4 cores audio was synced but more than 4 grows A/V sync problems.
Regards ExSport?

comment:2 Changed 7 years ago by temp0@…

Is it known bug that there is no reaction at all?
Many thanks

Note: See TracTickets for help on using tickets.