当尝试从图像制作幻灯片时,ffmpeg抛出“输出文件#0不包含任何流”的错误。

33

我正在尝试使用PhantomJS创建视频流,该流从URL创建屏幕截图,然后将帧传输到FFMPEG,以便它可以将视频流传输到RTMP URL。目前为止,这是我尝试过的:

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

使用ffmpeg和phantomjs从url制作电影 - user4535610
实际问题是什么?你试图解决什么问题? - llogan
@LordNeckbeard 我想从URL截取屏幕并创建视频,然后将其发布到RTMP服务器。基本上,PhantomJS执行了截取屏幕并将其渲染到'/dev/stdout'的过程,因此我可以通过FFmpeg获取它们。我尝试了上面的命令,但它没有起作用。 - Abdou Tahiri
提问时一定要解释清楚它的具体问题,否则就是重复的。 - Vaviloff
1
“它不起作用”从来不是在Stack Overflow上一个好的问题描述。我会让错误信息在问题中更加突出。另外,你是否谷歌了错误信息并查看其他人解决该问题的方法?---我已经为问题标题提出了建议,请查看。 - Pekka
显示剩余3条评论
1个回答

27

您当前的命令未指定任何输入,请使用

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

2
是的,那正是我所需要的。谢谢。 我可以使用jpg而不是png吗? - Abdou Tahiri
非常感谢。此外,将 flac 转换为 mp3 的选项是:cat input | ffmpeg -i pipe:.flac -qscale:a 0 "outputfile.mp3" - will

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接