0

I'm trying to stream a webpage captured with PhantomJS to Youtube using FMMpeg. This is the command I use:

xvfb-run phantomjs --web-security=no render.js | ffmpeg -threads 0 -y -v verbose -c:v png -r 30 -f image2pipe -i - -f lavfi -i anullsrc -strict -2 -acodec aac -ac 1 -ar 44100 -b:a 128k -c:v libx264 -s 1280x720 -pix_fmt yuv420p -f flv "rtmp://a.rtmp.youtube.com/live2/key";

And the render.js code: http://pastebin.com/raw/X9gv8iGH

It looks like it's streaming, but no feed is received by YouTube, and I can't see where the problem is. Outpout from my console

Victor
  • 13
  • 4

1 Answers1

3

Try this:

phantomjs --web-security=no render.js | ffmpeg -threads 0 -y -v verbose -c:v png -framerate 33 -f image2pipe -i - -f lavfi -i anullsrc -strict -2 -acodec aac -ac 1 -ar 44100 -b:a 128k -c:v libx264 -s 1280x720 -pix_fmt yuv420p -g 60 -r 30 -f flv "rtmp://a.rtmp.youtube.com/live2/key";

Parameter -framerate:

You can specify two frame rates: input and output. Set input frame rate with the -framerate input option (before -i). The default for reading inputs is -framerate 25 which will be set if no -framerate is specified. The output frame rate for the video stream by setting -r after -i or by using the fps filter.

So in your case framerate should be 1/period_from_phantomjs which is 1000/30 = 33.33

As for the -g 60, that will add a key frame every 2 seconds, which is probably a requirement for the youtube streaming api (I know that for facebook it is).

Milan Markovic
  • 1,250
  • 13
  • 18