fluent-ffmpeg / node-fluent-ffmpeg

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

Buffer as input return a incomplete video #892

Open nunowar opened 5 years ago

nunowar commented 5 years ago

When using buffer as input, the output video is incomplete, but if i use the same input file as file, the video is ok, some help to find the problem?

Version information

Code to reproduce

let inStream = streamifier.createReadStream(file.Body);

ffmpeg(inStream).inputFormat('gif')
 .outputOptions(['-pix_fmt yuv420p', '-movflags frag_keyframe+empty_moov', '-movflags +faststart'])
 .toFormat('mp4').save('test.mp4')
 .on('error', function(err, stdout, stderr) {
      console.log('Cannot process video: ' + err.message);
 })
 .on('end', function() {
      console.log('Finished processing');
 });

Expected results

Convert all video.

Observed results

The output video is incomplete, just have 1 second.

Stderr output: ffmpeg version 4.1.1-0york1~18.04 Copyright (c) 2000-2019 the FFmpeg developers
Stderr output:   built with gcc 7 (Ubuntu 7.3.0-27ubuntu1~18.04)
Stderr output:   configuration: --prefix=/usr --extra-version='0york1~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-nonfree --enable-libfdk-aac --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
Stderr output:   libavutil      56. 22.100 / 56. 22.100
Stderr output:   libavcodec     58. 35.100 / 58. 35.100
Stderr output:   libavformat    58. 20.100 / 58. 20.100
Stderr output:   libavdevice    58.  5.100 / 58.  5.100
Stderr output:   libavfilter     7. 40.101 /  7. 40.101
Stderr output:   libavresample   4.  0.  0 /  4.  0.  0
Stderr output:   libswscale      5.  3.100 /  5.  3.100
Stderr output:   libswresample   3.  3.100 /  3.  3.100
Stderr output:   libpostproc    55.  3.100 / 55.  3.100
Stderr output: Input #0, gif, from 'pipe:0':
Stderr output:   Duration: N/A, bitrate: N/A
Stderr output:     Stream #0:0: Video: gif, bgra, 820x462, 25 fps, 25 tbr, 100 tbn, 100 tbc
Stderr output: Stream mapping:
Stderr output:   Stream #0:0 -> #0:0 (gif (native) -> h264 (libx264))
Stderr output: [libx264 @ 0x564accb8eec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX512
Stderr output: [libx264 @ 0x564accb8eec0] profile High, level 3.0
Stderr output: [libx264 @ 0x564accb8eec0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Stderr output: Output #0, mp4, to 'test.mp4':
Stderr output:   Metadata:
Stderr output:     encoder         : Lavf58.20.100
Stderr output:     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 820x462, q=-1--1, 25 fps, 12800 tbn, 25 tbc
Stderr output:     Metadata:
Stderr output:       encoder         : Lavc58.35.100 libx264
Stderr output:     Side data:
Stderr output:       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stderr output: pipe:0: Input/output error
Stderr output: frame=    7 fps=0.0 q=28.0 Lsize=      35kB time=00:00:00.16 bitrate=1796.8kbits/s speed=1.53x    
Stderr output: video:34kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.893366%
Stderr output: [libx264 @ 0x564accb8eec0] frame I:1     Avg QP:14.49  size: 18796
Stderr output: [libx264 @ 0x564accb8eec0] frame P:2     Avg QP:24.29  size:  4460
Stderr output: [libx264 @ 0x564accb8eec0] frame B:4     Avg QP:27.03  size:  1634
Stderr output: [libx264 @ 0x564accb8eec0] consecutive B-frames: 14.3% 28.6%  0.0% 57.1%
Stderr output: [libx264 @ 0x564accb8eec0] mb I  I16..4: 71.4%  3.9% 24.7%
Stderr output: [libx264 @ 0x564accb8eec0] mb P  I16..4:  0.7%  1.9%  1.4%  P16..4:  6.4%  4.4%  3.0%  0.0%  0.0%    skip:82.2%
Stderr output: [libx264 @ 0x564accb8eec0] mb B  I16..4:  0.1%  0.4%  0.1%  B16..8:  9.5%  2.2%  1.1%  direct: 0.8%  skip:85.8%  L0:58.5% L1:32.8% BI: 8.7%
Stderr output: [libx264 @ 0x564accb8eec0] 8x8 transform intra:8.5% inter:17.9%
Stderr output: [libx264 @ 0x564accb8eec0] coded y,uvDC,uvAC intra: 17.9% 24.5% 23.2% inter: 3.3% 3.9% 3.4%
Stderr output: [libx264 @ 0x564accb8eec0] i16 v,h,dc,p: 86%  8%  6%  0%
Stderr output: [libx264 @ 0x564accb8eec0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30%  8% 60%  1%  0%  0%  0%  1%  0%
Stderr output: [libx264 @ 0x564accb8eec0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 21% 26%  4%  4%  4%  3%  4%  3%
Stderr output: [libx264 @ 0x564accb8eec0] i8c dc,h,v,p: 81% 11%  7%  1%
Stderr output: [libx264 @ 0x564accb8eec0] Weighted P-Frames: Y:0.0% UV:0.0%
Stderr output: [libx264 @ 0x564accb8eec0] ref P L0: 89.1%  3.0%  4.9%  3.0%
Stderr output: [libx264 @ 0x564accb8eec0] ref B L0: 81.6% 18.4%
Stderr output: [libx264 @ 0x564accb8eec0] ref B L1: 96.2%  3.8%
Stderr output: [libx264 @ 0x564accb8eec0] kb/s:978.66
Stderr output: 
Finished processing
llccrr commented 5 years ago

Any update on this ?

federicocarboni commented 4 years ago

Related to #1013 for GIFs as inputs you have to set the input format to gif_pipe, this is not mentioned in FFmpeg's Docs unfortunately.