Search code examples
javascriptaudioffmpegphantomjsaudio-recording

PhantomJs | FFMPEG Audio from website


I have the following Phantom script:

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

page.open('http://ads-e-bauerse-fm-05-gos2.sharp-stream.com/popfm_dk_mp3', function () {
    setTimeout(function() {
        // Initial frame
        var frame = 0;
        // Add an interval every second
        setInterval(function() {
            frame++;
            if(frame > 10) {
                phantom.exit();
            }
        }, 1);
    }, 666);
});

Now i run this script with the following command (adding ffmpeg)

phantomjs hello.js | ffmpeg -i stereo.wav -map_channel 0.0.0 left.wav -map_channel 0.0.1 right.wav     

The error i get is: stereo.wav: No such file or directory

Now the goal of this operation is to open a website listen to the music played on the site for 10 seconds then add that as an audio file in my project.

My question is what am i doing wrong?


Solution

  • Unfortunately PhantomJS only supports opening web pages.


    I'd suggest using streamripper for what you want to do:

    apt-get install streamripper -y
    streamripper http://ads-e-bauerse-fm-05-gos2.sharp-stream.com/popfm_dk_mp3 -l 10 -k 0 -A -a stream.mp3
    

    Where -l is rip length in seconds