[FFmpeg-user] FFmpeg single threaded bottleneck

Gabriel Balaich roderrooder at gmail.com
Fri Jun 12 22:15:42 EEST 2020


Apologies for the late response, I was undergoing some major hardware
changes in my setup and am now back to trying to figure this out.



> There is no multi-threaded audio encoding.


Yeah, I guess I understand why that makes sense programmatically, but my
issue isn't really that my audio is being encoded on a per-stream basis by
1 thread, right? It's that all audio streams in my command, even if they
have different destinations, are being funneled through 1 thread. I'd
assume the limitation around single thread encoding would exist on a
per-stream basis, but I'm obviously not well versed in the programming
behind that, just trying to understand what's going on.



> Is the issue you see only reproducible with dshow input or also with
> testsrc2
> input?


> I suspect there will always be a bottleneck in a load situation like above
> but it may be interesting to narrow it down.
>

Went ahead and tested this and you appear to be right, using this command I
get 100% utilization on 1 thread grinding the real-time encoding to a halt:
ffmpeg -y -f lavfi -re -i testsrc2=size=3840x2160:rate=60 `
-map 0 -c:v h264_nvenc -preset: hp -rc-lookahead 120 -pix_fmt nv12
C:\Users\gabri\Videostestsrc1.ts `
-map 0 -c:v h264_nvenc -preset: hp -rc-lookahead 120 -pix_fmt nv12
C:\Users\gabri\Videostestsrc2.ts `
-map 0 -c:v h264_nvenc -preset: hp -rc-lookahead 120 -pix_fmt nv12
C:\Users\gabri\Videostestsrc3.ts `
-map 0 -c:v h264_nvenc -preset: hp -rc-lookahead 120 -pix_fmt nv12
C:\Users\gabri\Videostestsrc4.ts

Ultimately, I do understand why each output stream individually would need
to be handled by 1 thread, but I guess I don't understand why all output
streams in a single command would need to be handled by 1 thread. It seems
like I can accomplish the same goal with a somewhat acceptable variance in
sync between each output file when using different FFmpeg instances for
each output file, but it definitely doesn't have the same consistency that
a single command does.


More information about the ffmpeg-user mailing list