Quantcast

Combine unordered images to video (+MP3 audio)

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Combine unordered images to video (+MP3 audio)

Drabner
I have also posted this problem on stackoverflow (http://stackoverflow.com/questions/9600384/combine-unordered-images-to-video-mp3-audio) and will add the answer there, if I receive one on the mailing list - and vice versa.


I did a few jobs with ffmpeg and also created my own dll, using ffmpeg API directly, but for my next project, I need to be able to combine multiple images together to a video with ffmpeg, also adding a mp3 sound clip. I know that you can do that for ordered images like this:

For images:
image001.jpg image002.jpg image003.jpg etc...

ffmpeg command line:
ffmpeg -f image2 -i img%03d.jpg -i sound.mp3 output.mpg


But in our project, we do not have the images ordered like that. Instead, which images to use for the video in which order is determined at runtime (one image for each frame of a video at 30fps).

So a video with 10 frames, for example, could have to consist of the following order of images:
image001.jpg image002.jpg image111.jpg image012.jpg imageFun.jpg image001.jpg image002.jpg imageFun.jpg image055.jpg imageEnd.jpg


How would I do that using ffmpeg?
This part of the documentation (http://ffmpeg.org/ffmpeg.html#toc-image2-2) doesn't exactly help me here. I really don't want to resort to using the ffmpeg API directly from C/C++, but fear that I have to if that is not possible "natively".


Addition:
If that is not possible with ffmpeg, but with some other software (that runs on Linux and can be controlled from command line) - I'm all ears! ;)
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combine unordered images to video (+MP3 audio)

Andrey Utkin
2012/3/7 Drabner <[hidden email]>:
> But in our project, we do not have the images ordered like that. Instead,
> which images to use for the video in which order is determined at runtime
> (one image for each frame of a video at 30fps).
>
> So a video with 10 frames, for example, could have to consist of the
> following order of images:
> image001.jpg image002.jpg image111.jpg image012.jpg imageFun.jpg
> image001.jpg image002.jpg imageFun.jpg image055.jpg imageEnd.jpg

Just copy or symlink your images to another dir with other names, to
have names form an order.
If not acceptable - then yes, you have to use API.

--
Andrey Utkin
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combine unordered images to video (+MP3 audio)

Drabner
Damn.

Well, we'll have to try out if that affects performance or something else too much.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Combine unordered images to video (+MP3 audio)

Drabner
There is indeed a better way to do this, via piping!
A user on stackoverflow ( http://stackoverflow.com/questions/9600384/combine-unordered-images-to-video-mp3-audio ) posted that answer.


I am now using the following command do do what I want to achieve:

type "list of jpeg images here" | ffmpeg -s 640x360 -f image2pipe -vcodec mjpeg -r 30 -i - -i audioMp3.data -y video.mp4
Loading...