Home/News | About | Download | Documentation | Forum | Bug Reports | Contact | Donations | Consulting | Projects | Legal | Security | FATE


This forum has not been maintained for a long time and will probably get deleted in the near future.
For faster responses to your questions, please use StackOverflow instead and tag your questions with "FFmpeg".
If you need a backup of the posts from this forum, please contact me directly.

Tip: Create a video slideshow from images

A collection of useful tutorials for some common tasks.

Tip: Create a video slideshow from images

Postby burek » Mon Apr 02, 2012 2:19 pm

This will create a video slideshow (using video codec libx264) from series of png images, named named img001.png, img002.png, img003.png, ...
(each image will have a duration of 5 seconds)
Code: Select all
ffmpeg -f image2 -r 1/5 -i img%03d.png -vcodec libx264 out.mp4


This will create a slideshow in which each image has a duration of 15 seconds:
Code: Select all
ffmpeg -f image2 -r 1/15 -i img%03d.png -vcodec libx264 out.mp4


If you want to create a video out of just one image, this will do (output video duration is set to 30 seconds):
Code: Select all
ffmpeg -loop 1 -f image2 -i img.png -vcodec libx264 -t 30 out.mp4


If you don't have images numbered and ordered in series (img001.jpg, img002.jpg, img003.jpg) but rather random bunch of images, you might try this:
Code: Select all
cat *.jpg | ffmpeg -f image2pipe -r 1 -vcodec mjpeg -i - -vcodec libx264 out.mp4

or for png images
Code: Select all
cat *.png | ffmpeg -f image2pipe -r 1 -vcodec png -i - -vcodec libx264 out.mp4

That will read all the jpg/png images in the current directory and write them, one by one, using the pipe, to the ffmpeg's input, which will produce the video out of it.

Important:
All images in a series need to be of the same size and format.

Explanation:
By telling FFmpeg to set the input file's FPS option (frames per second) to some very low value, we made FFmpeg duplicate frames at the output and thus we achieved to display each image for some time on screen :)

See also:
Tip: Create a thumbnail image every X seconds of the video
burek
 
Posts: 864
Joined: Mon May 09, 2011 10:16 pm
Location: Serbia

Re: Tip: Create a video slideshow from images

Postby zhengwx » Tue Aug 06, 2013 5:59 am

Is it possible to set different duration for each image?
zhengwx
 
Posts: 1
Joined: Tue Aug 06, 2013 5:54 am

Re: Tip: Create a video slideshow from images

Postby llogan » Wed Aug 07, 2013 10:43 pm

zhengwx wrote:Is it possible to set different duration for each image?

Use the concat demuxer.

Make a text file:
Code: Select all
file '/path/to/image_01.png'
Duration 4
file '/path/to/image_02.png'
Duration 1
file '/path/to/image_03.png'
Duration 2


Then run ffmpeg:
Code: Select all
ffmpeg -f concat -i input.txt -pix_fmt uyuv420p output.mp4


Also see:
http://ffmpeg.org/ffmpeg-formats.html#concat
http://trac.ffmpeg.org/wiki/Concatenate
llogan
 
Posts: 2360
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: Tip: Create a video slideshow from images

Postby alifaizan » Tue Aug 20, 2013 5:38 am

I have used the 'cat' select all command and I am getting an error :
Code: Select all
[image2pipe @ 0xa6d0ee0] Could not find codec parameters for stream 0 (Video: png): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
pipe:: could not find codec parameters


and my command is:
Code: Select all
cat /home/phedra/imgs/image/*.png | ffmpeg -f image2pipe -r 1 -vcodec png -i - -vcodec libx264 /home/phedra/imgs/video/out.mp4


Please help to resolve the error
alifaizan
 
Posts: 1
Joined: Tue Aug 20, 2013 5:33 am

Re: Tip: Create a video slideshow from images

Postby llogan » Tue Aug 20, 2013 5:45 pm

When asking for help with command line usage, please show your ffmpeg command line and the complete console output.
Use the [CODE] tags to format the text in a nice way.
llogan
 
Posts: 2360
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: Tip: Create a video slideshow from images

Postby shweta » Tue Feb 04, 2014 11:25 am

while i am creating video from images using ffmpeg, then on server it is making a video of 0 size. Please share if anyone has an idea..
shweta
 
Posts: 2
Joined: Tue Feb 04, 2014 11:12 am

Re: Tip: Create a video slideshow from images

Postby llogan » Tue Feb 04, 2014 7:20 pm

When asking for help with command line usage, please show your ffmpeg command line and the complete console output.
Use the [CODE] tags to format the ffmpeg command line and the complete console output.
llogan
 
Posts: 2360
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: Tip: Create a video slideshow from images

Postby shweta » Wed Feb 05, 2014 5:58 am

I am using
shell_exec("cat $root/app/webroot/img/lightbox/examples/*.jpg | ffmpeg -f image2pipe -s 605x500 -r 3 -vcodec mjpeg -i - -vcodec libx264 -r 3 -pix_fmt yuv420p $root/app/webroot/img/new/out_3.mp4");

video is created but of 0 kb

Please resolve the issue.
shweta
 
Posts: 2
Joined: Tue Feb 04, 2014 11:12 am

Re: Tip: Create a video slideshow from images

Postby llogan » Wed Feb 05, 2014 6:46 am

When asking for help with command line usage, please show your ffmpeg command line and the complete console output.
Use the [CODE] tags to format the ffmpeg command line and the complete console output.
llogan
 
Posts: 2360
Joined: Fri Jan 25, 2013 9:47 pm
Location: Alaska

Re: Tip: Create a video slideshow from images

Postby abbs » Sat Feb 22, 2014 5:12 pm

llogan wrote:
zhengwx wrote:Is it possible to set different duration for each image?

Not easily. You could create a short, temporary intermediate video for each frame

Code: Select all
ffmpeg -r 1/10 -i frame1.png -c:v huffyuv -r 25 output1.mkv
ffmpeg -r 1/5 -i frame2.png -c:v huffyuv -r 25 output2.mkv


Then concatenate each video:

Probably easier to use a video editor for something like that.


Ive used this method with good success - but it is very time consuming - here is what i'm trying to achieve and how I have been able to achieve it but hoping to look for a better solution.

Lets say I have 5 images that I would like to create a video from -

each image will show for a duration of 5 seconds.

there will be 4 transitions going from image 1-2, 2-3, 3-4, 4-5

the transitions will be for 1 second and will use 25 images.

the way I am currently doing this is by creating a video for all 5 images and looping them for 5 seconds. I then create 4 videos for the transitions - I then join the videos together.

now lets say I want to do this with 50 images - the process will take very long.

What I would love to be able to do would be to tell FFmpeg the parameters for each image and build the video.

So for example

Image 1 - loop for 5 secs
Transitions show 25FPS
image2 - loop for 5 secs
Transition show 25FPS

Thanks
abbs
 
Posts: 2
Joined: Sat Feb 22, 2014 4:54 pm

Next

Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron