Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transmuxing ends when rtmp is publishing with no errors #597

Open
Sina-KH opened this issue Jul 5, 2023 · 6 comments
Open

Transmuxing ends when rtmp is publishing with no errors #597

Sina-KH opened this issue Jul 5, 2023 · 6 comments

Comments

@Sina-KH
Copy link

Sina-KH commented Jul 5, 2023

Hi. Thanks for your great library.

I've configured nms on 2 of my test servers and it works great, but when I'm trying to make it work on production, it creates directories for different qualities, but does not generate .ts and .m3u8 for them. It only creates original hls outputs.
My logs show that instantly after [rtmp publish] Handle video. and [rtmp publish] Handle audio. files, it receives [rtmp publish] Close stream. id=Y8KK9U3D streamPath=/live/15_1280 streamId=1 and [rtmp play] Close stream. id=7MC9Q65N streamPath=/live/15_1280 streamId=1
Please note that everything is the same on my test and prod servers, and with no known cause, it fails on some of my servers and works on some other ones. I've tried both deploying dockerized and not dockerized versions, with different node versions.
FFMPEG version is also the same on all systems.

My configs:

const config = {
    rtmp: {
        port: parseInt(process.env.STREAM_RTMP_PORT || '8082'),
        chunk_size: parseInt(process.env.STREAM_CHUNK_SIZE || '60000'),
        gop_cache: true,
        ping: 60,
        ping_timeout: 30
    },
    http: {
        mediaroot: process.env.FILE_PATH + '/media',
        port: parseInt(process.env.STREAM_HTTP_PORT || '8081'),
        allow_origin: '*'
    },
    auth: process.env.STREAM_SECRET?.length ? {
        api: true,
        play: false,
        publish: true,
        secret: process.env.STREAM_SECRET,
        api_user: process.env.STREAM_API_AUTH_USER,
        api_pass: process.env.STREAM_API_AUTH_PASS,
    } : undefined,
    trans: {
        ffmpeg: process.env.FFMPEG_PATH || '',
        tasks: [
            {
                app: 'live',

                hls: true,
                hlsFlags: '[hls_time=2:hls_list_size=3:hls_flags=delete_segments]',
                hlsKeep: true, // to prevent hls file delete after end the stream

                // dash: true,
                // dashFlags: '[f=dash:window_size=3:extra_window_size=5]',
                // dashKeep: true, // to prevent dash file delete after end the stream

                mp4: true,
                mp4Flags: '[movflags=frag_keyframe+empty_moov]',
            }
        ]
    },
    fission: {
        ffmpeg: process.env.FFMPEG_PATH || '',
        tasks: [
            {
                rule: "live/*",
                model: [
                    {
                        ab: "128k",
                        vb: "1500k",
                        vs: "720x1280",
                        vf: "30",
                    },
                    {
                        ab: "64k",
                        vb: "1000k",
                        vs: "480x854",
                        vf: "24",
                    },
                    {
                        ab: "32k",
                        vb: "600k",
                        vs: "360x640",
                        vf: "20",
                    },
                ]
            },
        ]
    }
}

and logs:

[NodeEvent on preConnect] id=OKRRCRT1 args={"app":"live","type":"nonprivate","supportsGoAway":true,"flashVer":"FMLE/3.0 (compatible; FMSc/1.0)","swfUrl":"rtmp://IP_PORT_HERE/live","tcUrl":"rtmp://IP_PORT_HERE/live"}
7/5/2023 16:13:28 963 [INFO] [rtmp connect] id=OKRRCRT1 ip=MY_IP_HERE app=live args={"app":"live","type":"nonprivate","supportsGoAway":true,"flashVer":"FMLE/3.0 (compatible; FMSc/1.0)","swfUrl":"rtmp://IP_PORT_HERE/live","tcUrl":"rtmp://IP_PORT_HERE/live"}
[NodeEvent on postConnect] id=OKRRCRT1 args={"app":"live","type":"nonprivate","supportsGoAway":true,"flashVer":"FMLE/3.0 (compatible; FMSc/1.0)","swfUrl":"rtmp://IP_PORT_HERE/live","tcUrl":"rtmp://IP_PORT_HERE/live"}
[NodeEvent on prePublish] id=OKRRCRT1 StreamPath=/live/15 args={"sign":"CORRECT_SIGN_HERE__REMOVED_TO_SHARE_IT_WITH_YOU"}
7/5/2023 16:13:28 963 [INFO] [rtmp publish] New stream. id=OKRRCRT1 streamPath=/live/15 streamId=1
[NodeEvent on postPublish] id=OKRRCRT1 StreamPath=/live/15 args={"sign":"CORRECT_SIGN_HERE__REMOVED_TO_SHARE_IT_WITH_YOU"}
7/5/2023 16:13:28 963 [INFO] [Transmuxing MP4] /live/15 to /home/data/stream_files/media/live/15/2023-07-05-16-13-28.mp4
7/5/2023 16:13:28 963 [INFO] [Transmuxing HLS] /live/15 to /home/data/stream_files/media/live/15/index.m3u8
[NodeEvent on preConnect] id=CPRQV6U6 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:28 963 [INFO] [rtmp connect] id=CPRQV6U6 ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on postConnect] id=CPRQV6U6 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on preConnect] id=FTAZ3SW8 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:28 963 [INFO] [rtmp connect] id=FTAZ3SW8 ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on postConnect] id=FTAZ3SW8 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on prePlay] id=CPRQV6U6 StreamPath=/live/15 args={}
[NodeEvent on postPlay] id=CPRQV6U6 StreamPath=/live/15 args={}
7/5/2023 16:13:28 963 [INFO] [rtmp play] Join stream. id=CPRQV6U6 streamPath=/live/15  streamId=1 
[NodeEvent on prePlay] id=FTAZ3SW8 StreamPath=/live/15 args={}
[NodeEvent on postPlay] id=FTAZ3SW8 StreamPath=/live/15 args={}
7/5/2023 16:13:28 963 [INFO] [rtmp play] Join stream. id=FTAZ3SW8 streamPath=/live/15  streamId=1 
7/5/2023 16:13:29 963 [INFO] [rtmp publish] Handle audio. id=OKRRCRT1 streamPath=/live/15 sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 48000 2ch
7/5/2023 16:13:29 963 [INFO] [rtmp publish] Handle video. id=OKRRCRT1 streamPath=/live/15 frame_type=1 codec_id=7 codec_name=H264 1920x1080
[NodeEvent on preConnect] id=ISVLTK71 args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:30 963 [INFO] [rtmp connect] id=ISVLTK71 ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on postConnect] id=ISVLTK71 args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on prePublish] id=ISVLTK71 StreamPath=/live/15_1280 args={}
7/5/2023 16:13:30 963 [INFO] [rtmp publish] New stream. id=ISVLTK71 streamPath=/live/15_1280 streamId=1
[NodeEvent on postPublish] id=ISVLTK71 StreamPath=/live/15_1280 args={}
7/5/2023 16:13:30 963 [INFO] [Transmuxing MP4] /live/15_1280 to /home/data/stream_files/media/live/15_1280/2023-07-05-16-13-30.mp4
7/5/2023 16:13:30 963 [INFO] [Transmuxing HLS] /live/15_1280 to /home/data/stream_files/media/live/15_1280/index.m3u8
[NodeEvent on preConnect] id=YNOFQB7P args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:31 963 [INFO] [rtmp connect] id=YNOFQB7P ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on postConnect] id=YNOFQB7P args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on preConnect] id=OT8T2OPP args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:31 963 [INFO] [rtmp connect] id=OT8T2OPP ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on postConnect] id=OT8T2OPP args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on prePublish] id=YNOFQB7P StreamPath=/live/15_854 args={}
7/5/2023 16:13:31 963 [INFO] [rtmp publish] New stream. id=YNOFQB7P streamPath=/live/15_854 streamId=1
[NodeEvent on postPublish] id=YNOFQB7P StreamPath=/live/15_854 args={}
7/5/2023 16:13:31 963 [INFO] [Transmuxing MP4] /live/15_854 to /home/data/stream_files/media/live/15_854/2023-07-05-16-13-31.mp4
7/5/2023 16:13:31 963 [INFO] [Transmuxing HLS] /live/15_854 to /home/data/stream_files/media/live/15_854/index.m3u8
[NodeEvent on prePlay] id=OT8T2OPP StreamPath=/live/15_1280 args={}
[NodeEvent on postPlay] id=OT8T2OPP StreamPath=/live/15_1280 args={}
7/5/2023 16:13:31 963 [INFO] [rtmp play] Join stream. id=OT8T2OPP streamPath=/live/15_1280  streamId=1 
[NodeEvent on preConnect] id=62KCI105 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:31 963 [INFO] [rtmp connect] id=62KCI105 ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on postConnect] id=62KCI105 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on preConnect] id=9QAHATOC args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:31 963 [INFO] [rtmp connect] id=9QAHATOC ip=::ffff:127.0.0.1 app=live args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on postConnect] id=9QAHATOC args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
[NodeEvent on prePlay] id=62KCI105 StreamPath=/live/15_854 args={}
[NodeEvent on postPlay] id=62KCI105 StreamPath=/live/15_854 args={}
7/5/2023 16:13:31 963 [INFO] [rtmp play] Join stream. id=62KCI105 streamPath=/live/15_854  streamId=1 
[NodeEvent on prePublish] id=9QAHATOC StreamPath=/live/15_640 args={}
7/5/2023 16:13:31 963 [INFO] [rtmp publish] New stream. id=9QAHATOC streamPath=/live/15_640 streamId=1
[NodeEvent on postPublish] id=9QAHATOC StreamPath=/live/15_640 args={}
7/5/2023 16:13:31 963 [INFO] [Transmuxing MP4] /live/15_640 to /home/data/stream_files/media/live/15_640/2023-07-05-16-13-31.mp4
7/5/2023 16:13:31 963 [INFO] [Transmuxing HLS] /live/15_640 to /home/data/stream_files/media/live/15_640/index.m3u8
[NodeEvent on preConnect] id=V308RJRW args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:31 963 [INFO] [rtmp connect] id=V308RJRW ip=::ffff:127.0.0.1 app=live args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on postConnect] id=V308RJRW args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on prePlay] id=V308RJRW StreamPath=/live/15_640 args={}
[NodeEvent on postPlay] id=V308RJRW StreamPath=/live/15_640 args={}
7/5/2023 16:13:31 963 [INFO] [rtmp play] Join stream. id=V308RJRW streamPath=/live/15_640  streamId=1 
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Handle video. id=ISVLTK71 streamPath=/live/15_1280 frame_type=1 codec_id=7 codec_name=H264 720x1280
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Handle audio. id=ISVLTK71 streamPath=/live/15_1280 sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 48000 2ch
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Close stream. id=ISVLTK71 streamPath=/live/15_1280 streamId=1
[NodeEvent on donePublish] id=ISVLTK71 StreamPath=/live/15_1280 args={}
7/5/2023 16:13:32 963 [INFO] [rtmp play] Close stream. id=OT8T2OPP streamPath=/live/15_1280 streamId=1
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=OT8T2OPP
[NodeEvent on doneConnect] id=OT8T2OPP args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Handle video. id=YNOFQB7P streamPath=/live/15_854 frame_type=1 codec_id=7 codec_name=H264 480x854
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Handle audio. id=YNOFQB7P streamPath=/live/15_854 sound_format=10 sound_type=2 sound_size=1 sound_rate=3 codec_name=AAC 48000 2ch
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Close stream. id=YNOFQB7P streamPath=/live/15_854 streamId=1
[NodeEvent on donePublish] id=YNOFQB7P StreamPath=/live/15_854 args={}
7/5/2023 16:13:32 963 [INFO] [rtmp play] Close stream. id=62KCI105 streamPath=/live/15_854 streamId=1
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=62KCI105
[NodeEvent on doneConnect] id=62KCI105 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:32 963 [INFO] [rtmp publish] Close stream. id=9QAHATOC streamPath=/live/15_640 streamId=1
[NodeEvent on donePublish] id=9QAHATOC StreamPath=/live/15_640 args={}
7/5/2023 16:13:32 963 [INFO] [rtmp play] Close stream. id=V308RJRW streamPath=/live/15_640 streamId=1
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=V308RJRW
[NodeEvent on doneConnect] id=V308RJRW args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
[NodeEvent on donePlay] id=CPRQV6U6 StreamPath=/live/15 args={}
7/5/2023 16:13:32 963 [INFO] [rtmp play] Close stream. id=CPRQV6U6 streamPath=/live/15 streamId=1
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=CPRQV6U6
[NodeEvent on doneConnect] id=CPRQV6U6 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:32 963 [INFO] [Transmuxing end] /live/15_1280
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=ISVLTK71
[NodeEvent on doneConnect] id=ISVLTK71 args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:32 963 [INFO] [Transmuxing end] /live/15_640
7/5/2023 16:13:32 963 [INFO] [Transmuxing end] /live/15_854
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=9QAHATOC
[NodeEvent on doneConnect] id=9QAHATOC args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:32 963 [INFO] [rtmp disconnect] id=YNOFQB7P
[NodeEvent on doneConnect] id=YNOFQB7P args={"app":"live","type":"nonprivate","flashVer":"FMLE/3.0 (compatible; Lavf59.27.100)","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live"}
7/5/2023 16:13:32 963 [INFO] [Fission end] /live/15
7/5/2023 16:13:46 963 [INFO] [rtmp publish] Close stream. id=OKRRCRT1 streamPath=/live/15 streamId=1
[NodeEvent on donePublish] id=OKRRCRT1 StreamPath=/live/15 args={"sign":"CORRECT_SIGN_HERE__REMOVED_TO_SHARE_IT_WITH_YOU"}
7/5/2023 16:13:46 963 [INFO] [rtmp disconnect] id=OKRRCRT1
[NodeEvent on doneConnect] id=OKRRCRT1 args={"app":"live","type":"nonprivate","supportsGoAway":true,"flashVer":"FMLE/3.0 (compatible; FMSc/1.0)","swfUrl":"rtmp://IP_PORT_HERE/live","tcUrl":"rtmp://IP_PORT_HERE/live"}
7/5/2023 16:13:46 963 [INFO] [rtmp play] Close stream. id=FTAZ3SW8 streamPath=/live/15 streamId=1
7/5/2023 16:13:46 963 [INFO] [rtmp disconnect] id=FTAZ3SW8
[NodeEvent on doneConnect] id=FTAZ3SW8 args={"app":"live","flashVer":"LNX 9,0,124,2","tcUrl":"rtmp://127.0.0.1:PORT_HERE/live","fpad":false,"capabilities":15,"audioCodecs":4071,"videoCodecs":252,"videoFunction":1}
7/5/2023 16:13:46 963 [INFO] [Transmuxing end] /live/15
@Sina-KH
Copy link
Author

Sina-KH commented Jul 8, 2023

I've added logType: 4 to config and after checking FFmpeg logs and the flows, I found that the problem was that fission was not working correctly.
To solve the problem, I added -threads 1 to fission's ffmpeg command. A quick workaround can be forking the project and adding '-threads', '1' to the argv array in the node_fission_session.js file.
I'm not aware what causes this issue on my machines yet, because the hardwares were totally similar!

@cliqer
Copy link

cliqer commented Jul 8, 2023

@Sina-KH I had the same problem on M1 Max and solved it by brew install ffmpeg which installed v6 and then used:
ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg' as the path.

Now fission folders and files are created, but they still do not fuse in the main index.m3u8.

Any ideas why or is this behaviour correct and I need to change the stream on the client side player?

const NodeMediaServer = require('node-media-server');

const config = {
    logType: 4,

    rtmp: {
        port: 1935,
        chunk_size: 100,
        gop_cache: false,
        ping: 30,
        ping_timeout: 60,
    },
    
    http: {
        port: 8000,
        mediaroot: __dirname+'/media',
        webroot: __dirname+'/www',
        allow_origin: '*',
        api: true
    },

    fission: {
        ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg',
        tasks: [
            {
                rule: "live/*",
                model: [
                    {
                        ab: "128k",
                        vb: "3500k",
                        vs: "1920x1080",
                        vf: "30",
                    },
                    {
                        ab: "128k",
                        vb: "1500k",
                        vs: "1280x720",
                        vf: "30",
                    }
                ]
            },
        ]
    },

    trans: {
        ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg',
        tasks: [
            {
                app: 'live',
                vc: "copy",
                ac: "copy",
                hls: true,
                hlsFlags: '[hls_time=1:hls_list_size=3:hls_flags=delete_segments]',
                mp4: true,
                mp4Flags: '[movflags=frag_keyframe+empty_moov]',
            },
        ]
    },
};

const nms = new NodeMediaServer(config);
nms.run();

Also I noticed that the main incoming stream does not have a resolution. Maybe that plays a role:
image

@Sina-KH
Copy link
Author

Sina-KH commented Jul 8, 2023

@Sina-KH I had the same problem on M1 Max and solved it by brew install ffmpeg which installed v6 and then used: ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg' as the path.

Now fission folders and files are created, but they still do not fuse in the main index.m3u8.

Any ideas why or is this behaviour correct and I need to change the stream on the client side player?

const NodeMediaServer = require('node-media-server');

const config = {
    logType: 4,

    rtmp: {
        port: 1935,
        chunk_size: 100,
        gop_cache: false,
        ping: 30,
        ping_timeout: 60,
    },
    
    http: {
        port: 8000,
        mediaroot: __dirname+'/media',
        webroot: __dirname+'/www',
        allow_origin: '*',
        api: true
    },

    fission: {
        ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg',
        tasks: [
            {
                rule: "live/*",
                model: [
                    {
                        ab: "128k",
                        vb: "3500k",
                        vs: "1920x1080",
                        vf: "30",
                    },
                    {
                        ab: "128k",
                        vb: "1500k",
                        vs: "1280x720",
                        vf: "30",
                    }
                ]
            },
        ]
    },

    trans: {
        ffmpeg: process.env.FFMPEG_PATH || '/opt/homebrew/Cellar/ffmpeg/6.0/bin/ffmpeg',
        tasks: [
            {
                app: 'live',
                vc: "copy",
                ac: "copy",
                hls: true,
                hlsFlags: '[hls_time=1:hls_list_size=3:hls_flags=delete_segments]',
                mp4: true,
                mp4Flags: '[movflags=frag_keyframe+empty_moov]',
            },
        ]
    },
};

const nms = new NodeMediaServer(config);
nms.run();

Also I noticed that the main incoming stream does not have a resolution. Maybe that plays a role: image

Did you try hlsKeep: true to prevent hls file delete after end of the stream?
And did you change node_fission_session.js to have -threads 4 (4 is number of required threads) as I've mentioned?

@cliqer
Copy link

cliqer commented Jul 8, 2023

@Sina-KH, yes but maybe I'm missing something.
My solution was to create a custom master.m3u8 and link the streams through it:

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=1500000,RESOLUTION=1280x720
stream_720/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=3500000,RESOLUTION=1920x1080
stream/index.m3u8

Did you manage to fuse the fission's m3u8 on your main stream?
if so can you please paste here the output as to know what to expect?

Also do you have size on your main stream or is it 0x0?
I have a feeling it has to do with the ffmpeg version...

@Sina-KH
Copy link
Author

Sina-KH commented Jul 9, 2023

@cliqer

Exactly, I've created the primary .m3u8 file just like you did.
In the node_fission_session.js file, change line 23 to:

let outPath = ['-threads', '4', '-f', 'flv', 'rtmp://127.0.0.1:' + this.conf.rtmpPort + '/' + this.conf.streamApp + '/' + this.conf.streamName + '_' + m.vs.split('x')[1]];

And 4 is the number of threads. (maybe you can try adding this flag to line 19 and it work, also.)

I have no idea about your problem (size issue you mentioned) but with these changes my stream is working fine.

It also worth mentioning that the main hls output did not respect hls_time I passed to its flags, so I had to use fission and recreate my original resolution hls, also.

@rizalafaandi
Copy link

rizalafaandi commented Mar 17, 2024

hi, I have tried on react-native-nodemediaclient version 0.3.3 here

<NodePublisher ref={np} style={{flex: 1}} url={url} audioParam={{ codecid: NodePublisher.NMC_CODEC_ID_AAC, profile: NodePublisher.NMC_PROFILE_AUTO, samplerate: 48000, channels: 1, bitrate: 64 * 1000, }} videoParam={{ codecid: NodePublisher.NMC_CODEC_ID_H264, profile: NodePublisher.NMC_PROFILE_AUTO, width: 720, height: 1280, fps: 30, bitrate: 2000 * 1000, }} frontCamera={frontCamera} HWAccelEnable={true} denoiseEnable={true} torchEnable={torchEnable} keyFrameInterval={2} volume={mute ? 0.0 : 1.0} videoOrientation={ NodePublisher.VIDEO_ORIENTATION_PORTRAIT }/>

but when I look at the log in the nodemediaserver "handle video" section, I see the video dimensions are 0x0 so when I play the video in VLC the result is only sound.

[rtmp publish] Handle video. id=CRO7UOB1 streamPath=/live/genta-F2WKcWWJ frame_type=1 codec_id=7 codec_name=H264 0x0

Meanwhile, if I comment HWAccelEnable it will be read.

[rtmp publish] Handle video. id=UJUN7E6K streamPath=/live/genta-F2WKcWWJ frame_type=1 codec_id=7 codec_name=H264 720x1280

but there is a new problem, I can't play it on Android with hls extenston with error message:

{"errorException": "com.google.android.exoplayer2.ExoPlaybackException: MediaCodecVideoRenderer error, index=0, format=Format(0, null, null, video/avc, avc1.7A001F, -1, null, [720, 1280, -1.0], [-1, -1]), format_supported=NO_EXCEEDS_CAPABILITIES", "errorString": "ExoPlaybackException type : 1"}

what do you think is wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants