cannonbeach / ott-packager

OTT/ABR streaming encoder (H264/HEVC) and packager for DASH and HLS
GNU General Public License v2.0
228 stars 42 forks source link

GPU Transcoding #34

Closed vasudevavarun closed 3 years ago

vasudevavarun commented 3 years ago

Hello, I've compiled with

ENABLE_TRANSCODE=1 ENABLE_GPU=1 But I'm getting this error when I'm running fillet command.

 ./fillet --sources 1 --ip 224.1.1.1:4111 --interface eno1 --window 10 --segment 7 --identity 1000 --hls --transcode --outputs 2 --vcodec h264 --resolutions 320x240,960x540 --manifest /var/www/html/hls --vrate 500,2500 --acodec aac --arate 128 --aspect 16:9 --scte35 --quality 3 --stereo
STATUS: Source 0 IP: 224.1.1.1:4111
STATUS: Using supplied interface: eno1
STATUS: Using window size: 10
STATUS: Using segment length: 7
STATUS: Using config identity: 1000
STATUS: Number of transcoded outputs: 2
STATUS: output stream(0) resolution detected: 320 x 240
STATUS: output stream(1) resolution detected: 960 x 540
STATUS: Using supplied manifest directory: /var/www/html/hls
STATUS: output stream(0) video bitrate: 500
STATUS: output stream(1) video bitrate: 2500
STATUS: output stream(0) audio bitrate: 128
STATUS: output stream(0) aspect ratio detected: 16:9
status: starting video decode thread: 1
status: starting audio encode thread: 1
status: starting audio encode thread: 1
status: starting audio decode thread: 1
status: starting audio encode thread: 1
status: starting audio decode thread: 1
status: starting audio decode thread: 1
status: starting audio encode thread: 1
status: starting audio decode thread: 1
status: starting audio decode thread: 1
status: starting audio encode thread: 1
SESSION:1 (MAIN) STATUS: STARTING NEW SYNC THREAD
{
    "application": "fillet",
    "version": "1.0.0",
    "timestamp": "2021-04-08T13:54:03Z",
    "status": "success",
    "code": 200,
    "message": "OK",
    "data": {
        "system": {
            "input-signal": 0,
            "uptime": 0,
            "transcoding": 1,
            "codec": 2,
            "profile": 77,
            "quality": 3,
            "source-interruptions": 0,
            "source-errors": 0,
            "window-size": 10,
            "segment-length": 7,
            "youtube-active": 0,
            "hls-active": 1,
            "dash-fmp4-active": 0,
            "scte35": 1,
            "latency": "0.00 ms"
        },
        "source": {
            "inputs": 1,
            "stream-select": 0,
            "width": 0,
            "height": 0,
            "fpsnum": 0,
            "fpsden": 0,
            "aspectnum": 0,
            "aspectden": 0,
            "videomediatype": 0,
            "audiomediatype0": 0,
            "audiomediatype1": 0,
            "audiochannelsinput0": 0,
            "audiochannelsinput1": 0,
            "audiochannelsoutput0": 0,
            "audiochannelsoutput1": 0,
            "audiosamplerate0": 0,
            "audiosamplerate1": 0,
            "interface": "eno1",
            "stream0": {
                "source-ip": "224.1.1.1:4111",
                "video-bitrate": 0,
                "video-first-timestamp": 0,
                "video-current-duration": 0,
                "video-received-frames": 0
            }
        },
        "ad-insert": {
        },
        "output": {
            "output-directory": "/var/www/html/hls",
            "hls-manifest": "master.m3u8",
            "dash-manifest": "masterdash.mpd",
            "fmp4-manifest": "masterfmp4.m3u8",
            "outputs": 2,
            "stream0": {
                "output-width": 320,
                "output-height": 240,
                "video-bitrate": 500
            },
            "stream1": {
                "output-width": 960,
                "output-height": 540,
                "video-bitrate": 2500
            }
        },
        "publish": {
        }
    }
}
SESSION:1 (TSRECEIVE) STATUS: PARSING SOURCE ADDRESS 224.  1.  1.  1  SCANNED:4
*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
status: setting receiver socket size to: 1048576
status: binding to local address
status: mcast flag is: 1
status: interface is defined as input: 172.16.16.11
status: checking for available receive socket(0): 1
status: using socket index 0!
status: Sending out IGMP JOIN request on interface: 172.16.16.11
status: newly created socket: 4
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /api/v1/status_update/1000 HTTP/1.1
Host: 127.0.0.1:8080
Accept: */*
Content-Type: application/json
Content-Length: 2137

* upload completely sent off: 2137 out of 2137 bytes
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 1182
< ETag: W/"49e-VPiXf6y3i5qoLm9Hu6W1j02vgps"
< Date: Thu, 08 Apr 2021 13:54:03 GMT
< Connection: keep-alive
< 
{"application":"fillet","version":"1.0.0","timestamp":"2021-04-08T13:54:03Z","status":"success","code":200,"message":"OK","data":{"system":{"input-signal":0,"uptime":0,"transcoding":1,"codec":2,"profile":77,"quality":3,"source-interruptions":0,"source-errors":0,"window-size":10,"segment-length":7,"youtube-active":0,"hls-active":1,"dash-fmp4-active":0,"scte35":1,"latency":"0.00 ms"},"source":{"inputs":1,"stream-select":0,"width":0,"height":0,"fpsnum":0,"fpsden":0,"aspectnum":0,"aspectden":0,"videomediatype":0,"audiomediatype0":0,"audiomediatype1":0,"audiochannelsinput0":0,"audiochannelsinput1":0,"audiochannelsoutput0":0,"audiochannelsoutput1":0,"audiosamplerate0":0,"audiosamplerate1":0,"interface":"eno1","stream0":{"source-ip":"224.1.1.1:4111","video-bitrate":0,"video-first-timestamp":0,"video-current-duration":0,"video-received-frames":0}},"ad-insert":{},"output":{"output-directory":"/var/www/html/hls","hls-manifest":"master.m3u8","dash-manifest":"masterdash.mpd","fmp4-manifest":"masterfmp4.m3u8","outputs":2,* Connection #0 to host 127.0.0.1 left intact
SESSION:1 (RESTFUL) STATUS: HTTPCODE:200
* Closing connection 0
PAT TABLE FOUND
PMT TABLE FOUND ON PID:4096

SENDING SIGNAL TO MANAGEMENT INTERFACE

*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /api/v1/signal/1000 HTTP/1.1
Host: 127.0.0.1:8080
Accept: */*
Content-Type: application/json
Content-Length: 183

* upload completely sent off: 183 out of 183 bytes
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 199
< ETag: W/"c7-BmTTslHUFofWtp9TLE+YrhHTvyo"
< Date: Thu, 08 Apr 2021 13:54:03 GMT
< Connection: keep-alive
< 
* Connection #0 to host 127.0.0.1 left intact
SESSION:1 (RESTFUL) STATUS: HTTPCODE:200
* Closing connection 0
SESSION:1 (MAIN): FLM:8192 FRM:6144 CV:4096 CA:4096 RV:512 RA:2048
{
    "application": "fillet",
    "version": "1.0.0",
    "timestamp": "2021-04-08T13:54:04Z",
    "status": "success",
    "code": 200,
    "message": "OK",
    "data": {
        "system": {
            "input-signal": 1,
            "uptime": 0,
            "transcoding": 1,
            "codec": 2,
            "profile": 77,
            "quality": 3,
            "source-interruptions": 0,
            "source-errors": 2,
            "window-size": 10,
            "segment-length": 7,
            "youtube-active": 0,
            "hls-active": 1,
            "dash-fmp4-active": 0,
            "scte35": 1,
            "latency": "0.00 ms"
        },
        "source": {
            "inputs": 1,
            "stream-select": 0,
            "width": 0,
            "height": 0,
            "fpsnum": 0,
            "fpsden": 0,
            "aspectnum": 0,
            "aspectden": 0,
            "videomediatype": 0,
            "audiomediatype0": 0,
            "audiomediatype1": 0,
            "audiochannelsinput0": 0,
            "audiochannelsinput1": 0,
            "audiochannelsoutput0": 0,
            "audiochannelsoutput1": 0,
            "audiosamplerate0": 0,
            "audiosamplerate1": 0,
            "interface": "eno1",
            "stream0": {
                "source-ip": "224.1.1.1:4111",
                "video-bitrate": 3999000,
                "video-first-timestamp": 0,
                "video-current-duration": 0,
                "video-received-frames": 24
            }
        },
        "ad-insert": {
        },
        "output": {
            "output-directory": "/var/www/html/hls",
            "hls-manifest": "master.m3u8",
            "dash-manifest": "masterdash.mpd",
            "fmp4-manifest": "masterfmp4.m3u8",
            "outputs": 2,
            "stream0": {
                "output-width": 320,
                "output-height": 240,
                "video-bitrate": 500
            },
            "stream1": {
                "output-width": 960,
                "output-height": 540,
                "video-bitrate": 2500
            }
        },
        "publish": {
        }
    }
}
*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> POST /api/v1/status_update/1000 HTTP/1.1
Host: 127.0.0.1:8080
Accept: */*
Content-Type: application/json
Content-Length: 2144

* upload completely sent off: 2144 out of 2144 bytes
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Content-Type: application/json; charset=utf-8
< Content-Length: 1189
< ETag: W/"4a5-7TIVm2IMW4qCoOV7Nj2eAuwKRp4"
< Date: Thu, 08 Apr 2021 13:54:04 GMT
< Connection: keep-alive
< 
"stream0":{"output-width":320,"output-height":240,"video-bitrate":500},"stream1":{"output-width":960,"output-height":540,"video-bitrate":2500}},"publish":{}}}{"time":"2021-04-08T13:54:03Z","host":"ott-packager","id":1000,"status":"success","message":"input signal locked","source":"224.1.1.1:4111:eno1","level":"info","timestamp":"2021-04-08T13:54:03.200Z"}{"application":"fillet","version":"1.0.0","timestamp":"2021-04-08T13:54:04Z","status":"success","code":200,"message":"OK","data":{"system":{"input-signal":1,"uptime":0,"transcoding":1,"codec":2,"profile":77,"quality":3,"source-interruptions":0,"source-errors":2,"window-size":10,"segment-length":7,"youtube-active":0,"hls-active":1,"dash-fmp4-active":0,"scte35":1,"latency":"0.00 ms"},"source":{"inputs":1,"stream-select":0,"width":0,"height":0,"fpsnum":0,"fpsden":0,"aspectnum":0,"aspectden":0,"videomediatype":0,"audiomediatype0":0,"audiomediatype1":0,"audiochannelsinput0":0,"audiochannelsinput1":0,"audiochannelsoutput0":0,"audiochannelsoutput1":0,"audiosamplerat* Connection #0 to host 127.0.0.1 left intact
SESSION:1 (RESTFUL) STATUS: HTTPCODE:200
* Closing connection 0
SESSION:1 (MAIN): FLM:8192 FRM:6144 CV:4096 CA:4096 RV:512 RA:2048
STATUS: RECEIVE_FRAME (H264/HEVC : 0): TYPE: 2 PTS:      204967920 DTS:              0 KEY:1
STATUS: 1:DECODED VIDEO FRAME: 1920x1080 (1:1) INTERLACED:0 (TFF:0)
decode_pkt->size:348  incoming_audio_buffer_size:348  retcode:348
decode_pkt->size:346  incoming_audio_buffer_size:346  retcode:346
expected audio data:4096   actual audio data:4096   full_time:204972720 delta:0
STATUS: 2:DECODED VIDEO FRAME: 1920x1080 (1:1) INTERLACED:0 (TFF:0)
DEINTERLACED_FRAME_COUNT:1  SYNC_FRAME_COUNT:0   SYNC OFFSET:1 (40.00ms)  PKT_DTS:204967920  FT:204967920  FPS:25.00
SENDING VIDEO FRAME TO SCALER PTS:204967920 DTS:204967920  ASPECT:1:1
[0] SCALING OUTPUT FRAME TO: 320 x 240
[0] SENDING VIDEO FRAME TO ENCODER PTS:204967920 DTS:204967920  ASPECT:1:1

Initializing NVENC Hardware

NVENC: encode_codec=(nil)
NVENC: encode_avctx=0x7f158c000b80
NVENC: av_hwdevice_ctx_create=-12
Error: signal 11:
./fillet(+0x127f00)[0x55f349ab1f00]
/lib/x86_64-linux-gnu/libc.so.6(+0x46210)[0x7f1595914210]
./fillet(+0xbb2307)[0x55f34a53c307]
./fillet(+0x131c5d)[0x55f349abbc5d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x9609)[0x7f1595e27609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7f15959f0293]
e0":0,"audiosamplerate1":0,"interface":"eno1","stream0":{"source-ip":"224.1.1.1:4111","video-bitrate":3999000,"video-first-timestamp":0,"video-current-duration":0,"video-received-frames":24}},"ad-insert":{},"output":{"output-directory":"/var/www/html/hls","hls-manifest":"master.m3u8","dash-manifest":"masterd
cannonbeach commented 3 years ago

I have not posted all of the instructions and the updated the scripts yet for the GPU transcoding, however, I think you likely need to recompile the cbffmpeg directory with the following configuration:

./configure --prefix=/usr --enable-cuda --enable-cuvid --enable-nvenc --enable-nonfree --enable-libnpp --enable-avresample --disable-iconv --disable-v4l2-m2m --disable-vaapi --disable-vdpau --disable-videotoolbox --disable-avdevice --en able-encoder=mjpeg --extra-cflags=-I/usr/local/cuda-11.1/include --extra-ldflags=-L/usr/local/cuda-11.1/lib64

since the default scripts I've provided are only for CPU transcoding. Please try that out. I will update the scripts when I get a chance and also do some additional validation.

vasudevavarun commented 3 years ago

Hi, I've tried recompiling cbffmpeg again with cuda but the error is still same. Can you please provide command for packaging only I'm using the below command.


./fillet --sources 1 --ip 224.1.1.1:4111 --interface eno1 --window 10 --segment 7 --identity 1000 --hls  --manifest /var/www/html/hls --scte35
STATUS: Source 0 IP: 224.1.1.1:4111
STATUS: Using supplied interface: eno1
STATUS: Using window size: 10
STATUS: Using segment length: 7
STATUS: Using config identity: 1000
STATUS: Using supplied manifest directory: /var/www/html/hls
error: unknown video encoder selected! fail!
cannonbeach commented 3 years ago

Please double check that you've compiled it correctly. You can quickly check if your cbffmpeg is compiled correctly by doing a test GPU transcode of a file: cbffmpeg/ffmpeg -vsync 0 -i input.ts -c:a copy -c:v h264_nvenc -b:v 4M -f mpegts output.ts If that works fine, then please let me know more about the particular GPU system you are running such as model of GPU, version of driver and version of CUDA and I can investigate further.

For packaging, you should recompile with packaging only enabled. It's possible there is some additional validation occurring that shouldn't be happening when running the packaging mode compiled in the transcode mode. Feel free to submit a pull request if you happen to find an issue. Thanks.

vasudevavarun commented 3 years ago

cbffmpeg/ffmpeg -vsync 0 -i input.ts -c:a copy -c:v h264_nvenc -b:v 4M -f mpegts output.ts

image

For packaging, you should recompile with packaging only enabled. It's possible there is some additional validation occurring that shouldn't be happening when running the packaging mode compiled in the transcode mode. Feel free to submit a pull request if you happen to find an issue. Thanks.

Ok, I'll recompile and revert.

cannonbeach commented 3 years ago

Thanks for checking the cbffmpeg. I will check the code to see if it could be mapping the GPU incorrectly when you run it. I have only done limited testing of this feature, so I will hopefully be able to spend more time on it next week.

vasudevavarun commented 3 years ago

Hi, I've recompiled fillet with GPU and Transcoding parameters set to 0, but I'm still not able to repackage. Can you please tell what I'm doing wrong.

./fillet --sources 1 --ip 224.1.1.1:4111 --interface eno1 --window 5 --segment 5 --manifest /var/www/html/hls --identity 1000 --hls
STATUS: Source 0 IP: 224.1.1.1:4111
STATUS: Using supplied interface: eno1
STATUS: Using window size: 5
STATUS: Using segment length: 5
STATUS: Using supplied manifest directory: /var/www/html/hls
STATUS: Using config identity: 1000
error: unknown video encoder selected! fail!

Thanks.

cannonbeach commented 3 years ago

Sorry you are having problems with it. I will take a look and get back to you. I may have broken something in one of my more recent updates.

cannonbeach commented 3 years ago

Closing issue since no encoding options were selected when compiled with transcode enabled. Error message is correct.