fluent-ffmpeg / node-fluent-ffmpeg

A fluent API to FFMPEG (http://www.ffmpeg.org)
MIT License
7.97k stars 881 forks source link

Conversion failed! (Error closing file rtmps://live-api-s.facebook.com:443/rtmp/2184681118354596?), (Error writing trailer of rtmps://live-api-s.facebook.com:443/rtmp/2184681118354596?) #1176

Open bluecodetechnology opened 2 years ago

bluecodetechnology commented 2 years ago

Version information

Code to reproduce

stream_video_facebook: (path_facebook, rtmp_server_url_facebook, callback) => {
    return new Promise((resolve, reject) => {
        var stream_facebook = fs.createReadStream(path_facebook);  // create a read-stream from the file path

        ffmpeg({  // create a ffmpeg instance from the read-stream
            source: stream_facebook // pipe the read-stream to the ffmpeg instance 
         })

         .addOutputOption('-vcodec libx264')
         .addOutputOption('-acodec aac')
         .addInputOption(`-i ${path_facebook}`)
         .addOutputOption('-f flv') // set the output format to flv
         .addInputOption('-thread_queue_size 1024')
         .addOutputOption('-ab 128k')
         .addOutputOption('-vb 800k')
         .addOutputOption('-s 720x360')
         .addOutputOption('-r 30')

        .on('error', function(err, stdout, stderr) {  // handle encoding errors here
            console.log('ffmpeg output for facebook:\n' + stdout);
            console.log('ffmpeg stderr for facebook:\n' + stderr);
            // console.log(err, 'err fb');
            // reject(err);
            //callback({ status: 400, message: "facebook error" + err, data: null })  // if an error occurs, log it to the console
        })
        .on('end', function() { // handle encoding finished here 
            resolve(true);
            callback({
                    status: 200,
                    message: "Successfully streamed to facebook",
                }
            );
        })

        .save(rtmp_server_url_facebook); // save the output to a file

    });
},

Expected results

The expected result is to stream the video file to facebook through the rtmp url which it actually streams.

Observed results

The Observed result is that the video streams to twitch but i get this error at the end which means ffmpeg did not work please whats wrong.

Fluent FFMPEG stderr

ffmpeg output for facebook:

ffmpeg stderr for facebook: frame= 912 fps= 65 q=8.0 size= 2620kB time=00:00:30.39 bitrate= 706.0kbits/s speed=2.18x
frame= 940 fps= 65 q=8.0 size= 2691kB time=00:00:31.32 bitrate= 703.8kbits/s speed=2.16x
frame= 988 fps= 66 q=10.0 size= 2842kB time=00:00:32.71 bitrate= 711.5kbits/s speed=2.18x
frame= 1046 fps= 68 q=7.0 size= 2968kB time=00:00:34.57 bitrate= 703.2kbits/s speed=2.23x
frame= 1100 fps= 69 q=6.0 size= 3051kB time=00:00:36.61 bitrate= 682.5kbits/s speed=2.29x
frame= 1178 fps= 71 q=6.0 size= 3135kB time=00:00:39.21 bitrate= 654.9kbits/s speed=2.38x
frame= 1244 fps= 73 q=5.0 size= 3217kB time=00:00:41.54 bitrate= 634.5kbits/s speed=2.45x
frame= 1309 fps= 75 q=5.0 size= 3303kB time=00:00:43.46 bitrate= 622.5kbits/s speed=2.49x
frame= 1365 fps= 76 q=5.0 size= 3354kB time=00:00:45.72 bitrate= 601.0kbits/s speed=2.54x
frame= 1434 fps= 78 q=4.0 size= 3495kB time=00:00:47.57 bitrate= 601.7kbits/s speed=2.57x
frame= 1494 fps= 79 q=4.0 size= 3608kB time=00:00:49.89 bitrate= 592.3kbits/s speed=2.63x
frame= 1554 fps= 80 q=4.0 size= 3697kB time=00:00:51.75 bitrate= 585.2kbits/s speed=2.65x
frame= 1617 fps= 81 q=3.0 size= 3744kB time=00:00:53.70 bitrate= 571.0kbits/s speed=2.68x
frame= 1673 fps= 82 q=3.0 size= 3807kB time=00:00:55.70 bitrate= 559.8kbits/s speed=2.71x
frame= 1721 fps= 82 q=3.0 size= 3878kB time=00:00:57.33 bitrate= 554.1kbits/s speed=2.73x
frame= 1782 fps= 83 q=3.0 size= 3981kB time=00:00:59.21 bitrate= 550.8kbits/s speed=2.75x
frame= 1816 fps= 82 q=2.0 size= 4003kB time=00:01:00.58 bitrate= 541.3kbits/s speed=2.75x
frame= 1865 fps= 83 q=2.0 size= 4044kB time=00:01:01.97 bitrate= 534.6kbits/s speed=2.75x
frame= 1918 fps= 83 q=2.0 size= 4122kB time=00:01:03.83 bitrate= 529.0kbits/s speed=2.77x
frame= 1978 fps= 84 q=2.0 size= 4193kB time=00:01:06.08 bitrate= 519.8kbits/s speed=2.81x
frame= 2056 fps= 85 q=1.0 size= 4278kB time=00:01:08.47 bitrate= 511.8kbits/s speed=2.85x
frame= 2106 fps= 86 q=1.0 size= 4327kB time=00:01:10.33 bitrate= 504.0kbits/s speed=2.86x
frame= 2158 fps= 86 q=1.0 size= 4372kB time=00:01:11.72 bitrate= 499.3kbits/s speed=2.86x
frame= 2216 fps= 87 q=1.0 size= 4432kB time=00:01:13.65 bitrate= 493.0kbits/s speed=2.88x
frame= 2253 fps= 86 q=1.0 size= 4488kB time=00:01:14.97 bitrate= 490.3kbits/s speed=2.88x
frame= 2294 fps= 86 q=1.0 size= 4634kB time=00:01:16.37 bitrate= 497.1kbits/s speed=2.87x
frame= 2339 fps= 86 q=0.0 size= 4746kB time=00:01:18.18 bitrate= 497.3kbits/s speed=2.89x
frame= 2383 fps= 86 q=0.0 size= 4778kB time=00:01:19.62 bitrate= 491.6kbits/s speed=2.89x
frame= 2440 fps= 87 q=0.0 size= 4846kB time=00:01:21.47 bitrate= 487.3kbits/s speed= 2.9x
frame= 2496 fps= 87 q=0.0 size= 5026kB time=00:01:23.33 bitrate= 494.1kbits/s speed=2.92x
frame= 2548 fps= 88 q=0.0 size= 5166kB time=00:01:24.72 bitrate= 499.5kbits/s speed=2.91x
frame= 2590 fps= 87 q=0.0 size= 5239kB time=00:01:26.12 bitrate= 498.3kbits/s speed=2.91x
frame= 2642 fps= 88 q=0.0 size= 5354kB time=00:01:27.98 bitrate= 498.5kbits/s speed=2.92x
frame= 2703 fps= 88 q=0.0 size= 5491kB time=00:01:29.86 bitrate= 500.6kbits/s speed=2.93x
frame= 2758 fps= 89 q=0.0 size= 5680kB time=00:01:31.69 bitrate= 507.5kbits/s speed=2.95x
frame= 2829 fps= 89 q=0.0 size= 5863kB time=00:01:34.15 bitrate= 510.1kbits/s speed=2.98x
frame= 2885 fps= 90 q=0.0 size= 5993kB time=00:01:36.10 bitrate= 510.9kbits/s speed=2.99x
frame= 2943 fps= 90 q=0.0 size= 6144kB time=00:01:38.19 bitrate= 512.5kbits/s speed=3.01x
frame= 2993 fps= 90 q=0.0 size= 6231kB time=00:01:39.59 bitrate= 512.5kbits/s speed=3.01x
frame= 3043 fps= 90 q=0.0 size= 6284kB time=00:01:41.44 bitrate= 507.5kbits/s speed=3.02x
frame= 3098 fps= 91 q=0.0 size= 6322kB time=00:01:43.30 bitrate= 501.3kbits/s speed=3.02x
frame= 3131 fps= 90 q=0.0 size= 6342kB time=00:01:44.23 bitrate= 498.4kbits/s speed=3.01x
frame= 3161 fps= 90 q=0.0 size= 6371kB time=00:01:45.16 bitrate= 496.3kbits/s speed=2.99x
frame= 3214 fps= 90 q=0.0 size= 6500kB time=00:01:47.02 bitrate= 497.5kbits/s speed= 3x
frame= 3260 fps= 90 q=0.0 size= 6602kB time=00:01:48.80 bitrate= 497.1kbits/s speed=3.01x
frame= 3306 fps= 90 q=0.0 size= 6759kB time=00:01:50.27 bitrate= 502.2kbits/s speed=3.01x
frame= 3344 fps= 90 q=0.0 size= 6893kB time=00:01:51.31 bitrate= 507.2kbits/s speed=2.99x
frame= 3396 fps= 90 q=0.0 size= 6976kB time=00:01:53.05 bitrate= 505.5kbits/s speed= 3x
frame= 3433 fps= 90 q=0.0 size= 7013kB time=00:01:54.45 bitrate= 501.9kbits/s speed= 3x
frame= 3467 fps= 90 q=0.0 size= 7175kB time=00:01:55.38 bitrate= 509.4kbits/s speed=2.98x
frame= 3512 fps= 90 q=0.0 size= 7313kB time=00:01:56.79 bitrate= 512.9kbits/s speed=2.98x
frame= 3551 fps= 89 q=0.0 size= 7396kB time=00:01:58.16 bitrate= 512.7kbits/s speed=2.97x
frame= 3592 fps= 89 q=0.0 size= 7490kB time=00:01:59.55 bitrate= 513.2kbits/s speed=2.97x
frame= 3634 fps= 89 q=0.0 size= 7582kB time=00:02:00.95 bitrate= 513.5kbits/s speed=2.97x
frame= 3688 fps= 89 q=0.0 size= 7868kB time=00:02:02.81 bitrate= 524.8kbits/s speed=2.98x
frame= 3760 fps= 90 q=0.0 size= 8112kB time=00:02:05.13 bitrate= 531.1kbits/s speed= 3x
frame= 3827 fps= 91 q=0.0 size= 8351kB time=00:02:07.45 bitrate= 536.8kbits/s speed=3.02x
frame= 3881 fps= 91 q=0.0 size= 8510kB time=00:02:09.31 bitrate= 539.1kbits/s speed=3.02x
frame= 3952 fps= 91 q=0.0 size= 8589kB time=00:02:11.63 bitrate= 534.5kbits/s speed=3.04x
frame= 4008 fps= 92 q=0.0 size= 8671kB time=00:02:13.49 bitrate= 532.1kbits/s speed=3.05x
frame= 4055 fps= 92 q=0.0 size= 8752kB time=00:02:14.90 bitrate= 531.5kbits/s speed=3.05x
frame= 4111 fps= 92 q=0.0 size= 8981kB time=00:02:16.76 bitrate= 537.9kbits/s speed=3.05x
frame= 4150 fps= 92 q=0.0 size= 9049kB time=00:02:18.13 bitrate= 536.6kbits/s speed=3.05x
frame= 4198 fps= 92 q=0.0 size= 9371kB time=00:02:19.99 bitrate= 548.4kbits/s speed=3.06x
frame= 4251 fps= 92 q=0.0 size= 9736kB time=00:02:21.85 bitrate= 562.2kbits/s speed=3.06x
[tls @ 0x79d4d80] Error in the push function. [tls @ 0x79d4d80] IO error: Broken pipe av_interleaved_write_frame(): Broken pipe Last message repeated 1 times [flv @ 0x798a7c0] Failed to update header with correct duration. [flv @ 0x798a7c0] Failed to update header with correct filesize. Error writing trailer of rtmps://live-api-s.facebook.com:443/rtmp/2184681118354596?s_bl=1&s_oil=2&s_oilp=videoinfra_live_multi_e2o_2_vcache_pullprod&s_oilu=videoinfra_live_e2o_poc&s_ow=20&s_psm=1&s_r2f=1&s_sw=0&s_tids=1&s_vt=api-s&a=Aby3oAuUAKsPvq30: Broken pipe frame= 4315 fps= 92 q=0.0 Lsize= 9832kB time=00:02:23.73 bitrate= 560.4kbits/s speed=3.07x
video:7404kB audio:2273kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.602904% [tls @ 0x79d4d80] The specified session has been invalidated for some reason. Last message repeated 1 times Error closing file rtmps://live-api-s.facebook.com:443/rtmp/2184681118354596?s_bl=1&s_oil=2&s_oilp=videoinfra_live_multi_e2o_2_vcache_pullprod&s_oilu=videoinfra_live_e2o_poc&s_ow=20&s_psm=1&s_r2f=1&s_sw=0&s_tids=1&s_vt=api-s&a=Aby3oAuUAKsPvq30: Input/output error [libx264 @ 0x78c6980] frame I:18 Avg QP: 1.64 size: 39022 [libx264 @ 0x78c6980] frame P:1195 Avg QP: 1.80 size: 4435 [libx264 @ 0x78c6980] frame B:3102 Avg QP: 4.66 size: 513 [libx264 @ 0x78c6980] consecutive B-frames: 2.3% 3.9% 4.7% 89.1% [libx264 @ 0x78c6980] mb I I16..4: 68.1% 5.4% 26.5% [libx264 @ 0x78c6980] mb P I16..4: 3.5% 0.3% 1.2% P16..4: 7.5% 1.0% 1.0% 0.0% 0.0% skip:85.6% [libx264 @ 0x78c6980] mb B I16..4: 0.3% 0.0% 0.1% B16..8: 4.4% 0.4% 0.1% direct: 0.8% skip:94.0% L0:44.1% L1:53.3% BI: 2.6% [libx264 @ 0x78c6980] final ratefactor: -3.13 [libx264 @ 0x78c6980] 8x8 transform intra:5.4% inter:27.6% [libx264 @ 0x78c6980] coded y,uvDC,uvAC intra: 29.9% 17.9% 16.8% inter: 1.8% 1.9% 1.5% [libx264 @ 0x78c6980] i16 v,h,dc,p: 46% 53% 1% 0% [libx264 @ 0x78c6980] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 32% 34% 28% 1% 1% 0% 1% 0% 2% [libx264 @ 0x78c6980] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 28% 34% 16% 2% 3% 3% 5% 2% 6% [libx264 @ 0x78c6980] i8c dc,h,v,p: 79% 16% 4% 0% [libx264 @ 0x78c6980] Weighted P-Frames: Y:2.4% UV:2.0% [libx264 @ 0x78c6980] ref P L0: 83.0% 4.3% 9.3% 3.3% 0.1% [libx264 @ 0x78c6980] ref B L0: 82.4% 15.8% 1.8% [libx264 @ 0x78c6980] ref B L1: 96.5% 3.5% [libx264 @ 0x78c6980] kb/s:422.42 [aac @ 0x79d5d00] Qavg: 713.294 Conversion failed!