32

Im trying to create video streaming using phantomjs that create screenshots from a url then it will pipe the frames to ffmpeg so he can use it to stream the video to an rtmp url . here is what i tried so far :

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

and here is the script :

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);
});

and this is the output :

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
Pekka
  • 442,112
  • 142
  • 972
  • 1,088
Abdou Tahiri
  • 4,338
  • 5
  • 25
  • 38
  • [Making a movie from the url using ffmpeg and phantomjs](http://stackoverflow.com/questions/40325667/making-a-movie-from-the-url-using-ffmpeg-and-phantomjs) –  Nov 24 '16 at 21:09
  • What is the actual question? What issue are you trying to solve? – llogan Nov 24 '16 at 21:49
  • @LordNeckbeard i want to create a video from a url screenshots and then publish them to an rtmp server . basically phantomjs did the process of taking screenshots and render them to '/dev/stdout' so i can get them by ffmpeg . i tried the command above and it didnt work – Abdou Tahiri Nov 25 '16 at 08:41
  • When asking question always be sure to explain HOW exacty is it not working, otherwise it's a duplicate. – Vaviloff Nov 25 '16 at 09:08
  • What part you didn't understand ? i add the output log of the command . – Abdou Tahiri Nov 25 '16 at 09:17
  • 1
    "It doesn't work" is never a good problem description on Stack Overflow. I'd make the error message much more prominent in the question. Also did you Google the error message and look at what other people have done to solve the problem? --- I've made a suggestion for the question title, check it out. – Pekka Nov 25 '16 at 09:19
  • Alas, there was no output when I commented. That's better now. – Vaviloff Nov 25 '16 at 09:23
  • @Pekka웃 no problem for me thanks. – Abdou Tahiri Nov 25 '16 at 09:33

1 Answers1

25

Your present command doesn't specify any input, so use

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

There's no audio input, so setting an audio codec is pointless. If your output needs an audio stream, use

phantomjs runner.js | ffmpeg -f image2pipe -i pipe:.png -f lavfi -i anullsrc -c:v libx264 -c:a aac -f flv rtmp://localhost/mystream
Gyan
  • 85,394
  • 9
  • 169
  • 201
  • 2
    Yes, that's exactly what i needed. Thanks .. May i need to use jpg instead of png ? – Abdou Tahiri Nov 25 '16 at 09:58
  • Many thanks. As well, the option for `flac` to `mp3` is: `cat input | ffmpeg -i pipe:.flac -qscale:a 0 "outputfile.mp3` – will Sep 07 '19 at 03:34