Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Convert png to video

  1. #1
    Join Date
    Sep 2013
    Beans
    4

    Convert png to video

    Hi guys

    I hope not to replicate existing threads! I have a series of png image files which are named movie001.png, movie002.png and so on. I would like to use these files as frames to create a video. SO far tried the following commands:

    Code:
    ffmpeg -f image2 -r 06 -i *.png output.mp4
    ffmpeg -i *.png -vcodec ffv1 -r 0.0001 test.avi
    


    In both cases I manage to create a video file however the video was too short and so fast that the file got opened and closed immediately. In facts I could not see anything.
    What am I doing wrong? Thanks a lot for your advice !!

  2. #2
    Join Date
    Nov 2008
    Location
    Metro Boston
    Beans
    8,519
    Distro
    Kubuntu 14.04 Trusty Tahr

    Re: Convert png to video

    Shouldn't the -r value be something like 24 to generate a video that displays at 24 frames per second?
    If you ask for help, please have the courtesy to check for responses and thank the people who helped you.

    Blog · Linode System Administration Guides · Android Apps for Ubuntu Users

  3. #3
    Join Date
    Sep 2013
    Beans
    4

    Re: Convert png to video

    Thanks for the reply. I have got 30 frames in total. Therefore I wrote a low value of r in order to have a longer video.
    Any suggestion?

  4. #4
    Join Date
    Apr 2009
    Location
    UK Lake District
    Beans
    2,865
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Convert png to video

    Why not just create a slideshow
    Ubuntu Member Always something different. Promoting Ubuntu and System 76 at TUXPC

  5. #5
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Convert png to video

    Code:
    ffmpeg -f image2 -r 6 -pattern_type glob -i '*.png' output.mp4
    ...should do it. You need to quote the *.png, otherwise the shell expands it into a list of all the png files in the current directory -- you don't want that, you want to pass a literal '*.png' to ffmpeg (which then internally expands that to every .png in the current directory...). You also need to use the '-pattern_type glob' option to make this syntax work, otherwise ffmpeg uses a different pattern-matching syntax.
    Please mark your thread as solved if you get a satisfactory solution to your problem.

  6. #6
    Join Date
    Sep 2013
    Beans
    4

    Re: Convert png to video

    thanks everybody! Evilsoup I tried your command and received the following error message:

    Code:
    ffmpeg version 0.8.6-4:0.8.6-0ubuntu0.12.04.1, Copyright (c) 2000-2013 the Libav developers
      built on Apr  2 2013 17:02:36 with gcc 4.6.3
    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    Unrecognized option 'pattern_type'
    Failed to set value 'glob' for option 'pattern_type'
    Am I doing anything wrong?
    thanks

  7. #7
    Join Date
    Oct 2010
    Location
    London
    Beans
    481
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Convert png to video

    No, I don't think you're doing anything wrong, it's just that ffmpeg (and avconv) is a fast-moving project, and the versions in the repositories are often out-of-date. It seems that the version you have doesn't have the '-pattern_type' option.

    If the files are named after a pattern along the lines of 'img01.png, img02.png ... img30.png', then you should be able to use the following:

    Code:
    ffmpeg -f image2 -r 6 -i 'img%02d.png' output.mp4
    '%02d' here means 'sequential numbers padded with two zeroes' (so 01, 02 ... 30, etc.).
    Please mark your thread as solved if you get a satisfactory solution to your problem.

  8. #8
    Join Date
    Jan 2010
    Location
    Hyperborea
    Beans
    1,395
    Distro
    Ubuntu

    Re: Convert png to video

    Fakeoutdoorsman posted this recently, it also adds sound. It's tailored for upload to Youtube.
    Code:
    ffmpeg -loop 1 -i image.png -i music.mp3 -c:a copy -c:v libx264 -crf 0 -s hd720 -preset veryslow -shortest output.mkv

  9. #9
    Join Date
    Jul 2009
    Location
    CyberspacEastEngland
    Beans
    Hidden!
    Distro
    Ubuntu 13.10 Saucy Salamander

    Re: Convert png to video

    Quote Originally Posted by coldraven View Post
    Fakeoutdoorsman posted this recently, it also adds sound. It's tailored for upload to Youtube.
    Code:
    ffmpeg -loop 1 -i image.png -i music.mp3 -c:a copy -c:v libx264 -crf 0 -s hd720 -preset veryslow -shortest output.mkv


    hmmm that wonderful command for YT coldraven is really for 1 image and a sound file; what the asker wants here is multiple image and no mention of sound or YT
    probably best he uses Esoup's command for this
    Linux is Latin for off-the-beaten-track [◄►] ● Is there Voodoo in the machine?
    ShanArt ● Mark as SolvedXmms

  10. #10
    Join Date
    Sep 2006
    Beans
    3,470

    Re: Convert png to video

    Quote Originally Posted by scamiolo View Post
    In both cases I manage to create a video file however the video was too short and so fast that the file got opened and closed immediately. In facts I could not see anything.
    By default ffmpeg will use an input (and therefore the output too) frame rate of 25 frames per second. As evilsoup shows you can declare an input "-r" and it will use that value instead of the default. For example, if you want the input to be one frame every five seconds you can use a fraction: "-r 1/5". You can also use different values for the input and one for the output. This is useful if you want the output to vary from the input, such as if your video player can only handle "standard" frame rates. ffmpeg will simply duplicate or drop frames to match the difference.

    Code:
    ffmpeg -r 1/5 -i input -vcodec libx264 -pix_fmt yuv420p -r 25 output
    Since your input is PNG, and therefore likely RGB, then "-pix_fmt yuv420p" will ensure your output is compatible with "dumb" players (QuickTime, WMP, etc).

    Quote Originally Posted by scamiolo View Post
    thanks everybody! Evilsoup I tried your command and received the following error message:

    Code:
    *** THIS PROGRAM IS DEPRECATED ***
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    Unrecognized option 'pattern_type'
    Failed to set value 'glob' for option 'pattern_type'
    I think I should clarify that ffmpeg (the original one) and avconv (and the temporary, old, fake, so-called "ffmpeg" in the repo) are tools from two different projects: FFmpeg and libav. The "deprecated" message is misleading for general users. See Who can tell me the difference and relation between ffmpeg, libav, and avconv? and The FFmpeg/Libav situation.

    As for "Unrecognized option 'pattern_type'", either use a non-ancient ffmpeg or use "ffmpeg -i movie%03d.png" instead of a glob pattern. You can follow a step-by-step guide to compile ffmpeg, or simply use a Linux build of ffmpeg that you can download and use.

    Also see:
    Last edited by FakeOutdoorsman; September 10th, 2013 at 06:51 PM.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •