Wednesday, 31 May 2017

Using videoshow (npm module) with ffmpeg to conver audio+image into video

I'm trying to use the videoshow utility to combine a short audio clip with an image on my ubuntu system. I installed ffmpeg globally while in the root directory using:

sudo apt-get install ffmpeg

I then installed videoshow inside the project folder using:

sudo npm install videoshow

The project folder contains 3 files plus the node_modules folder: an image (wolf.jpg), an audio clip (wolf.mp3), and a js file (audio.js). I derived audio.js from an example script on the videoshow github page. Here is my script:

    var videoshow = require('videoshow')

var images = [
  "wolf.jpg"
]

var videoOptions = {
  fps: 25,
  loop: 5, // seconds
  transition: true,
  transitionDuration: 1, // seconds
  videoBitrate: 1024,
  videoCodec: 'libx264',
  size: '640x?',
  audioBitrate: '128k',
  audioChannels: 2,
  format: 'mp4',
  pixelFormat: 'yuv420p'
}

videoshow(images, videoOptions)
  .audio('wolf.mp3')
  .save('wolf.mp4')
  .on('start', function (command) {
    console.log('ffmpeg process started:', command)
  })
  .on('error', function (err, stdout, stderr) {
    console.error('Error:', err)
    console.error('ffmpeg stderr:', stderr)
  })
  .on('end', function (output) {
    console.error('Video created in:', output)
  })

In the terminal, inside the project folder I then call:

node audio.js

The terminal is silent for a moment followed by:

    ffmpeg process started: ffmpeg -i /tmp/videoshow-db63732f-7376-4663-a7bc-c061091e579a -y -filter_complex concat=n=1:v=1:a=0 wolf.mp4
ffmpeg process started: ffmpeg -i /tmp/videoshow-1f8851b4-c297-4070-a249-3624970dbb85 -i wolf.mp3 -y -b:a 128k -ac 2 -r 25 -b:v 1024k -vcodec libx264 -filter:v scale=w=640:h=trunc(ow/a/2)*2 -f mp4 -map 0:0 -map 1:0 -t 5 -af afade=t=in:ss=0:st=0:d=3 -af afade=t=out:st=2:d=3 -pix_fmt yuv420p wolf.mp4
Error: [Error: ffmpeg exited with code 1: ]
ffmpeg stderr: undefined

I'm not sure why this isn't working, but any/all assistance would be deeply appreciated...

Hawu'h (thanks), Roo



via delesslin

No comments:

Post a Comment