Page 1 of 1

Performance problems with simultaneous transcoding for livehttp

Posted: 05 Jun 2018 13:06
by Ghengis
I will eventually have a live video feed coming in that I'd like to publish via HLS in a few different bitrates. During initial development, I've been trying to figure out transcoding using VLC just working from a single local file, under the assumption that I can easily replace the input later. (I say this here for context, in case transcode-from-file is somehow fundamentally different from transcode-from-stream.)

I've gotten as far as this:

Code: Select all

"c:\program files\videolan\vlc\vlc-gpu.exe" -I dummy "c:\users\James\Downloads\bbb_sunflower_2160p_60fps_normal.mp4" --sout=#duplicate{dst={transcode{height=540,fps=15,vcodec=h264,vb=800,venc=x264{aud,profile=baseline,keyint=30},acodec=aac,ab=96,threads=4}:std{access=livehttp{seglen=4,delsegs=false,numsegs=0,index=c:\workspace\vidtest\bbb540.m3u8,index-url=bbb540-#####.ts},mux=ts{use-key-frames},dst=c:\workspace\vidtest\bbb540-#####.ts}},dst={transcode{height=720,fps=30,vcodec=h264,vb=2200,venc=x264{aud,profile=baseline,keyint=60},acodec=aac,ab=128,threads=4}:std{access=livehttp{seglen=4,delsegs=false,numsegs=0,index=c:\workspace\vidtest\bbb720.m3u8,index-url=bbb720-#####.ts},mux=ts{use-key-frames},dst=c:\workspace\vidtest\bbb720-#####.ts}},dst={transcode{height=1080,fps=60,vcodec=h264,vb=3200,venc=x264{aud,profile=baseline,keyint=120},acodec=aac,ab=192,threads=4}:std{access=livehttp{seglen=4,delsegs=false,numsegs=0,index=c:\workspace\vidtest\bbb1080.m3u8,index-url=bbb1080-#####.ts},mux=ts{use-key-frames},dst=c:\workspace\vidtest\bbb1080-#####.ts}}}
It seems to work well, all three sets of files are being generated at the same time, but performance is pretty bad. The output files are being written at around half or less the real-time playback speed, with 4-second segments showing up every 10+ seconds. That would be fine if the hardware just couldn't keep up, but in Task Manager, my CPU usage hovers around 30% and GPU around 50%. As you can see in the script, I'm telling each transcode to use 4 threads, and I've forced VLC to use my GeForce 1060 instead of the Intel iGPU (though according to Task Manager it doesn't make much difference, in terms of percentage load).

Is there something I'm missing here? I'd like to use "all the hardware" if possible. I'm trying to get a feel for how much I can transcode in real-time on a given set of hardware, but if half the cores are always sitting idle, it seems like that could be put to better use.

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 26 Jun 2018 20:56
by Jean-Baptiste Kempf
What are your VLC logs?

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 09:19
by Ghengis
What log level should I capture? I can run it for a little while and upload the results here, if that helps. You could also run the command yourself, the sample I'm transcoding is the 4K render of Big Buck Bunny available from Blender: http://bbb3d.renderfarming.net/download.html . Let me know which you'd prefer.

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 09:45
by InTheWings
If multiple streams are encoded at the same time, try disabling hw acceleration (yes, that sounds wrong, i know)

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 10:03
by Ghengis
Which hardware flag would that be? I see a few different ones in the command line reference.

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 10:34
by InTheWings
--avcodec-hw=none

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 11:46
by Ghengis
That flag does reduce GPU usage to 0, and increase CPU usage somewhat, but it still won't go over 45% (typically 35-40%) with the command in the OP. It's taking around 20 seconds (!) to produce a 4-second segment. Well, 3 4-second segments, but you get the idea.

I logged a few files' worth of output, hosted in this gist. (Can I maybe attach logs here in the forum somehow?)

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 11:57
by InTheWings
transcoding is non threaded by default

Re: Performance problems with simultaneous transcoding for livehttp

Posted: 27 Jun 2018 17:02
by Ghengis
Does "threads=4" in the OP not mean what I thought it meant?