Page 1 of 1
Enable Hardware Encoding
Posted: 06 Oct 2020 09:17
by paolofonta
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
Re: Enable Hardware Encoding
Posted: 06 Oct 2020 17:14
by RĂ©mi Denis-Courmont
Change the venc value to whichever encoder you want to use.
Re: Enable Hardware Encoding
Posted: 06 Oct 2020 17:20
by paolofonta
Ok, fine, but is there any encoder that I can use that allows me to make GPU encoding?
Re: Enable Hardware Encoding
Posted: 08 Oct 2020 13:32
by paolofonta
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?
Re: Enable Hardware Encoding
Posted: 12 Oct 2020 10:25
by paolofonta
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?