VideoHelp Forum




+ Reply to Thread
Results 1 to 14 of 14
  1. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Hi guys and gals!

    First off let me say, this is a great community! Long time reader, first time poster.

    Ok, here's my question:

    I have a series of sequentially named images (Slide01.jpg, Slide02.jpg, ...), and sequentially named wave files (Slide01.wav, Slide02.wav, ...).

    What I'd like to do is build a video where the images are synced with the audio, so Slide01.jpg is displayed the whole time Slide01.wav is playing, then Slide02.jpg is displayed while Slide02.wav is playing, etc.

    I have a directory which contains both the images and the wav files.

    I've been monkeying around with ffmpeg, and can get it to build a video from the sequence of images w/o audio just find by doing:
    Code:
    ffmpeg -i Slide%02d.jpg -r 15 output.flv
    The %02d means "for each file in this directory named Slidexx.jpg (where xx is a 2 digit number).
    The -r switch sets the framerate

    I've tried to add the audio in as a mapped stream with this line:
    Code:
    ffmpeg  -i Slide%02d.jpg -i Slide%02d.wav -map 0:0 -map 1:0 -r 15 output.flv
    Seems like it should work, however, ffmpeg barfs telling me that it can't find "Slide%02d.wav".

    I haven't been able to find any infos on the iwebs regarding adding audio to a video being created from images. I KNOW this has to be possible....

    Any ideas gang? I'm open to using a tool other than ffmpeg, and don't care about platform as we do an equal amount of work in both Windows and Linux.

    Thanks in advance,
    Sean
    Quote Quote  
  2. aBigMeanie aedipuss's Avatar
    Join Date
    Oct 2005
    Location
    666th portal
    Search Comp PM
    i know dvdslideshowgui can sync multiple slides to one audio, don't know about many but it may be worth trying. as it's free anyway.

    http://download.videohelp.com/tin2tin/

    if you had no other choice you could use it to do each slide/song individually and then join all the resultant vobs into one dvd.
    --
    "a lot of people are better dead" - prisoner KSC2-303
    Quote Quote  
  3. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Thanks for the info!

    The video I'm intending to create is not destined to become a DVD. It's going to ultimately be a .flv (flash video).

    I had the same thought about creating separate clips for each audio/image pair, then joining, and am currently fighting with a Windows batch script to do this for me. I think I'll move over to my Linux box as Batch makes me want to rip my hair out by the handful!

    I'd also like to stay in the command line as this process will need to be scripted.

    Any other thoughts?
    Quote Quote  
  4. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Ok, so after more playing around with things, what I've been doing is this:

    I have a shell script that loops over a directory. Here's my script:
    Code:
    #!/bin/sh
    
    for f in /home/boyer/VideoTest/*.wav
    
    	do
    	{
    	  wav=`basename $f`
    	  name=`basename $f .wav`
    	  jpg="${name}.jpg"
    	  output="${name}.avi"
    
    	  convert $jpg -resize 656x492\! -quality 100% $jpg
    	  ffmpeg -i $wav -i $jpg $output
    
    	}
    done;
    
    for f in /home/boyer/VideoTest/*avi
    	do
    	{
    	  file=`basename $f`
    	  files="${files} $file"
    	}
    done;
    
    mencoder -ovc copy -oac copy -o joined.avi $files
    As you can see, for each file in the dir, I'm resising my image (from 660x495) to 656x492 (perfect 4:3 ratio). Then I'm running ffmpeg, giving it a wav source, and a jpg source.

    An avi (I've also tested with mpg and flv) is outputted.

    For whatever reason, the video files produced with ffmpeg are corrupt. The avi's have broken headers and can't seek and won't combine), and the mpgs won't play video at all...

    Then I'm attempting to combine (in this case the avi's) using mencoder, but it tells me my source videos are broken, and thus my output video is broken.

    It's clear that something is going wrong from the very beginning. Should I be including some -map options on my ffmpeg call?

    Advice?

    Thanks!
    Sean
    Quote Quote  
  5. Member Soopafresh's Avatar
    Join Date
    Jan 2004
    Location
    United States
    Search Comp PM
    Perhaps you should specify a different codec to use

    -vcodec libx264 -b 2000

    or use a lossless one like -vcodec huffyuv then convert the final product in mencoder to something that will work in an flv container (typically h264)
    "Quality is cool, but don't forget... Content is King!"
    Quote Quote  
  6. Member
    Join Date
    Nov 2009
    Location
    United States
    Search Comp PM
    Here's an avisynth script that will create a video of your image at your desired frame rate for the duration of the length of your wave file.

    Just feed the AudioNImage function the location of the wave file, the location of the image file, and the required frames per second of the video.

    Example:

    Code:
    audio="D:\video\Captures\rocky_mountains.wav"
    picture="D:\video\Captures\firstframe.bmp"
    AudioNImage(audio,picture,15)
    
    #spline32resize(640,480)
    
    function AudioNImage(string wave, string image, float fps)
    {
    aud=Wavsource(wave)
    length=audiolengthF(aud)
    rate=Audiorate(aud)
    frames=Int((length/rate)*fps)
    vid=ImageSource(image, end=Int(frames), fps=fps)
    return audiodub(vid,aud)
    }
    You can add a resize after the function if needed.

    You can then feed ffmpeg like this: ffmpeg -i avsfile.avs outputfile.flv
    Quote Quote  
  7. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Cheers you guys! Saved me with the avisynth

    I'd still love to figure out why I can't get a usable video out of ffmpeg on it's own, but this get's me going for now!

    I'll post back if I ever discover a way to do it without avisynth.

    Thanks again!
    Quote Quote  
  8. Member
    Join Date
    Nov 2006
    Location
    United States
    Search Comp PM
    Originally Posted by Khaver View Post

    You can then feed ffmpeg like this: ffmpeg -i avsfile.avs outputfile.flv

    Hi I am trying to do the same thing, I got your script to work (I had to change the output file extension to .avi), but the image in the output video is flipped vertically.

    Do you know how to fix that?
    Last edited by Rotsujin; 27th Feb 2010 at 20:31.
    Quote Quote  
  9. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Oddly enough the same thing was happening to me too!

    All I did was flip my images before hand using image magick. This was ok, since I was resizing the images explicitly first anyway. Here's my line:
    Code:
    imgconv image.png -resize 656x492! -flip imagesmall.png
    Quote Quote  
  10. Member
    Join Date
    Jul 2009
    Location
    Spain
    Search Comp PM
    If necessary, you could also do the flipping in the Avisynth script by changing
    vid=ImageSource(image, end=Int(frames), fps=fps)
    to
    vid=ImageSource(image, end=Int(frames), fps=fps).FlipVertical()
    Quote Quote  
  11. Member
    Join Date
    Nov 2006
    Location
    United States
    Search Comp PM
    @boyer & Gavino: Thanks for the help!
    Quote Quote  
  12. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    Hey guys!

    Back again with another question regarding this issue.

    I've had to abandon using avisynth, as for the live of me (and our IT team) we cannot get avisynth to build on Linux (which is ultimately where this stuff has to run).

    Using ffmpeg, I can create a video from a png image, and a wave file.

    The problem is, that the video stream is only 34ms long where the audio stream is 4:43 let's say.
    On Windows, this avi will play/seek just fine, but on Linux, it is totally broken.

    My question is, is there a way to sync the length of the video stream (in this case the input is a png image) to the length of the audio stream, without knowing the length of the wav at runtime?

    If worse comes to worse, I could find a tool to extract the runtime of the wav, then manually put that into the ffmpeg command, but I'd rather avoid that if possible.

    Any ideas?
    Quote Quote  
  13. Member
    Join Date
    Jan 2010
    Location
    Canada
    Search Comp PM
    PS - the solution for creating a piece of video from a still image with audio is using the -loop_input switch on the image input side.

    Code:
    ffmpeg -loop_input -r 1 -i image.png -i audio.mp3 output.avi
    The above code will loop the single image the entire length of the mp3 audio file given. The video stream will be VERY small, because you can input at 1 frame per second. If your output format won't support 1 fps, just jack it up on the output. Voila!
    Quote Quote  
  14. *del
    Last edited by bseos; 3rd Mar 2012 at 03:02. Reason: made new thread
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!