ffmpeg : creating video from image results in just 1 second video

7,525

The -loop option applies to the next input file, so it's probably not parsed in your case. Try this – I left out the other options for the sake of brevity:

ffmpeg -loop 1 -i input.jpg -t 5 output.mp4

A few tips:

  • Your ffmpeg version is already a little outdated. Always try to use a recent build if something fails.

  • -f image2 is superfluous since JPG images are parsed with the image2 demuxer automatically.

  • To achieve real constant bitrate, I believe you need to set all three of -b:v, -minrate and -maxrate to the same value.

  • You typically do not want to use MPEG-1 video (mpeg1video encoder in ffmpeg) these days, especially not for HD content. You'll end up with either huge files, or really bad quality for constrained bitrates. Although you specified a very large bitrate (is that really what you want?), you might be better off at least using MPEG-2 video, or even MPEG-4 Part 12 (AVC, H.264). See the x264 encoding guide for some options.

Share:
7,525

Related videos on Youtube

user1404
Author by

user1404

Updated on September 18, 2022

Comments

  • user1404
    user1404 almost 2 years

    I'm trying to create a short video file out of a single image for 5 seconds on a windows machine using ffmpeg. The video file is to be used to concat in front of video files taken with a camera that produces 1920x1080 60fps. The following creates 1 second stream instead of a 5 second one. Any ideas? thanks advance.

    "c:\program files\ffmpeg\ffmpeg32" -f image2 -i "c:\program files\ffmpeg\imput1.jpg" -loop 1 -vcodec mpeg1video -b:v 104857200 -r 59.94 -s 1920x1080 -aspect 16:9 -t 5 "c:\program files\ffmpeg\banner.MPG"
    

    Here are my output results:

    <pre>c:\Program Files\ffmpeg>"c:\program files\ffmpeg\ffmpeg32" -f
    image2 -i "input1.jpg" -loop 1 -vcodec mpeg1video -b:v 10 4857200 -r
    59.94 -s 1920x1080 -aspect 16:9 -t 5 "c:\program files\ffmpeg\banner. MPG" ffmpeg version N-52045-g694fa00 Copyright (c) 2000-2013 the
    FFmpeg developers built on Apr 12 2013 16:54:51 with gcc 4.8.0 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads
    --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp e --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrn b --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libr tmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheo ra --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-li bvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --ena ble-zlib 
    55. 0.100 libavfilter 3. 53.101 / 3. 53.101 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 3.100 / 52. 3.100 Input #0, image2, from 'c:\program files\ffmpeg\input1.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: N/A Stream #0:0:
    Video: mjpeg, yuvj420p, 722x267 [SAR 1:1 DAR 722:267], 25 tbr, 25 tbn,
    25 tbc File 'c:\program files\ffmpeg\banner.MPG' already exists.
    Overwrite ? [y/N] y VBV buffer size not set, muxing may fail Output
    #0, mpeg, to 'c:\program files\ffmpeg\banner.MPG': Metadata: encoder : Lavf55.2.100 Stream #0:0: Video: mpeg1video, yuv420p, 1920x1080 [SAR
    1:1 DAR 16:9], q=2-3 1, 104857 kb/s, 90k tbn, 59.94 tbc Stream
    mapping: Stream #0:0 -> #0:0 (mjpeg -> mpeg1video) Press [q] to stop,
    [?] for help frame= 1 fps=0.0 q=9.8 Lsize= 130kB time=00:00:00.01
    bitrate=63812.1kbits /s video:130kB audio:0kB subtitle:0 global
    headers:0kB muxing overhead 0.373990%
    
    c:\Program Files\ffmpeg>> libavutil 52. 26.100 / 52. 26.100 libavcodec 55. 2.100 / 55. 2.100
    libavformat 55. 2.100 / 55. 2.100 libavdevice 55. 0.100 /
    </pre>
    

    UPdate: Got the 5 second video to work with the following but the videos won't concat with the newly made one. I guess this probably warrants a new question.

    "c:\program files\ffmpeg\ffmpeg32" -loop 1 -i graphic.jpg -s 1920x1080 -aspect 16:9 -t 5 -c:v libx264 banner.mp4 
    
    • slhck
      slhck over 10 years
      Can you please format your code properly? Don't use blockquote styles, but wrap everything in a <pre> tag or select the log, then press the {} button in the editor, or Ctrl-K.
  • user1404
    user1404 over 10 years
    the mpeg1video and large bitrate setting was taken from the ffprobe reading of my videos files produced from my camera. For simplicity i was trying to match the same attributes the camera was producing with hopes it might concatenate easier. Many thanks for your suggestions. I'll try them in the next hour or so.
  • user1404
    user1404 over 10 years
    I couldn't get the above working but looking into the errors, it seems it doesn't like graphics that aen't irregular sizes. I did get the 5 sec video working with the following; however, when I run the ffmpeg concat, it doesn't attach the video with newly made 5 second video. I'll update the question with the working one above.