Mostra notizie nelle discussioni
  • Avatar
    ☺
    Scritto da
    ::1
    il 2014-03-12 23:43:31.0 alle 2014-03-12 23:43:31.0
    Trollate totali: 12321
    nodejs + ffmpeg + youtube-dl = maximum awesomeness
    Ho appena partorito questa cosa stasera e pensavo di condividerla con voi che non vi meritate un cazzo™.
    È uno script per coffee-script da girare su runtime nodejs, crea un server http che streamma l'audio di un video di youtube:
    http = require 'http'
    spawn = require('child_process').spawn
    
    server = http.createServer (req, res) ->
      videoId = req.url.substring 1
      console.log videoId
      ffmpeg = spawn 'ffmpeg', [
        '-i'
        '-'
        '-vn'
        '-sn'
        '-f'
        'mp3'
        '-loglevel'
        'quiet'
        '-'
      ]
      ffmpeg.stderr.on 'data', (data) -> console.error 'ffmpeg', data.toString 'utf8'
      youtubeDl = spawn 'youtube-dl', [
        '-q'
        '-o'
        '-'
        "http://www.youtube.com/watch?v=#{videoId}"
      ]
      youtubeDl.stderr.on 'data', (data) -> console.error 'youtube-dl', data.toString 'utf8'
      youtubeDl.stdin.end()
      youtubeDl.stdout.pipe ffmpeg.stdin
      res.writeHead 200,
        'Content-Type' : 'audio/mpeg'
      ffmpeg.stdout.pipe res
    
    server.listen 8080
    


    Una volta lanciato se viene richiamato dal browser l'indirizzo http://localhost:8080/dQw4w9WgXcQ viene fuori l'audio codificato mp3 preso dal video.
    Young professional woman and busy mom.
    • Avatar
      Scritto da
      Non Autenticato
      il 2014-03-12 23:59:09.0 alle 2014-03-12 23:59:09.0
      Re: nodejs + ffmpeg + youtube-dl = maximum awesomeness
      > Ho appena partorito questa cosa stasera e pensavo di condividerla con voi che non vi meritate un cazzo™.
      > È uno script per coffee-script da girare su runtime nodejs, crea un server http che streamma l'audio di un video di youtube:
      >
      > http = require 'http'
      > spawn = require('child_process').spawn
      > 
      > server = http.createServer (req, res) ->
      > videoId = req.url.substring 1
      > console.log videoId
      > ffmpeg = spawn 'ffmpeg', [
      > '-i'
      > '-'
      > '-vn'
      > '-sn'
      > '-f'
      > 'mp3'
      > '-loglevel'
      > 'quiet'
      > '-'
      > ]
      > ffmpeg.stderr.on 'data', (data) -> console.error 'ffmpeg', data.toString 'utf8'
      > youtubeDl = spawn 'youtube-dl', [
      > '-q'
      > '-o'
      > '-'
      > "http://www.youtube.com/watch?v=#{videoId}"
      > ]
      > youtubeDl.stderr.on 'data', (data) -> console.error 'youtube-dl', data.toString 'utf8'
      > youtubeDl.stdin.end()
      > youtubeDl.stdout.pipe ffmpeg.stdin
      > res.writeHead 200,
      > 'Content-Type' : 'audio/mpeg'
      > ffmpeg.stdout.pipe res
      > 
      > server.listen 8080
      > 

      >
      > Una volta lanciato se viene richiamato dal browser l'indirizzo http://localhost:8080/dQw4w9WgXcQ viene fuori l'audio codificato mp3 preso dal video.

      Produce anche l'mp3?

      Hai poi provato se aggiornando Java funzionano anche i link di samurai?
    • Avatar
      Scritto da
      Non Autenticato
      il 2014-03-13 08:42:56.0 alle 2014-03-13 08:42:56.0
      Re: nodejs + ffmpeg + youtube-dl = maximum awesomeness
      lamer@polpot ~/tmp $ nodejs scriptsuora.js 
      
      /home/lamer/tmp/scriptsuora.js:1
      tion (exports, require, module, __filename, __dirname) { http = require 'http'
                                                                              ^^^^^^
      SyntaxError: Unexpected string
          at Module._compile (module.js:439:25)
          at Object.Module._extensions..js (module.js:474:10)
          at Module.load (module.js:356:32)
          at Function.Module._load (module.js:312:12)
          at Function.Module.runMain (module.js:497:10)
          at startup (node.js:119:16)
          at node.js:901:3
      


      In PHP non sarebbe successo A bocca storta
      • Avatar
        ☺
        Scritto da
        ::1
        il 2014-03-13 08:50:15.0 alle 2014-03-13 08:50:15.0
        Trollate totali: 12321
        Re: nodejs + ffmpeg + youtube-dl = maximum awesomeness
        Scritto da:
        >
        > lamer@polpot ~/tmp $ nodejs scriptsuora.js 
        > 
        > /home/lamer/tmp/scriptsuora.js:1
        > tion (exports, require, module, __filename, __dirname) { http = require 'http'
        > ^^^^^^
        > SyntaxError: Unexpected string
        > at Module._compile (module.js:439:25)
        > at Object.Module._extensions..js (module.js:474:10)
        > at Module.load (module.js:356:32)
        > at Function.Module._load (module.js:312:12)
        > at Function.Module.runMain (module.js:497:10)
        > at startup (node.js:119:16)
        > at node.js:901:3
        > 

        >
        > In PHP non sarebbe successo A bocca storta

        C'è scritto che è coffee-script, non javascript.
        Devi installare coffee-script (sudo npm install -g coffee-script se non ce l'hai nel package manager della tua distro) e lanciare coffee scriptsuora.coffee.

        **Modificato dall'autore il 13.03.2014 08:55**
        Young professional woman and busy mom.
<softv>

Pagina generata in 123 millisecondi

Utenti attivi: 14 nell'ultimo minuto, 26 negli ultimi cinque minuti, 42 negli ultimi 15 minuti