h2non / videoshow

Simple node.js utility to create video slideshows from images with optional audio and visual effects using ffmpeg
MIT License
874 stars 160 forks source link

Make slideshow run based on audio, not audio based on number of images #60

Open techsin opened 6 years ago

techsin commented 6 years ago

i've 1 image, i want it to remain there until whole audio is done.

right now it's setup so audio is just background music and slides are the main content

jremi commented 6 years ago

did you solve this...? I want to also use 1 image and allow the audio length to set the video length to the total length of audio clip.

JMGoebel commented 6 years ago

Yes I have! I'm at work atm but ill try to give you an example when I get home tonight. I found a few ways to do it.

On Feb 23, 2018 12:47 PM, "jremi" notifications@github.com wrote:

did you solve this...? I want to also use 1 image and allow the audio length to set the video length to the total length of audio clip.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/h2non/videoshow/issues/60#issuecomment-368102715, or mute the thread https://github.com/notifications/unsubscribe-auth/AI4VC-EPkSPuJlUnERT_nC4q5Kmhm4Myks5tXwfJgaJpZM4ROy9w .

jremi commented 6 years ago

For anyone that may come accross this thread... Here is my solution to being able to use 1 image and have the video the total length of the audio clip duration.

var videoOptions = {
  disableFadeOut : true,
  disableFadeIn : true,
  transition: false
}
var wavFileInfo = require('wav-file-info');
wavFileInfo.infoByFilename(audio, function(err, info){
  if (err){throw err}    
  var wavFileDuration = Math.ceil(info.duration);

  // Each image in video array appears to be equal to 5 seconds
  // Build array length of duplicates to match audio wav duration
  var imageDuplicationSize = Math.ceil(wavFileDuration/5);
  var images = [];
  for(var x=0; x<=imageDuplicationSize; x++){
    images.push(__dirname + '/myImage.jpg');
  }
  videoshow(images, videoOptions)
});