2016-11-24 30 views
3

我试图创建视频流使用phantomjs,从url创建屏幕截图,然后它将管道帧到ffmpeg,所以他可以用它将视频流式传输到rtmp网址。 这里是我试过至今:ffmpeg投掷“输出文件#0不包含任何流”当试图使图像幻灯片显示

phantomjs runner.js | ffmpeg -f image2pipe -vcodec png -c:a copy -c:v libx264 -f flv rtmp://localhost/mystream 

这里是脚本:

var page = require('webpage').create(); 
page.viewportSize = { width: 640, height: 480 }; 

page.open('http://www.goodboydigital.com/pixijs/examples/12-2/', function() { 
    setInterval(function() { 
    page.render('/dev/stdout', { format: "png" }); 
    }, 25); 
}); 

,这是输出:

ffmpeg version 3.0.2 Copyright (c) 2000-2016 the FFmpeg developers 
    built with Apple LLVM version 7.3.0 (clang-703.0.29) 
    configuration: --prefix=/usr/local/Cellar/ffmpeg/3.0.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-opencl --enable-libx264 --enable-libmp3lame --enable-libxvid --enable-vda 
    libavutil  55. 17.103/55. 17.103 
    libavcodec  57. 24.102/57. 24.102 
    libavformat 57. 25.100/57. 25.100 
    libavdevice 57. 0.101/57. 0.101 
    libavfilter  6. 31.100/6. 31.100 
    libavresample 3. 0. 0/3. 0. 0 
    libswscale  4. 0.100/4. 0.100 
    libswresample 2. 0.101/2. 0.101 
    libpostproc 54. 0.100/54. 0.100 
Output #0, flv, to 'rtmp://localhost/mystream': 
Output file #0 does not contain any stream 
+0

(http://stackoverflow.com/questions/40325667/making-a-movie-from-the- [使用的ffmpeg和phantomjs从URL拍电影] url-using-ffmpeg-and-phantomjs) – 2016-11-24 21:09:35

+0

实际问题是什么?你想解决什么问题? – LordNeckbeard

+0

@LordNeckbeard我想从url截图创建视频,然后将它们发布到rtmp服务器。基本上phantomjs完成了截图并将其渲染为'/ dev/stdout'的过程,所以我可以通过ffmpeg获取它们。我试过上面的命令,它没有工作 –

回答

5

您现在的命令中没有指定任何输入,所以用

phantomjs runner.js | ffmpeg -f image2pipe -i pipe:.png -c:a copy -c:v libx264 -f flv rtmp://localhost/mystream 

没有音频输入,因此设置音频编解码器毫无意义。如果你的输出需要的音频流,使用

phantomjs runner.js | ffmpeg -f image2pipe -i pipe:.png -f lavfi -i anullsrc -c:v libx264 -c:a aac -f flv rtmp://localhost/mystream 
+1

是的,那正是我需要的。谢谢.. 可能需要使用jpg而不是png吗? –

+1

'pipe:.jpg'是你的输入是jpeg。 – Mulvya