将ffmpeg输出到node.js中的flash播放器

时间:2013-12-10 19:17:08

标签: node.js ffmpeg streaming

我正在使用ffmpeg来获取视频源并将其直播到Flash中的浏览器。

这是代码(使用expressjs):

app.get('/stream', function(req, res) {

    var command = spawn('ffmpeg', ['-re','-i','video.avi','-c:v','libx264','-c:a','libfaac','-ar',44100,'-f','flv','-']);

    res.setHeader("Accept-Ranges", "bytes");
    res.setHeader("Content-Type", "video/x-flv");        
    command.stdout.pipe(res);

});

编辑:它使用的命令是:

ffmpeg -re -i video.avi -c:v libx264 -c:a libfaac -ar 44100 -f flv -

如果我直接在浏览器中加载此URL,它会下载flv文件,我可以在VLC播放器中播放它。但是,当我在像JWPlayer这样的播放器中使用它时,甚至试图简单地嵌入时,它都不会显示任何内容。

知道我在这里可能缺少什么吗?

谢谢!

编辑:这是ffmpeg的输出,在此之后它只是在编码时继续的字节。

ffmpeg version N-52420-gfc69033 Copyright (c) 2000-2013 the FFmpeg developers
  built on Apr 25 2013 17:10:30 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-libaacplus --enable-libass --enable-libcelt --enable-libfaac --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-openssl --enable-libopus --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxvid --prefix=/usr/local
  libavutil      52. 27.100 / 52. 27.100
  libavcodec     55.  6.100 / 55.  6.100
  libavformat    55.  3.100 / 55.  3.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 60.101 /  3. 60.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  3.100 / 52.  3.100
[avi @ 0x7ffb12004800] non-interleaved AVI
Input #0, avi, from 'video.avi':
  Metadata:
    encoder         : AVI-Mux GUI 1.17.8.3, Feb 16 201019:42:50
    JUNK            : 
  Duration: 01:58:39.79, start: 0.000000, bitrate: 1710 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 720x304 [SAR 1:1 DAR 45:19], 29.97 tbr, 29.97 tbn, 29.98 tbc
    Stream #0:1: Audio: ac3 ([0] [0][0] / 0x2000), 48000 Hz, 5.1(side), fltp, 192 kb/s
    Metadata:
      title           : videotest
[libx264 @ 0x7ffb12022000] using SAR=1/1
[libx264 @ 0x7ffb12022000] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
[libx264 @ 0x7ffb12022000] profile High, level 3.0
[libx264 @ 0x7ffb12022000] 264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=6 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
Output #0, flv, to 'pipe:':
  Metadata:
    JUNK            : 
    encoder         : Lavf55.3.100
    Stream #0:0: Video: h264 ([7][0][0][0] / 0x0007), yuv420p, 720x304 [SAR 1:1 DAR 45:19], q=-1--1, 1k tbn, 29.97 tbc
    Stream #0:1: Audio: aac ([10][0][0][0] / 0x000A), 44100 Hz, 5.1, s16, 128 kb/s
    Metadata:
      title           : videotest
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 -> libx264)
  Stream #0:1 -> #0:1 (ac3 -> libfaac)
Press [q] to stop, [?] for help
FLVme=  -43 fps= 28 q=0.0 size=       0kB time=00:00:01.48 bitrate=   2.2kbits/s    
videodatarateionframerate@=?Q??s
audiodatarate@_@audiosamplerate@刀audiosamplesize@0stereo
                                                         audiocodecid@$JUNKencoder
                                                                                  Lavf55.3.10filesize   8   -d??gd??@?'?c1--?h???"??0   ?B?????E???H??,? ?#??x264 - core 125 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - 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=6 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?Re??g?$?<<

0 个答案:

没有答案