Create slideshow with ffmpeg from still images

classic Classic list List threaded Threaded
20 messages Options
Reply | Threaded
Open this post in threaded view
|

Create slideshow with ffmpeg from still images

thljcl
Create slide show from still images is not exactly as simple as I originally anticipated. After knowing that ffmpeg is able to convert still images into video of lossless compression using encoders such as x264, I have a basic idea of how to create a slide show from a bunch of still images. In a way, creating slide show is exactly the opposite of creating the illusion of moving pictures. Human eyes perceive motion when the similar images are being displayed in sequence rapidly. For a slide show, however, each image or slide is being displayed for a couple of seconds instead of 1/24 seconds.
Let’s start from the very beginning.
 The basic command to convert a couple of still images to H.264 lossless video is:
ffmpeg -r "24" -i "f_%%1d.png" -vcodec "libx264" -crf "0" "output.mkv"
The input frames are being set to the frame rate of 24 FPS.
f_%%1d.png represents images with the file name starting with f_1.png, f_2.png, f_3.png …
In Windows 8, you select a couple of images with whatever file names, when you rename those files together, they would be renamed to filename (1).png, filename (2).png…
Each frame would be displayed for 1/24 second.
On ffmpeg wiki at http://bit.ly/14YRtSv, there is a guide for creating a video slideshow with ffmpeg. If that guide works perfectly for me, I would not bother to write here.
Say if you want to create a slide show with each slide to be displayed for 5 seconds, one way that would work, though not practical, is to manually duplicate the same image. You would need 120 copies of the same image for the same slide to be displayed for 5 seconds at 24 frame per second.
The problem with the ffmpeg wiki’s guide is that ffmpeg drops frames, especially at the beginning or ending of the videos. Dropping frames causes the dropped slide or changed length. What I want to do is to dictate how ffmpeg duplicate frames automatically as I want.
Here I have 135 images at http://sdrv.ms/11onHnh. Among them, 9 of them have the resolution of 3456 × 1080 pixels; the rest of them have the resolution of 1920 × 1080 pixels. To create a slideshow of 1280 × 720 pixels, I need to resize all of them to have the same resolution.

ffmpeg -r "1" -i "wallpapers\sources\1_%%1d.jpg" -pix_fmt "yuv444p" -vcodec "libx264" -crf "0" "wallpapers\1.mkv"
ffmpeg -r "1" -i "wallpapers\sources\2_%%1d.jpg" -pix_fmt "yuv444p" -vf "scale=1920:600,pad=1920:1080:0:240" -vcodec "libx264" -crf "0" "wallpapers\2.mkv"
ffmpeg -r "1" -i "wallpapers\sources\3_%%1d.jpg" -pix_fmt "yuv444p" -vcodec "libx264" -crf "0" "wallpapers\3.mkv"

I merge the three videos using mkvtoolnix. I extract frames from the combined video.

mkdir "wallpapers\frames"
ffmpeg -i "wallpapers\t.mkv" -vf "scale=1280:720" "wallpapers\frames\f (%%1d).png"

From individual frames, I wrote a batch file to duplicate frames and create a slideshow (H.264 lossless). Each slide is to be displayed for 10 seconds.

cd /d "wallpapers\frames"
copy "f (135).png" "f (136).png"
cd /d "%programfiles%\ffmpeg\bin"
ffmpeg -r "1" -i "wallpapers\frames\f (%%1d).png" -vcodec "libx264" -crf "0" -vf "fps=10" "wallpapers\1.mkv"
cd /d "wallpapers\frames"
del "f (136).png"
cd /d "%programfiles%\ffmpeg\bin"
ffmpeg -r "1" -i "wallpapers\1.mkv" -vf "fps=24" -vcodec "libx264" -crf "0" "wallpapers\2.mkv"
cd /d "wallpapers"
del "1.mkv"
ren "2.mkv" "slideshow.mkv"
cd /d "%programfiles%\ffmpeg\bin"

In duplicating the frames, ffmpeg will ignore the last frame. That’s why I duplicate the last frame. Likewise, I can extract all the frames from the last show. Ffmpeg will duplicate the first frame. Similarly, I delete the first frame. Below is the lines I wrote to extract the frames from the slideshow:

ffmpeg -i "wallpapers\slideshow.mkv" -vf "fps=1" -vcodec "libx264" -crf "0" "wallpapers\1.mkv"
ffmpeg -r "10" -i "wallpapers\1.mkv" -vf "fps=1" -vcodec "libx264" -crf "0" "wallpapers\2.mkv"
cd /d "wallpapers"
del "1.mkv"
ren "2.mkv" "1.mkv"
cd /d "%programfiles%\ffmpeg\bin"
mkdir "wallpapers\frames_1"
ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
cd /d "wallpapers\frames_1"
del "f_1.png"
cd /d "%programfiles%\ffmpeg\bin\wallpapers"
del "1.mkv"
cd /d "%programfiles%\ffmpeg\bin"
ffmpeg -r "1" -i "wallpapers\frames_1\f_%%1d.png" -vcodec "libx264" -crf "0" "wallpapers\1.mkv"
rmdir /s /q "wallpapers\frames_1"
mkdir "wallpapers\frames_1"
ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
cd /d "wallpapers"
del "1.mkv"
cd /d "%programfiles%\ffmpeg\bin"

The slideshow I created is at http://sdrv.ms/15Xa2TU.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Paul B Mahol
Have you some questions?

If you are still not aware this list is not for propagating your
view of world but for user questions.

On 7/28/13, thljcl <[hidden email]> wrote:

> Create slide show from still images is not exactly as simple as I originally
> anticipated. After knowing that ffmpeg is able to convert still images into
> video of lossless compression using encoders such as x264, I have a basic
> idea of how to create a slide show from a bunch of still images. In a way,
> creating slide show is exactly the opposite of creating the illusion of
> moving pictures. Human eyes perceive motion when the similar images are
> being displayed in sequence rapidly. For a slide show, however, each image
> or slide is being displayed for a couple of seconds instead of 1/24 seconds.
> Let's start from the very beginning.
>  The basic command to convert a couple of still images to H.264 lossless
> video is:
> ffmpeg -r "24" -i "f_%%1d.png" -vcodec "libx264" -crf "0" "output.mkv"
> The input frames are being set to the frame rate of 24 FPS.
> f_%%1d.png represents images with the file name starting with f_1.png,
> f_2.png, f_3.png ...
> In Windows 8, you select a couple of images with whatever file names, when
> you rename those files together, they would be renamed to filename (1).png,
> filename (2).png...
> Each frame would be displayed for 1/24 second.
> On ffmpeg wiki at http://bit.ly/14YRtSv, there is a guide for creating a
> video slideshow with ffmpeg. If that guide works perfectly for me, I would
> not bother to write here.

So instead of modifying that wiki, you posted your way how things should
be done here.

> Say if you want to create a slide show with each slide to be displayed for 5
> seconds, one way that would work, though not practical, is to manually
> duplicate the same image. You would need 120 copies of the same image for
> the same slide to be displayed for 5 seconds at 24 frame per second.
> The problem with the ffmpeg wiki's guide is that ffmpeg drops frames,
> especially at the beginning or ending of the videos. Dropping frames causes
> the dropped slide or changed length. What I want to do is to dictate how
> ffmpeg duplicate frames automatically as I want.
> Here I have 135 images at http://sdrv.ms/11onHnh. Among them, 9 of them have
> the resolution of 3456  * 1080 pixels; the rest of them have the resolution
> of 1920  * 1080 pixels. To create a slideshow of 1280  * 720 pixels, I need to
> resize all of them to have the same resolution.
>
> ffmpeg -r "1" -i "wallpapers\sources\1_%%1d.jpg" -pix_fmt "yuv444p" -vcodec
> "libx264" -crf "0" "wallpapers\1.mkv"
> ffmpeg -r "1" -i "wallpapers\sources\2_%%1d.jpg" -pix_fmt "yuv444p" -vf
> "scale=1920:600,pad=1920:1080:0:240" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> ffmpeg -r "1" -i "wallpapers\sources\3_%%1d.jpg" -pix_fmt "yuv444p" -vcodec
> "libx264" -crf "0" "wallpapers\3.mkv"

Using -pix_fmt should only be required if some jpgs are yuv444p but
others are not.
Otherwise you are doing extra conversion for no real benefit.

>
> I merge the three videos using mkvtoolnix. I extract frames from the
> combined video.

If you use mkvtoolnix that is really bad, because this mailing list is not
about mkvtoolnix. So your way is not better in any way.

Above 3 videos could be merged with ffmpeg too, get learn that first
before posting next time.

>
> mkdir "wallpapers\frames"
> ffmpeg -i "wallpapers\t.mkv" -vf "scale=1280:720" "wallpapers\frames\f
> (%%1d).png"
>
> From individual frames, I wrote a batch file to duplicate frames and create
> a slideshow (H.264 lossless). Each slide is to be displayed for 10 seconds.
>
> cd /d "wallpapers\frames"
> copy "f (135).png" "f (136).png"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\frames\f (%%1d).png" -vcodec "libx264" -crf "0"
> -vf "fps=10" "wallpapers\1.mkv"
> cd /d "wallpapers\frames"
> del "f (136).png"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\1.mkv" -vf "fps=24" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> cd /d "wallpapers"
> del "1.mkv"
> ren "2.mkv" "slideshow.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
>
> In duplicating the frames, ffmpeg will ignore the last frame. That's why I
> duplicate the last frame. Likewise, I can extract all the frames from the
> last show. Ffmpeg will duplicate the first frame. Similarly, I delete the
> first frame. Below is the lines I wrote to extract the frames from the
> slideshow:

This sounds like bug, you give extremly good practice: never ever report bug
just find workarounds: slower, complicated, using non-ffmpeg tools are
better ....

>
> ffmpeg -i "wallpapers\slideshow.mkv" -vf "fps=1" -vcodec "libx264" -crf "0"
> "wallpapers\1.mkv"
> ffmpeg -r "10" -i "wallpapers\1.mkv" -vf "fps=1" -vcodec "libx264" -crf "0"
> "wallpapers\2.mkv"
> cd /d "wallpapers"
> del "1.mkv"
> ren "2.mkv" "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
> mkdir "wallpapers\frames_1"
> ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
> cd /d "wallpapers\frames_1"
> del "f_1.png"
> cd /d "%programfiles%\ffmpeg\bin\wallpapers"
> del "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
> ffmpeg -r "1" -i "wallpapers\frames_1\f_%%1d.png" -vcodec "libx264" -crf "0"
> "wallpapers\1.mkv"
> rmdir /s /q "wallpapers\frames_1"
> mkdir "wallpapers\frames_1"
> ffmpeg -i "wallpapers\1.mkv" "wallpapers\frames_1\f_%%1d.png"
> cd /d "wallpapers"
> del "1.mkv"
> cd /d "%programfiles%\ffmpeg\bin"
>
> The slideshow I created is at http://sdrv.ms/15Xa2TU.

In short this is perfect explanation how things should not be done.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
Yes, I’m aware of the fact that ffmpeg can be used to concatenate videos
Physical concatenation protocol.
Allow to read and seek from many resource in sequence as if they were a unique resource.
A URL accepted by this protocol has the syntax:
  concat:URL1|URL2|...|URLN

where URL1, URL2, ..., URLN are the urls of the resource to be concatenated, each one possibly specifying a distinct protocol.
For example to read a sequence of files ‘split1.mpeg’, ‘split2.mpeg’, ‘split3.mpeg’ with ffplay use the command:
  ffplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg

Note that you may need to escape the character "|" which is special for many shells.
But I can make my own choice to use the tools I prefer, can I not?
With regards to reporting bugs to ffmpeg developers, I do not in this case discover a bug, so to speak. If it sounds like a bug to you; suite yourself to report it. I’m sure that you can test it to find the bugs yourself.
Bear in mind, frame rate conversion from one constant frame rate to another always involves adding or dropping frames. As users, we might not know the algorithms behind the video filter “fps”; that’s why I specifically perform a number of tests to find out how it decides which frames it adds or drops. I would consider the frame rate conversion is “flawed” if such a condition is true: the conversion process is not reversible. Well, allows me to elaborate further.
If the original source is of the frame rate of lower frame rate, when its frame rate is to be converted to higher frame rate, it would involve the duplication of frames; of course the question of which frames would be duplicated depends on the algorithms designed by the developers. When the video of higher frame rate with duplicated frames undergoes frame rate conversion so that the output would have the original frame rates, only duplicated frames would be dropped. Even though the length of the videos would change due to frame rate conversion, repeated conversion from one to another and vice versa would not change the video length for a specific frame rate. Of course, if the source of higher frame rate with no duplicated frames undergoes frame rate conversion to achieve lower frame rate, such a process is irreversible, as expected.
Based on my own tests, ffmpeg passes my expectation of how frame rate conversion should be handled. That’s why I do not discover a bug. However, if you find bugs from my experience, feel free to report it and publish it. I have to say that the basic idea behind the duplication of frames to create a slideshow involves a feature in ffmpeg which is frame rate conversion. In effect, we use frame rate conversion algorithms to cause ffmpeg to duplicate frames for us, instead of manually copying frames to create a slideshow.
I’m not absolutely sure that my way of creating a slideshow is particularly good or superior, that’s why I did not attempt to edit the ffmpeg wiki.
No, it’s not meant for propagating my views of world. In fact, similar questions have been asked before at http://bit.ly/13rjKL3 and http://bit.ly/1cgluyH. But while I believe that my experience may be helpful to somebody, it does not directly answer their questions. Speaking of questions the users may ask, it’s indeed a question. It is a question I would ask myself as well as other possibly much more skillful users of ffmpeg. I gave my “workaround”. But in no way I suggested that somehow I gave a perfect answer. If I sound like such, I apologize in advance. Presumably, somebody else may have better answers for what I saw or what I want to achieve. Possibly, my understanding of how ffmpeg works is misguided.
That's why I specifically try to extract all the original non-duplicated frames from the created slideshow, which is successful, I have to say.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Paul B Mahol
On 7/29/13, thljcl <[hidden email]> wrote:

> Yes, I'm aware of the fact that ffmpeg can be used to concatenate videos
> Physical concatenation protocol.
> Allow to read and seek from many resource in sequence as if they were a
> unique resource.
> A URL accepted by this protocol has the syntax:
>   concat:URL1|URL2|...|URLN
>
> where URL1, URL2, ..., URLN are the urls of the resource to be concatenated,
> each one possibly specifying a distinct protocol.
> For example to read a sequence of files `split1.mpeg', `split2.mpeg',
> `split3.mpeg' with ffplay use the command:
>   ffplay concat:split1.mpeg\|split2.mpeg\|split3.mpeg
>
> Note that you may need to escape the character "|" which is special for many
> shells.
> But I can make my own choice to use the tools I prefer, can I not?

Yes, but not telling rest of world your sub-optimal solution.

Also there are better ways to concatenate videos, but it appears you are
aware of only this one.

> With regards to reporting bugs to ffmpeg developers, I do not in this case
> discover a bug, so to speak. If it sounds like a bug to you; suite yourself
> to report it. I'm sure that you can test it to find the bugs yourself.
> Bear in mind, frame rate conversion from one constant frame rate to another
> always involves adding or dropping frames. As users, we might not know the
> algorithms behind the video filter "fps"; that's why I specifically perform
> a number of tests to find out how it decides which frames it adds or drops.
> I would consider the frame rate conversion is "flawed" if such a condition
> is true: the conversion process is not reversible. Well, allows me to
> elaborate further.
> If the original source is of the frame rate of lower frame rate, when its
> frame rate is to be converted to higher frame rate, it would involve the
> duplication of frames; of course the question of which frames would be
> duplicated depends on the algorithms designed by the developers. When the
> video of higher frame rate with duplicated frames undergoes frame rate
> conversion so that the output would have the original frame rates, only
> duplicated frames would be dropped. Even though the length of the videos
> would change due to frame rate conversion, repeated conversion from one to
> another and vice versa would not change the video length for a specific
> frame rate. Of course, if the source of higher frame rate with no duplicated
> frames undergoes frame rate conversion to achieve lower frame rate, such a
> process is irreversible, as expected.
> Based on my own tests, ffmpeg passes my expectation of how frame rate
> conversion should be handled. That's why I do not discover a bug. However,
> if you find bugs from my experience, feel free to report it and publish it.
> I have to say that the basic idea behind the duplication of frames to create
> a slideshow involves a feature in ffmpeg which is frame rate conversion. In
> effect, we use frame rate conversion algorithms to cause ffmpeg to duplicate
> frames for us, instead of manually copying frames to create a slideshow.
> I'm not absolutely sure that my way of creating a slideshow is particularly
> good or superior, that's why I did not attempt to edit the ffmpeg wiki.
> No, it's not meant for propagating my views of world. In fact, similar
> questions have been asked before at http://bit.ly/13rjKL3 and
> http://bit.ly/1cgluyH. But while I believe that my experience may be helpful
> to somebody, it does not directly answer their questions. Speaking of
> questions the users may ask, it's indeed a question. It is a question I
> would ask myself as well as other possibly much more skillful users of
> ffmpeg. I gave my "workaround". But in no way I suggested that somehow I
> gave a perfect answer. If I sound like such, I apologize in advance.
> Presumably, somebody else may have better answers for what I saw or what I
> want to achieve. Possibly, my understanding of how ffmpeg works is
> misguided.
> That's why I specifically try to extract all the original non-duplicated
> frames from the created slideshow, which is successful, I have to say.


Have you read documentation of fps filter?
Did you tried changing its parameters?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Andy Civil
In reply to this post by thljcl
On 2013-07-29 7:59 AM, thljcl wrote:

> ... I believe that my experience may be helpful to somebody  ...

I am interested to read your experiences, and also this thread becomes a
historical record for others who search for answers in the future.

I have previously posted a method to create a slideshow with FFmpeg,
specifically to allow for slides of different lengths (e.g. when doing a
presentation with a voiceover) which is not covered in the Wiki or any other
article that I know. However, my method is 'awkward' and I'm interested to look
at yours to see if I can combine them to get a simpler method which still allows
for different times. (Concatenation was not a possibility when I worked out my
method.)

Thank you for posting.

--
Andy
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
This post was updated on .
I’m sorry. I have not read your previous post. I do not know which method you have tried. Yes, I can create a slideshow with slides of different length. I can even create a sample and share it over SkyDrive with you temporarily before I remove it. What I would like to know is how you create your slideshow with slides of different length. Would you mind to show me the link that leads to your previous post? Or, would you mind to re-write your experience? Your efforts are truly appreciated. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
This post was updated on .
In reply to this post by Andy Civil
Disclaimer: I do not in any way endorse the contents of this slideshow. I’m just demoing how I use ffmpeg to create slideshow with slides of varying length.

The slideshow is at http://sdrv.ms/13rDjUJ

The “job.7z” and “job-2.7z” contain text files, which can be made the batch file I used by changing its filename extension. “job” is used for creating slideshow. “job-2” is used for extracting the frames. From the slides, I created files of “1.mkv, 2.mkv, 3.mkv … 12.mkv”. Then I use mkvtoolnix to merge them together into a single. One thing I like about mkvtoolnix is that it has a GUI front end.
In this slideshow, I makes the first slide lasts for 10 seconds; second slide lasts for 11 seconds; third slide lasts for 12 seconds; fourth slide lasts for 10 seconds; fifth slide lasts for 11 seconds; sixth slide lasts for 12 seconds; seventh slide lasts for 10 seconds; eighth slide lasts for 11 seconds; ninth slide lasts for 12 seconds; tenth slide lasts for 10 seconds; eleventh slide lasts for 11 seconds; twelfth slide lasts for 7 seconds;
I don’t plan to keep this demo for long. As such, I shall remove it after August 7, 2013.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Andy Civil
In reply to this post by thljcl
On 2013-07-30 3:20 AM, thljcl wrote:
> I’m sorry. I have not read your previous post. I do not which method you have
> tried. Yes, I can create a slideshow with slides of different length. I can
> even create a sample and share it over SkyDrive with you temporarily before
> I remove it. What I would like to know is how you create your slideshow with
> slides of different length. Would you mind to show me the link that leads to
> your previous post? Or, would you mind to re-write your experience? Your
> efforts are truly appreciated. Thank you.

I describe it in this post:
<http://ffmpeg-users.933282.n4.nabble.com/Create-video-with-multiple-images-tp2524565p2527808.html>
That post references a google site where I describe what I did (which is a good
thing because it was three years ago and I've forgotten). The links to posts on
that site no longer work, as the archive must have moved. Also, at the bottom of
the google site there is a link that you can download my example - it is a
computer voice reading the question from Francois which I was answering
(including the bad english!). The audio bitrate is only 16k and the video
resolution is small, but the whole file is only 268 KB.

However, I think today your method is probably better. Your example slideshow is
1.1 MB and it has no sound, but the resolution is much bigger and it's also longer.

I have downloaded your examples, I'm too busy to look right now, but I think I
will learn from them. Thank you!

--
Andy
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
If you file size is your concern, you can re-encode it using lossy compression after you’ve done with the editing process. I specifically choose lossless compression and no chroma subsampling to preserve the video quality. It’s playable by VLC, Media Player Classic Home Cinema, or Windows Media Player (with K-Lite Codec Pack Mega).
With regards to compatibility, I know that setting of YUV444P and H.264 High 4:4:4 Predictive Profile (Hi444PP) is not exactly widely compatible with most media players or commercially available media players. It’s meant for keeping the master copy for future editing.
Again, if compatibility is your concern,

ffmpeg -i "input.mkv" -vcodec "libx264" -crf "18" -pix_fmt "yuv420p" "output.mkv"

This is a tradeoff of image quality for compatibility and file size. -crf “18” may be considered a good choice for preserving image quality when it comes to lossy compression. While it’s generally unpredictable to know the average bit rate for a given constant rate factor, I do have a theory behind the algorithms to determine the average bit rate from constant rate factor. If you are interested, I can post it here as well. For myself, I generally choose different constant rate factor value for different videos. You may have wondered why I did not do lossy compression on the slideshows I created.
The short answer is for local computer playback it is simply unnecessary for slideshows.
Slideshows are really different from animation in a number of aspects. First of all, there are many frame duplicates because of the slide of a certain length. In H.264 inter-frame picture prediction lossless compression, we can reduce the file size by reducing the redundancy across the frames. Of course, based on my own tests, H.264 inter-frame picture prediction is not perfect or ideal in any sense, although considered excellent in comparison with other codecs. The low bit rate is due to the repetition of the same image; rather than the reduction of image quality. This is what inter-frame compression does. This is somewhat similar to repeating the same characters in text file and compressing it using 7-zip.
Also, when the bit rate is low, it will take less resources for a CPU to decode it. For live video or animations, however, things are entirely different. While I may still keep the master copy, it’s not used for local playback because of the lack of computing resources to decode it quickly enough during the playback. If I can’t play it even on my PC, why I still keep it? It is master copy, folks. Lossy compression is required for local playback. The bit rate for the lossless version is usually very high. Unless for the purpose of distribution or sharing, I generally don’t do chroma subsampling even if I do lossy compression.
As far as I know, YouTube cannot decode YUV444p correctly. So you still need to re-encode it before you want to upload it to YouTube.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
In reply to this post by Paul B Mahol
Oh yes, with regards to why I specify “yuv444p”, do you happen to know that the chroma subsampling done by different encoders is not necessarily using the same algorithms? In other words, while the main idea behind chroma subsampling is same, each encoder may drop different bits from image during the encoding the process. To be more specific, when we open the image file for viewing or editing, generally the picture viewer or media player would decode the image to bitmap and then present it to us on screen. It’s similar to word document, which is actually a zip file. Each time we open it, Microsoft word would extract it. In fact, you can even change the filename extension of docx to zip if you want. The same applies to Excel, PowerPoint, etc.
Do you realize that it’s generally a bad idea to save the edits directly to jpg even when the source is the picture you take using your camera? The best practice would be to convert it to lossless format such as bmp or PNG. Do your editing there. You can then save it back to jpg when you have done with editing. You make many edits and save them directly to jpg, you will suffer what we call “generation loss”. Lossless editing in jpg file is still possible but only for limited instances, such as “gray scaling”, “rotating and flipping”, “cropping”, and “rescaling”. Generally, if you draw directly from jpg in an image editor and save it to jpg, what you will get is “lossy editing”.
Granted, if the source is encoded to a “color space”, you then use the same encoder to encode the source in the same color space; it’s really not necessarily to choose “yuv444p” in this case. But jpeg and H.264 are two different codecs. Ffmpeg still needs to decode the image before it can re-encode it. Likewise, you can do frame rate conversion using a different set of tools, you cannot expect ffmpeg to recover the original lower frame rate with all the original frames; the algorithms being used might not be the same.
If the source is PNG image, I don’t even want to specify “YUV444p”; it will be chosen automatically if no pixel format is specified.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Andy Civil
In reply to this post by thljcl
On 2013-07-30 12:54 PM, thljcl wrote:
> If you file size is your concern,  ...

My interest was really intellectual/academic; I had seen a tutorial on Java
where the video seemed out of sync with the voiceover, and when I analysed it I
found that the thing had simply been produced with a frame rate of 1 fps. I
thought it should be possible to do this much more efficiently. (I'm a fan of
efficiency, sometimes as an end in itself!)

At first, I thought your method wasn't working well because the photography
slideshow was over 100MB, but the 'relativity' thing you posted was very good,
and I'm convinced that your process is useful.

I think it would be a good way to distribute tutorials (slideshow with
voiceover) especially to places where data rate is an issue. Being able to vary
the slide delay (to make the slide appear at the right point in the narrative)
is the feature that is missing from other "make a slideshow with FFmpeg"
suggestions.

--
Andy
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
Andy, the wallpaper slideshow I created lasts for 22 minutes 30 seconds. It’s much longer than the “relativity” slideshow. You did not download it, did you? Well, I admit that it’s mainly due to my own laziness to specify varying length for different slide. When each slide has the same duration, it requires less efforts. By the way, even though it’s lossless compression, its average bit rate is at 765 kbps. Well, if it’s animation or live recording, I would say that the bit rate would be around 10 Mbps or larger.
Yes, it’s unbelievably large for lossless format. That also shows how much data we lose during lossy compression. Lossy compression is a good choice for distribution, local playback. But we try to do editing, we would try keep as much fidelity as possible.
I do study special relativity quite a lot. But the slides are written by someone else using PowerPoint.  I just ‘borrowed’ it without permission. Well, it’s publicly available anyway. Ha ha… Special Relativity is so complex that I don’t even know where to begin with. There are so much to talk about. It’s not about ‘special relativity’. So I just ‘borrowed’ the material.
Well, for animation or live recording, using CRF value of 18+- can achieve the average bit rate around 3000 Kbps. I usually do the calculation first before I decide which CRF value to be used; sometimes smaller; sometimes larger; it depends on the complexity of the source.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
Well, let me explain why there is a big difference of average bit rate between “Relativity” and “Wallpapers”. I said previously that “Wallpapers” is considerably longer, thus having much larger file size. But you may have argued that there is a big difference in average bit rate as well. The average bit rate of “Relativity” is around 70 kbps; but the average bit rate of “wallpapers” is around 765 kbps. It’s more than ten times larger!
The story to be told here is actually about how lossless compression for image/video works. I actually wrote much about it at my web site at http://bit.ly/17RMRLW and http://bit.ly/18LfN9F. Granted, my web site is not exactly top ten web site in any rank. I’m pretty lazy to update it regularly as well.
That said, I would still tell the theory here, if you are interested. If not, just ignore this post.
The general idea is that “lossless compression” relies on the ability to find redundancy of data. For example, how much will the file size for an image of 1280 × 720 pixels? Is it possible to tell the file size by knowing the resolution? The answer is yes, for uncompressed image file, if we know the other factor that affects the file size, which is bit depth. The bit depth reported by Media Player Classic Home Cinema should be more accurately called ‘bit per channel’. A 24-bit image has three channels; the bit per channel is 8 bit. For an uncompressed image file, the file size can be calculated:
Resolution × bit depth × 1/8
In the case for a 24-bit image file of 1280 × 720 pixels,
1280×720×24×1/8 Bytes = 2,764,800 Bytes ≈ 2.64 MiB
Well, you don’t have to take my words for granted. Just open Microsoft Paint and create a BMP file. The BMP file has contain other information, such as header and so on; the actual file size is actually slightly bigger.
As such a one-minute uncompressed video of 1280 × 720 pixels and 24 FPS would have the file size of 3,981,312,000 Bytes or approximately 3.71 GiB.
By default, when you create a new image file using Microsoft Paint, it only has one color, which is white. Bit depth specify the number of possible colors that a pixel can represent. In an image file, a pixel represent a single color. 24 bit would mean 16,777,216 possible colors. But since a pixel can only represent a color, an image file of 1280 × 720 pixels can at most has 921,600 colors. Human eyes can only discriminate up to 10 million colors; thus 24 bit is more than enough in most cases. If you save that “empty” image file to PNG file, the file size is reduced to only 4.16 KiB. PNG is a lossless file format. That is possible because of the redundancy; meaning that all other pixels sharing the same colors. If your image file has 921,600 colors, no matter which lossless file format you choose, you should get the file size of very close, if not the same.
Of course, as I explained previously, when it comes to lossless encoding of videos, there is also inter-frame compression, meaning that if redundancy of data across the frames is spotted, the encoder can reduce the file size as well. That would explain the great difference of average bit rate between “Wallpapers” and “Relativity”. “Wallpapers” are made from photographs; they do have more colors compared with “Relativity”, which contains more texts (single-color) and single-color background.
In fact, you can create a slideshow video directly from PowerPoint. The downside is that you cannot specify the length of each slide, the compression level, frame rate, or basically every encoding setting. PowerPoint allows us to save the slides to PNG files, which I used to create the slideshow using ffmpeg.
Also, I don’t keep PNG files. I can always extract them from lossless H.264 video file when I need them for editing. The reason is to save storage space.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

James Linder
In reply to this post by thljcl

On 30/07/2013, at 7:13 PM, thljcl wrote:

> Disclaimer: I do not in any way endorse the contents of this slideshow. I’m
> just demoing how I use ffmpeg to create slideshow with slides of varying
> length.http://sdrv.ms/13rDjUJThe “job.7z” and “job-2.7z” contain text files,
> which can be made the batch file I used by changing its filename extension.
> “job” is used for creating slideshow. “job-2” is used for extracting the
> frames. From the slides, I created files of “1.mkv, 2.mkv, 3.mkv … 12.mkv”.
> Then I use mkvtoolnix to merge them together into a single. One thing I like
> about mkvtoolnix is that it has a GUI front end.In this slideshow, I makes
> the first slide lasts for 10 seconds; second slide lasts for 11 seconds;
> third slide lasts for 12 seconds; fourth slide lasts for 10 seconds; fifth
> slide lasts for 11 seconds; sixth slide lasts for 12 seconds; seventh slide
> lasts for 10 seconds; eighth slide lasts for 11 seconds; ninth slide lasts
> for 12 seconds; tenth slide lasts for 10 seconds; eleventh slide lasts for
> 11 seconds; twelfth slide lasts for 12 seconds;I don’t plan to keep this
> demo for long. As such, I shall remove it after August 7, 2013.

dvdslideshow is your friend

James
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
Is this tool from http://bit.ly/159uJ2e what you are referring to? Thanks for telling a commercially available tool that costs USD 50. By the way I also have another free tool that is called “Movie Maker”, which is free for Windows users. I think that you have missed the point why I learned to use ffmpeg; it’s not merely for academic reasons, although that is a big part of it.
As I previously mentioned, I can do a lot of customizations when it comes to encoding settings, such as frame rate, quality preservation (Hey, I can do lossless encoding), file size control, and so on. Ffmpeg is free to use but it’s not exactly the most user-friendly tool as a command-line tool. But it’s certainly very powerful. At the end, it’s up to the users to choose whether or not they only need simple tools for simple job; or they need something more advanced, but more difficult to be used.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

Andy Civil
On 2013-07-31 12:20 AM, thljcl wrote:
> Is this tool from http://bit.ly/159uJ2e what you are referring to?

I very much doubt it; I think James was trying to impress us with a 'short'
answer, and wasn't specific enough with his recommendation!

I'm guessing that the one he was referring to is this one:
http://dvd-slideshow.sourceforge.net/wiki/Main_Page

It is indeed free, and looks interesting. It's also Linux only; I can't complain
about that because I approve of trying to migrate to Linux - but to be honest
all my photos and stuff are on a Windows computer so I'd prefer a windows tool,
at least for now.

Also, I note that the dvd-slideshow can do things like the Ken Burns effect.
This is very nice for presentation, but obviously kills any idea of saving data
by having a whole string of "repeat last image" tokens (or whatever you call them).

The bottom line is, I'm interested in your method - I just have to update my 7z
so that I can uncompress your job files - LOL - but honestly, most people will
be less infatuated with data rate efficiency, and will enjoy that dvd-slideshow
program.

P.S. I don't know why you use bit.ly so much, it's OK but I prefer to know where
I'm going... I discovered that you can PREVIEW a bit.ly link by adding a simple
"+" sign at the end; I'm sharing this gem for others' interest.

--
Andy
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
Thanks for clarifying. Linux tool? Eh? It does not matter. Based on what I saw from the documentation you show me on http://dvd-slideshow.sourceforge.net/wiki/Main_Page, it does not seem to offer what I can do with ffmpeg. Well, as you said, it probably did not matter for average users. They won’t be so picky about encoders’ settings as long as they got something done. Lossless encoding? That probably never crossed the mind for average users.
Hm… On the other hand, I seriously doubt the big producers would forget to have multiple backup of master copies. In the old days, that would mean film master, i.e. the actual film stocks. In digital age, that of course means the copies without any lossy compression. After all, they would like to continue to make money from their cash cows.
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

James Linder
In reply to this post by thljcl

On 31/07/2013, at 12:20 PM, thljcl wrote:

> Is this tool from http://bit.ly/159uJ2e what you are referring to? Thanks for
> telling a commercially available tool that costs USD 50. By the way I also
> have another free tool that is called “Movie Maker”, which is free for
> Windows users. I think that you have missed the point why I learned to use
> ffmpeg; it’s not merely for academic reasons, although that is a big part of
> it.
> As I previously mentioned, I can do a lot of customizations when it comes to
> encoding settings, such as frame rate, quality preservation (Hey, I can do
> lossless encoding), file size control, and so on. Ffmpeg is free to use but
> it’s not exactly the most user-friendly tool as a command-line tool. But
> it’s certainly very powerful. At the end, it’s up to the users to choose
> whether or not they only need simple tools for simple job; or they need
> something more advanced, but more difficult to be used.

Sorry I thought it would be trivial to find
http://dvd-slideshow.sourceforge.net/wiki/Main_Page

It uses ffmpeg to do the heavy lifting
It is very easy to use
It is command line stuff so you may tweek as you see fit
The result is pleasing

James
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

James Linder
In reply to this post by Andy Civil

On 31/07/2013, at 1:06 PM, Andy Civil wrote:

> On 2013-07-31 12:20 AM, thljcl wrote:
>> Is this tool from http://bit.ly/159uJ2e what you are referring to?
>
> I very much doubt it; I think James was trying to impress us with a 'short' answer, and wasn't specific enough with his recommendation!
>
> I'm guessing that the one he was referring to is this one:
> http://dvd-slideshow.sourceforge.net/wiki/Main_Page
>
> It is indeed free, and looks interesting. It's also Linux only; I can't complain about that because I approve of trying to migrate to Linux - but to be honest all my photos and stuff are on a Windows computer so I'd prefer a windows tool, at least for now.
>
> Also, I note that the dvd-slideshow can do things like the Ken Burns effect. This is very nice for presentation, but obviously kills any idea of saving data by having a whole string of "repeat last image" tokens (or whatever you call them).
>
> The bottom line is, I'm interested in your method - I just have to update my 7z so that I can uncompress your job files - LOL - but honestly, most people will be less infatuated with data rate efficiency, and will enjoy that dvd-slideshow program.
>
> P.S. I don't know why you use bit.ly so much, it's OK but I prefer to know where I'm going... I discovered that you can PREVIEW a bit.ly link by adding a simple "+" sign at the end; I'm sharing this gem for others' interest.

Indeed it is (the source forge link)
My wife uses it unchanged on her mac. I venture to suggest that one could run it on winders too.
Since it is command line ffmpeg you may tweek as you see fit, what I was saying is this is a very nice *outta box" solution to a generic problem/need.
James
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: Create slideshow with ffmpeg from still images

thljcl
In reply to this post by James Linder
Does it currently support H.264 lossless or FFV1 encoding process?