Jalle19 / node-ffmpeg-mpegts-proxy

Simple proxy for leveraging ffmpeg to convert any source URL into MPEG-TS over HTTP
GNU General Public License v2.0
167 stars 52 forks source link

Additional parameters for input #53

Closed DanielQuirogaDev closed 4 years ago

DanielQuirogaDev commented 5 years ago

The streams i am processing come from internet and sometimes they lag out and die, so i´d love to add this options to the input but, this won't work.

Where can i add additional parameters for the ffmpeg / avconv command?

Thanks in advance, this tool saved my life.

if (source.realtime !== false) { options = [ '-re -reconnect 1 -reconnect_at_eof 1 -reconnect_streamed 1 -reconnect_delay_max 2' ]; }

Jalle19 commented 5 years ago

Have you tried https://github.com/Jalle19/node-ffmpeg-mpegts-proxy/blob/master/README.md#custom-avconv-parameters ?

DanielQuirogaDev commented 5 years ago

Damn, I feel so stupid man. Thanks :)

DanielQuirogaDev commented 5 years ago

sorry to bother again, after adding this:

{
            "name": "Test Channel",
            "provider": "Test Channel One",
            "url": "/tchannel",
            "source": "http://somesource.com/rcn/playlist.m3u8",
            "avconvOptions": {
                    "input": [
                            "fflags", "+genpts"
                    ],
                    "output": [
                            "-bsf", "h264_mp4toannexb"
                    ]
            }
    },

I get this on the silly output:

2019-10-29T13:57:29.275Z - silly: ffmpeg version N-95314-g1331e00179 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) configuration: --enable-libx264 --enable-libvpx --enable-gpl libavutil 56. 35.100 / 56. 35.100 libavcodec 58. 59.102 / 58. 59.102 libavformat 58. 33.100 / 58. 33.100 libavdevice 58. 9.100 / 58. 9.100 libavfilter 7. 62.100 / 7. 62.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100

2019-10-29T13:57:29.275Z - info: avconv started successfully 2019-10-29T13:57:29.275Z - silly: libpostproc 55. 6.100 / 55. 6.100

2019-10-29T13:57:29.680Z - silly: [hls @ 0x55a065837a80] Skip ('#EXT-X-VERSION:3')

2019-10-29T13:57:29.681Z - silly: [hls @ 0x55a065837a80] Opening 'http://somesource.com/rcn/chunks.m3u8?nimblesessionid=1462466' for reading

2019-10-29T13:57:30.056Z - silly: [hls @ 0x55a065837a80] Skip ('#EXT-X-VERSION:3')

2019-10-29T13:57:30.056Z - silly: [hls @ 0x55a065837a80] Opening 'http://somesource.com/rcn/l_4906_270303_44.ts?nimblesessionid=1462466' for reading

2019-10-29T13:57:30.248Z - silly: [hls @ 0x55a065837a80] Opening 'http://somesource.com/rcn/l_4906_276309_45.ts?nimblesessionid=1462466' for reading

2019-10-29T13:57:30.664Z - silly: Input #0, hls, from 'http://147.135.84.60:8081/atenea/rcn/playlist.m3u8': Duration: N/A, start: 270.303367, bitrate: N/A Program 0 Metadata: variant_bitrate : 1479644 Stream #0:0: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc Metadata:

2019-10-29T13:57:30.664Z - silly: variant_bitrate : 1479644 Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp Metadata: variant_bitrate : 1479644 Option re (read input at native frame rate) cannot be applied to output url fflags -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to. Error parsing options for output file fflags. Error opening output files: Invalid argument

2019-10-29T13:57:30.665Z - error: avconv exited with code 1 2019-10-29T13:57:30.665Z - info: ::ffff:127.0.0.1 still connected, restarting avconv after 5 seconds ... ^Cdaniel@Ragnar:~/$

Jalle19 commented 5 years ago

The example is probably out of date, ffmpeg says fflags is not an input option. Try with the ones you actually want to use instead, like -reconnect

Jalle19 commented 5 years ago

These reconnect options look quite useful, maybe they should be included by default. I don't know what side effects it has though.

DanielQuirogaDev commented 5 years ago

Before i adopted your proxy i was using a simple python program to handle my live streams with zero issues, including those options.

I tought so as well but couldn't find where should i put them. Boomer hehe. Javascript is not my thing

DanielQuirogaDev commented 5 years ago

I tried with my options first but got the same error. It is trying to put the options after the -re...

On Tue, Oct 29, 2019, 10:08 AM Sam Stenvall notifications@github.com wrote:

The example is probably out of date, ffmpeg says fflags is not an input option. Try with the ones you actually want to use instead, like -reconnect

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Jalle19/node-ffmpeg-mpegts-proxy/issues/53?email_source=notifications&email_token=AMCXP35GD7Y64AM26JMHFALQRBGYHA5CNFSM4JGHV4C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECQ3N5Q#issuecomment-547469046, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMCXP37WTYXJPCOITNY4KBLQRBGYHANCNFSM4JGHV4CQ .

Jalle19 commented 5 years ago

Does it work if you change it so they come after -re?

DanielQuirogaDev commented 5 years ago

Well you place the -re from options.js but at run time it says that my options are coming at the wrong place. Like I am trying to use my options as source.

If you'd like I can upload a full log later on

On Tue, Oct 29, 2019, 3:00 PM Sam Stenvall notifications@github.com wrote:

Does it work if you change it so they come after -re?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Jalle19/node-ffmpeg-mpegts-proxy/issues/53?email_source=notifications&email_token=AMCXP3YBCL6FN5K7Y7CCKT3QRCI4XA5CNFSM4JGHV4C2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOECR4IEQ#issuecomment-547603474, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMCXP32JDJF3UUJLB4364FDQRCI4XANCNFSM4JGHV4CQ .

DanielQuirogaDev commented 5 years ago

If i place the options like this:

{ "name": "Test Channel", "provider": "Test Channel One", "url": "/tchannel", "source": "http://daniel/daniel/rcn/playlist.m3u8", "avconvOptions": { "input": [ "reconnect 1" ], "output": [ "-bsf", "h264_mp4toannexb" ] } },

i get:

2019-10-30T00:57:08.021Z - info: ::ffff:127.0.0.1 still connected, restarting avconv after 5 seconds ... 2019-10-30T00:57:13.029Z - silly: ffmpeg version N-95314-g1331e00179 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 7 (Ubuntu 7.4.0-1ubuntu1~18.04.1) configuration: --enable-libx264 --enable-libvpx --enable-gpl

2019-10-30T00:57:13.029Z - info: avconv started successfully 2019-10-30T00:57:13.029Z - silly: libavutil 56. 35.100 / 56. 35.100 libavcodec 58. 59.102 / 58. 59.102 libavformat 58. 33.100 / 58. 33.100 libavdevice 58. 9.100 / 58. 9.100 libavfilter 7. 62.100 / 7. 62.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100

2019-10-30T00:57:13.510Z - silly: [hls @ 0x55fac59db880] Skip ('#EXT-X-VERSION:3')

2019-10-30T00:57:13.510Z - silly: [hls @ 0x55fac59db880] Opening 'http://rcn/chunks.m3u8?nimblesessionid=1464651' for reading

2019-10-30T00:57:13.963Z - silly: [hls @ 0x55fac59db880] Skip ('#EXT-X-VERSION:3')

2019-10-30T00:57:13.964Z - silly: [hls @ 0x55fac59db880] Opening 'http://rcn/l_5640_10656679_1771.ts?nimblesessionid=1464651' for reading

2019-10-30T00:57:14.152Z - silly: [hls @ 0x55fac59db880] Opening 'http://rcn/l_5640_10662685_1772.ts?nimblesessionid=1464651' for reading

2019-10-30T00:57:14.815Z - silly: Input #0, hls, from 'http://rcn/playlist.m3u8': Duration: N/A, start: 10656.679367, bitrate: N/A Program 0 Metadata: variant_bitrate : 1503291

2019-10-30T00:57:14.815Z - silly: Stream #0:0: Video: hevc (Main) ([36][0][0][0] / 0x0024), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 29.97 fps, 29.97 tbr, 90k tbn, 29.97 tbc Metadata: variant_bitrate : 1503291 Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp Metadata: variant_bitrate : 1503291 Option re (read input at native frame rate) cannot be applied to output url reconnect 1 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to. Error parsing options for output file reconnect 1. Error opening output files: Invalid argument

2019-10-30T00:57:14.816Z - error: avconv exited with code 1 2019-10-30T00:57:14.816Z - info: ::ffff:127.0.0.1 still connected, restarting avconv after 5 seconds ...

It takes the output option like the output url for some reason. Checking your code again to see if i see where it is failing.

Thanks for the awesome package!

Jalle19 commented 4 years ago

I'm closing this due to inactivity, if you feel there's an actual issue in the code feel free to reopen.