Enable Hardware Encoding

About encoding, codec settings, muxers and filter usage
paolofonta
New Cone
New Cone
Posts: 4
Joined: 06 Oct 2020 09:08

Enable Hardware Encoding

Postby paolofonta » 06 Oct 2020 09:17

Good morning

I'm sending frames to VLC with a python script via std output and I'm exposing the resulting video on http with the following terminal command:

python3 script.py | cvlc --demux=rawvideo --rawvid-fps=25 --rawvid-width=1920 --rawvid-height=1080 --rawvid-chroma=RV24 - --no-audio --sout '#transcode{vcodec=MJPG,venc=ffmg{strict=1}}:standard{access=http{user=pippo,pwd=pluto,mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:10002/}'

It works, but encoding is managed by the CPU. I want to enable hardware encoding in order to use GPU for encoding instead of CPU.
Could anyone explain me how to modify the command in order to achieve this?

Thanks in advance

Rémi Denis-Courmont
Developer
Developer
Posts: 15265
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Enable Hardware Encoding

Postby Rémi Denis-Courmont » 06 Oct 2020 17:14

Change the venc value to whichever encoder you want to use.
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded

paolofonta
New Cone
New Cone
Posts: 4
Joined: 06 Oct 2020 09:08

Re: Enable Hardware Encoding

Postby paolofonta » 06 Oct 2020 17:20

Ok, fine, but is there any encoder that I can use that allows me to make GPU encoding?

paolofonta
New Cone
New Cone
Posts: 4
Joined: 06 Oct 2020 09:08

Re: Enable Hardware Encoding

Postby paolofonta » 08 Oct 2020 13:32

At the moment the solution I'm thinking about is to use FFMPEG to perform hardware encoding.
The output of the script is the input of FFMPEG and the output of FFMPEG will be the input of VLC.

I'm using this pipe:

python3 script.py | ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -f rawvideo -s 1920x1080 -i - -c:a copy -c:v h264_nvenc -f h264 - | cvlc --demux=rawvideo --rawvid-fps=25 --rawvid-width=1920 --rawvid-height=1080 --rawvid-chroma=RV24 - --no-audio --sout '#transcode{vcodec=MJPG,venc=ffmpeg{strict=1}}:standard{access=http{user=pippo,pwd=pluto,mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:10001/}'

It still not works, anyone has any suggestion on how to compose the VLC part?

paolofonta
New Cone
New Cone
Posts: 4
Joined: 06 Oct 2020 09:08

Re: Enable Hardware Encoding

Postby paolofonta » 12 Oct 2020 10:25

This is working

python3 script.py | ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -f rawvideo -pix_fmt rgb24 -s:v 1920x1080 -r 24 -i - -c:v h264_nvenc -f h264 - | cvlc stream:///dev/stdin --sout "#transcode{vcodec=mjpg,vb=2500,fps=24,acodec=none}:standard{access=http{user=pippo,pwd=pluto,mime=multipart/x-mixed-replace;boundary=7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8554/}" :demux=h264


If I remove the part of vlc transcode it don't works anymore.
I can't figure why the h264 stream as received from ffmpeg cannot be "forwarded" via http stream by VLC.

Why something like the below pipe cannot work?

python3 script.py | ffmpeg -y -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -f rawvideo -pix_fmt rgb24 -s:v 1920x1080 -r 24 -i - -c:v h264_nvenc -f h264 - | cvlc stream:///dev/stdin --sout "#standard{access=http{user=pippo,pwd=pluto,mime=multipart/x-mixed-replace;boundary=7b3cc56e5f51db803f790dad720ed50a},mux=ts,dst=:8554/}"

Is there a way to get h264 as input and stream it over http?


Return to “VLC stream-output (sout)”

Who is online

Users browsing this forum: No registered users and 12 guests