Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a video from jpeg with avconv => corrupted video

Im trying to make a video (whatever the format) from a directory full of jpeg frames.

I tried with avconv (v0.8), as seen on many topics on the internet, and the libav documentation as well :

avconv -i samples/*.jpeg output.mpeg

It seems to work nicely and create the output.mpeg file.

But the file can't be read by any reader (vlc, banshee, totem,...). No error, but nothing happend when I press Play.

If I check the video file size, it is about 20kB, whereas the original video is 10MB. So we can assume the data has not been stored into the file (it is about 20kB no matter the number of frames given on input)

I made a pastebin of the debug log of the processing. I am not familiar with codec world, so I don't understand many things : http://pastebin.com/9dfxFWZe.

I also try a lot of combinations with -s, -r, -b, -vcodec, -f format, etc.. but the probleme is still there.

Am I doing anything wrong ?

Ask me anything that could help you, I will answer very quickly.

Thank you for your help :)

like image 616
OoDeLally Avatar asked Jul 20 '12 15:07

OoDeLally


3 Answers

I found it better to pipe the jpg file in you want so you can control the selection with standard wildcards, try something like this. This also outputs a video that you can user on the web and mobile (ie. using the standard browser tag):

cat samples/*.jpeg | avconv -r 30 -f image2pipe -codec:v mjpeg -i - -pix_fmt yuvj420p -r 30 -c:v libx264 -vf scale=480:300 -y output.mp4
like image 142
Ben Avatar answered Oct 15 '22 15:10

Ben


avconv expects you to give the input filenames in a printf-like syntax. Simply using shell wildcards (such as samles/*.jpeg) is not enough.

Your samples seem to be named sample/lapinsnipermin/.jpeg, so try the following command line:

avconv -f image2 -i samples/lapinsnipermin/%03d.jpeg output.mpeg

Does this work? You might also want to add options for the bitrate (e.g -r 25).

like image 10
Sjlver Avatar answered Oct 15 '22 14:10

Sjlver


Resurrecting this since it came up when Googling for a solution. I finally got it working using this:

knoppix@Microknoppix:~$ avconv -r 1 -i /tmp/photo%d.jpg -r 24 -s 320x240 -vsync cfr /tmp/video.mpg

I couldn't get avconv to recognize the input files in the original names; this shows why:

knoppix@Microknoppix:~$ strace avconv -i /media/sdb1/DCIM/188_0408/IMGP%04d.JPG /tmp/video.mpg 2>&1 | grep 188_0408
execve("/usr/bin/avconv", ["avconv", "-i", "/media/sdb1/DCIM/188_0408/IMGP%0"..., "/tmp/video.mpg"], [/* 36 vars */]) = 0
stat64("/media/sdb1/DCIM/188_0408/IMGP0000.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0001.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0002.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0003.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
stat64("/media/sdb1/DCIM/188_0408/IMGP0004.JPG", 0xbf925b00) = -1 ENOENT (No such file or directory)
write(2, "/media/sdb1/DCIM/188_0408/IMGP%0"..., 66/media/sdb1/DCIM/188_0408/IMGP%04d.JPG: No such file or directory

I didn't see an option for setting the starting number, so I did this:

i=0; for file in /media/sdb1/DCIM/188_0408/IMGP28*.JPG; do cp $file /tmp/photo$i.jpg; i=$((i+1)); done

The end result is a video of my photos, showing one for each second; the -vsync cfr tells avconv to pad the input frames to match the output framerate.

like image 5
jcomeau_ictx Avatar answered Oct 15 '22 15:10

jcomeau_ictx