var page = require("webpage").create(); var width = 1280; var height = 720; page.viewportSize = { width: width, height: height }; var system = require('system'); if (system.args.length < 3) { console.log('please supply address URL and output name'); phantom.exit(); } var address = system.args[1]; var output = system.args[2]; page.open(address, function () { // as per https://github.com/ariya/phantomjs/issues/10619#issuecomment-33248657 page.evaluate(function(w, h) { document.body.style.width = w + "px"; document.body.style.height = h + "px"; }, width, height); page.clipRect = {top: 0, left: 0, width: width, height: height}; setInterval(function () { page.render(output, { format: "png" }); }, 250); }); // https://mindthecode.com/blog/recording-a-website-with-phantomjs-and-ffmpeg/ // https://trac.ffmpeg.org/wiki/EncodingForStreamingSites // phantomjs ../runner.js | ffmpeg -y -c:v png -f image2pipe -r 10 -t 5 -i - -f v4l2 -video_size 640x360 -i /dev/video0 -filter_complex "[0:v][1:v]overlay=640:0,format=yuv420p[v]" -map "[v]" -c:v libx264 -pix_fmt yuv420p -movflags +faststart dragon.mp4