VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors.
Please consider supporting us by disabling your ad blocker or buy PlayOn and record Netflix! :)
+ Reply to Thread
Results 1 to 22 of 22
Thread
  1. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Thank you all for leading me to the solution. See below for my solved post.

    I've spent over an hour online trying to get this to work... And it doesn't.
    I've googled it and followed the directions. Nope.
    Windows computer.

    I have 24 images... Named e01.png through e24.png
    I have an MP3 file called audio.mp3

    I want to make an MP4 file slideshow of these images. I've followed the instructions online and it doesn't work.
    Directions are confusing on how to understand the duration per image, as well...
    Need help.

    Code:
    ffmpeg -r 1/5 -i e%02d.png -i audio.mp3 -c:a copy -c:v libx264 -r 30 output.mp4
    I have also tried:

    Code:
    ffmpeg -y -loop 1 -r 0.2 -i e%02d.png -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p output.mp4
    In the past, I've done a single image file and this works:

    Code:
    ffmpeg -loop 1 -i image.png -i audio.mp3 -c:a copy -c:v libx264 -tune stillimage -strict experimental -shortest output.mp4
    ^^ that works fine.

    So, need help on how to understand how to get a slideshow of 'n' number of images, and 5 seconds each, loops if finishes before audio finishes.

    Online didn't help. I tried for an hour following 3 different sites.
    Last edited by Tolwyn; 15th Aug 2017 at 16:46. Reason: Solved
    Quote Quote  
  2. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    The problem online is that not one source indicates the OS they are using. I'm guessing the %02d escape doesn't work in Windows, but no where can I find how this should work as a batch file in Windows.
    Quote Quote  
  3. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Also, obviously, I'm concerned about the -r 1/5 values with the -r and the 0.2 with the -r 0.2. I'm wondering if the forward or backslash is messing me up.

    This doesn't work at all:
    http://www.bogotobogo.com/FFMpeg/ffmpeg_adv_slide_show_from_images_jpeg.php
    Last edited by Tolwyn; 15th Aug 2017 at 17:30.
    Quote Quote  
  4. What doesn't work ? Can you be more specific ? Is there an error message ?

    Add -pix_fmt yuv420p , -shortest , -start_number 1 , loop 1

    Code:
    ffmpeg -loop 1 -r 0.2 -i "e%02d.png" -i audio.mp3 -shortest -start_number 1 -c:v libx264 -pix_fmt yuv420p -r 30 -c:a copy "output.mp4"
    30/0.2 = 150 . At 30FPS that will be 5 seconds because 150/30 =5

    There won't be an easy way to batch it because of different numbering schemes (image sequences usually start at zero) and patterns (different "placeholder" digits)
    Quote Quote  
  5. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by Tolwyn View Post
    The problem online is that not one source indicates the OS they are using. I'm guessing the %02d escape doesn't work in Windows, but no where can I find how this should work as a batch file in Windows.
    You must escape literal percent signs in a batch file by doubling them, even within quotes, thus:
    "e%%02d.png"
    Quote Quote  
  6. Or you can use a list file and concat:

    https://trac.ffmpeg.org/wiki/Slideshow

    Code:
    ffmpeg.exe -f concat -i list.txt -i audio.mp3 -c:a copy -c:v libx264 -r 30 output.mp4
    list.txt:
    Code:
    file 'e00.png'
    duration 5
    file 'e01.png'
    duration 5
    file 'e02.png'
    duration 5
    file 'e03.png'
    duration 5
    file 'e04.png'
    duration 5
    file 'e05.png'
    duration 5
    file 'e06.png'
    duration 5
    file 'e07.png'
    duration 5
    file 'e08.png'
    duration 5
    file 'e09.png'
    duration 5
    file 'e10.png'
    duration 5
    file 'e11.png'
    duration 5
    file 'e12.png'
    duration 5
    file 'e13.png'
    duration 5
    file 'e14.png'
    duration 5
    duration 5
    file 'e15.png'
    duration 5
    file 'e16.png'
    duration 5
    file 'e17.png'
    duration 5
    file 'e18.png'
    duration 5
    file 'e19.png'
    duration 5
    file 'e20.png'
    duration 5
    file 'e21.png'
    duration 5
    file 'e22.png'
    duration 5
    file 'e23.png'
    duration 5
    file 'e23.png'
    That lest you specify different durations for each image.
    Quote Quote  
  7. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Thanks everyone for your responses I really appreciate them. So it looks like it might be the escaping the % which is where I was getting hung up just something simple that I had either forgotten over time or never tried at all.

    So I'll try that first and then if that doesn't work I'll work with Con cat and make a list. But my images I can bulk rename so I have them all named with the same exact syntax.


    Originally Posted by JVRaines View Post
    You must escape literal percent signs in a batch file by doubling them, even within quotes, thus:
    "e%%02d.png"
    Quote Quote  
  8. If your images start at 1 rather than 0 you can use "-start_number 1".

    https://trac.ffmpeg.org/wiki/Slideshow
    Quote Quote  
  9. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    @jagabo, I noticed you concat e023 twice.

    file 'e23.png'
    duration 5
    file 'e23.png'
    Is this a bug in ffmpeg? The reason I ask is, It used to have a bug where it dropped the first frame but that has been fixed but now I notice if the method of batch file OR CLI directly is used, and img001.jpg thru img005.jpg used, img004.jpg is very short duration before switching to img005.jpg. If the last frame is repeated, everything comes out correct. Or is it because of using JPG files?

    Thanks
    Budman1


    UPDATE: Yes I found it noted during online search. Looks like it affects last image or 2 depending which method is used.

    Thanks
    Last edited by Budman1; 12th Aug 2017 at 16:31.
    Quote Quote  
  10. Yes, the wiki link I gave indicated the last frame had to be included twice in the list. I didn't try it with the last name only once.
    Quote Quote  
  11. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Nope. Still doesn't work.
    My files (images) are named e00.png through e24.png.

    Code:
    ffmpeg -r 1/5 -i e%%02.png -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -shortest output.mp4
    e%02.png: No such file or directory
    Quote Quote  
  12. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    When it delivers that msg, it usually means some path is not complete. According to you script, you would need ffmpeg and all your images in the same folder as well as running the cmd window from it as well. Try using complete path for the images folder.
    Quote Quote  
  13. Originally Posted by Tolwyn View Post
    Nope. Still doesn't work.
    My files (images) are named e00.png through e24.png.

    Code:
    ffmpeg -r 1/5 -i e%%02.png -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -shortest output.mp4
    e%02.png: No such file or directory
    You forgot the d , and possibly the path

    "e%02d.png"
    Quote Quote  
  14. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    THANK YOU. Gawd. I forgot the d.

    Hey, is there a location where I can find these escape codes?
    Quote Quote  
  15. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Ok. another question. I have 20 images. The audio source is like 4 minutes. Obviously, 5 seconds/image won't work. What's the switch to get it to loop through?
    Quote Quote  
  16. Originally Posted by Tolwyn View Post
    Ok. another question. I have 20 images. The audio source is like 4 minutes. Obviously, 5 seconds/image won't work. What's the switch to get it to loop through?
    - loop 1 as an input option (has to come before the -i ). see post 4
    Quote Quote  
  17. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    Yeah, I did that and it didn't work:

    Code:
    ffmpeg -loop 1 -r 1/5 -i e%%02d.png -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a copy output.mp4
    Quote Quote  
  18. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    -shortest will terminate at the shortest input. In you case the audio will end with the newly created video at 100 seconds.
    You might also use the -t 00:04:00 option with the -loop

    ffmpeg -loop 1 -r 1/5 -i e%%02d.png -i audio.mp3 -c:v libx264 -r 30 -pix_fmt yuv420p -c:a copy -t 00:04:00 output.mp4
    Last edited by Budman1; 14th Aug 2017 at 23:49.
    Quote Quote  
  19. Originally Posted by Budman1 View Post
    -shortest will terminate at the shortest input. In you case the audio will end with the video at 100 seconds.
    Actually it would end with the audio. Because -loop 1 for time image sequence is longer than 4 minutes, it's basically infinite

    Everything works here, I don't know what's up




    @ Tolywn what does the console output say ? Any error messages ? Are your paths correct ?

    If you're using a batch file file (but not batch processing more than one series), add pause to the end to see the messages

    as a batch file
    Code:
    ffmpeg -loop 1 -r 0.2 -i "e%%02d.png" -i audio.mp3 -shortest -start_number 1 -c:v libx264 -pix_fmt yuv420p -r 30 -c:a copy "output.mp4"
    
    pause
    Quote Quote  
  20. Member
    Join Date
    Aug 2010
    Location
    San Francisco, California
    Search PM
    Originally Posted by Tolwyn View Post
    Hey, is there a location where I can find these escape codes?
    https://ffmpeg.org/ffmpeg-formats.html#image2-1
    Quote Quote  
  21. Member
    Join Date
    Oct 2003
    Location
    United States
    Search Comp PM
    The -loop issue is solved.

    One of the images in my sequence (the last one, of all things)... is rotated 90 degrees. The images are 512x384 (4:3), except the LAST image, which is 3:4 - 384x512. That frame size borked the entire operation. I simply... missed it.
    Quote Quote  
  22. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    @poisondeathray Thanks, I finally understand loop option... I think LOL
    @jagabo Thanks, I understand the problem with the last frames during image to video conversion.
    Quote Quote  



Similar Threads