4
1
I'm attempting to take a set of images taken at 1-second intervals to form a timelapse video. I figured this would be easy with ffmpeg, but i'm running into cryptic errors.
All the images are yuv420 jpegs, taken from an android camera. They're saved as individual jpegs in a folder, they're all identically sized and formatted. They are named as a sequence of 7-digit names, starting at zero (so "0000000.jpg" to "0001000.jpg", as an example).
This is my string (folder names redacted for clarity):
avconv -r 1 -f image2 -i %07d.jpg -vcodec libx264 -crf 18 -preset slower video.mp4
Seems great, i see plenty of posts from people who say that works for them.
However ffmpeg gives me this (bold indicates error)
ffmpeg version 0.8.5-6:0.8.5-1, Copyright (c) 2000-2012 the Libav developers built on Jan 13 2013 12:05:48 with gcc 4.7.2 *** THIS PROGRAM IS DEPRECATED *** This program is only provided for compatibility and will be removed in a future release. Please use avconv instead. [mjpeg @ 0x233aea0] overread 8 Input #0, image2, from '%07d.jpg': Duration: 00:00:00.04, start: 0.000000, bitrate: N/A Stream #0.0: Video: mjpeg, yuvj420p, 640x480 [PAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc File 'video.mp4' already exists. Overwrite ? [y/N] y [buffer @ 0x233b340] w:640 h:480 pixfmt:yuvj420p [libx264 @ 0x2339fa0] using SAR=1/1 [libx264 @ 0x2339fa0] using cpu capabilities: MMX2 SSE2Fast FastShuffle SSEMisalign LZCNT [libx264 @ 0x2339fa0] profile Main, level 3.1 [libx264 @ 0x2339fa0] 264 - core 123 r2189 35cf912 - H.264/MPEG-4 AVC codec - Copyleft 2003-2012 - http://www.videolan.org/x264.html - options: cabac=1 ref=8 deblock=1:0:0 analyse=0x1:0x131 me=umh subme=9 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=2 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=2 b_bias=0 direct=3 weightb=0 open_gop=1 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=60 rc=crf mbtree=1 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.25 aq=1:1.00 Output #0, mp4, to 'video.mp4': Metadata: encoder : Lavf53.21.1 Stream #0.0: Video: libx264, yuvj420p, 640x480 [PAR 1:1 DAR 4:3], q=-1--1, 25 tbn, 25 tbc Stream mapping: Stream #0.0 -> #0.0 Press ctrl-c to stop encoding [mjpeg @ 0x233aea0] overread 8 frame= 0 fps= 0 q=0.0 Lsize= 0kB time=10000000000.00 bitrate= 0.0kbits/s video:0kB audio:0kB global headers:0kB muxing overhead 610.000000%
The import lines (which show up in red) are the ones that say "[mjpeg @ 0x233aea0] overread 8".
This makes me think that perhaps it's trying to read the images as motion jpegs instead of plain jpeg files, and is failing somehow. I've tried with/without "-f image2", with the same result. And i've also tried using avconv, with the same result.
I should note that the images are valid, and if i convert them all to *.png (a costly and time-consuming process) the whole thing works. But i'd prefer to just be able to use the jpegs, without an intermediate conversion. After all, that's what ffmpeg is for, transcoding.
Does anyone have a good way to convert *.jpg to video using ffmpeg?
First of all thank you for posting the complete output. You're not using FFmpeg, really—you're using a "crippled" and outdated version called
– slhck – 2013-03-02T21:37:14.280ffmpeg
from Libav (an FFmpeg fork) that was shipped with Ubuntu. Instead of that, please use a recent static build from their downloads page, or compile it yourself, then try again. Could very well be a bug that was long fixed. Note that MJPEG is fine as decoder.By the way: The "overread" error stems from the MJPEG decoder finding too many bits after reading the image block by block. Could also be that the images aren't properly formatted. Could you maybe try re-saving the JPG files, e.g. with ImageMagick's
convert <input> <output>
? – slhck – 2013-03-02T21:41:08.197Thanks for the tip about libav vs ffmpeg! I've run a subsonic server off the same box, and always had odd troubles with properly transcoding some files. After cleaning off avconv/libav/ffmpeg, and reinstalling the official version, all that is gone. However, the error still remains. Is it possible that the images are formatted incorrectly, if they display fine with browsers/image editors? I'm installing imagemagick as we speak to test further – Knetic – 2013-03-02T21:53:23.647
Given that I've never had problems such as this I can only imagine it's the images themselves being the culprit. If you want you could give us the link to one or two images to test (unaltered, i.e. uploaded in an archive)? – slhck – 2013-03-02T21:55:55.517
That was it! After mogrify'ing the jpegs and getting the proper ffmpeg, the frames are transcoded to video just like they should be. I think you must have been right about the images being weirdly encoded, because there is a little grey bar at the bottom right of every image, which i assume must be leftover from some improper encoding. If you like, you can post what you said to an answer, and i'll accept it. – Knetic – 2013-03-02T22:24:32.550
I'm glad I could help you. Answer posted – and welcome to Super User! :) – slhck – 2013-03-02T22:31:39.163