Bitcoin Forum
November 14, 2024, 10:54:29 AM *
News: Latest Bitcoin Core release: 28.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [3 BTC] Help me covert some images to a movie  (Read 1140 times)
CatsLikeToStretch (OP)
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile
April 21, 2012, 02:12:16 PM
 #1

I am running Ubuntu 10.04.  I have generated a series of images in pbm format and I want to convert them to a movie file.  I dont particularly care which format as long as it is widely used.  I have 100 files in a directory, named 0.pbm to 99.pbm.  I want to create a video, using these images and at 30 fps, and at as high of quality as possible.  As I understand it, this functionality is available  in the netpbm program, but I am not very familiar with using the terminal and I dont understand what I need to type in the terminal to get this to work.  To get the reward, please explain what I need to type and also a little why - I want to learn a little about using the terminal here as well.  You can check my history and see that I have already paid out on two different bounties like this, so I can assure you I will pay up if you help me.  Thanks in advance.
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
April 21, 2012, 07:12:16 PM
 #2

http://electron.mit.edu/~gsteele/ffmpeg/

tells you quite exactly what to do. Convert the file to jpg and then encode them to a movie.

for f in *pbm ; do convert -quality 100 $f `basename $f pbm`jpg; done

should loop over your files and convert them to jpegs.

You could then try mencoder or ffmpeg to create the movie:

mencoder mf://*.jpg -mf w=800:h=600:fps=30:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

ffmpeg -r 30 -b 1800 -i %02d.jpg output.mp4

The best parameters for the output (resolution, bitrate) depend on your input files obviously (the resolution of the images or how move movement you have in your movie).

h264 might be the best encoder for HD quality these days, so I'd consider it, if you want HD quality.

CatsLikeToStretch (OP)
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile
April 22, 2012, 03:31:14 PM
 #3

Thanks for your reply - I think the answer I am looking for is here - I just am not sure exactly what I need to do.


tells you quite exactly what to do. Convert the file to jpg and then encode them to a movie.

for f in *pbm ; do convert -quality 100 $f `basename $f pbm`jpg; done
should loop over your files and convert them to jpegs.


I'm having trouble with this.  What do I need to type - I really don't understand the terminal much. 



mencoder mf://*.jpg -mf w=800:h=600:fps=30:type=jpg -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi

ffmpeg -r 30 -b 1800 -i %02d.jpg output.mp4

The best parameters for the output (resolution, bitrate) depend on your input files obviously (the resolution of the images or how move movement you have in your movie).


What do any of those parameters mean?  Please explain more. If you post your bitcoin address I will send you 1 BTC for what you have said so far.  Thanks in advance.
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
April 22, 2012, 07:02:15 PM
 #4

Oh cool, that you actually want to pay me something! My address is:

1Q3DhCvgcgMKtQJGQMPZGLZaueWaTps7wh

Ok, back to your questions...

You'll most likely use the bash shell. That shell is not simply a terminal, but it also contains a pretty much complete programming language, so you can write (shell) scripts with it!

The line:

for f in *pbm ; do convert -quality 100 $f `basename $f pbm`jpg; done

is such a (small) script.

The shell expands *pbm to the list of pbm file in your directory, so it evaluates to

0.pbm 1.pbm 2.pbm ...

The 'for' commands lets you loop over this list of filenames, so the variable f becomes one of the filenames in each iteration. During the first loop iteration f is 0.pbm, then it's 1.pbm etc.

The 'do' part simply describes what to do in each loop iteration. So we call a program called 'convert', which is part of the imagemagick package and converts image files. So in the first iteration, we call

convert -quality 100 0.pbm 0.jpg

, because $f simply means 'the value of f' , which is 0.pbm at the time. `<command>` is a construct to run a command and use it's return value. So basename is just a program to
a) remove a path from a filename and
b) remove a suffix from the filename.
So "basename 0.pbm pbm" is just a way to remove the pbm suffix from the filename. Then we add jpg to the filename and 0.pbm becomes 0.jpg.

So this whole line is just a short way to execute
convert -quality 100 0.pbm 0.jpg
convert -quality 100 1.pbm 1.jpg
etc...
So we convert each pbm file with quality 100 (no quality loss) to a jpg file.

So you should have the files
0.jpg 1.jpg 2.jpg ...
in your directory and you could use them as the input of ffmpeg or mencoder to create a movie from them.

PS: if you don't know what a command like 'convert' does, just type 'man convert' and you'll get a manual for this program. Use 'q' to leave the manual.

So, you your jpg files now as the input to ffmpeg:

ffmpeg -r 30 -b 1800 -i *.jpg output.mp4

, which calls ffmpeg with *.jpg (all the images) as the input (the part after -i is the input), a framerate of 30 fps (-r 30 means rate 30), a bitrateof 1800 kbit / second and and outputfile named 'output.mp4'.

The %02d was actually an error by me, since it means '2 digits', but this wouldn't match for your first files 0.pbm, but only for 00.pbm, 01.pbm etc.

Does this help you a bit further?

You could also send me the files, if you want, so I could create the video, but I thought you want to learn bash...

Ciao,
Andreas

CatsLikeToStretch (OP)
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile
April 23, 2012, 03:05:06 AM
 #5

Thank you for your very detailed reply.  I don't have time right now to work on this issue, but I will send you 2.7 of the 3 promised BTC.  In 48 hours I will have time to work on this issue and if I can get it to work I will send you the rest, otherwise I will ask some more questions.   Thanks again! 

I have sent 2.71828 BTC to 1Q3DhCvgcgMKtQJGQMPZGLZaueWaTps7wh

Thanks again!
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
April 23, 2012, 01:26:39 PM
 #6

No problem. Take your time. If you have problem, just reply here or send me a PM.

Thank you!

CatsLikeToStretch (OP)
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile
April 26, 2012, 03:08:01 AM
 #7

Ok - I was able to get it to work, thanks for your help.  This was the first bash scripting I have ever done.  I am pretty capable at scripting in other contexts, just had no idea how it worked from the terminal.  Thanks for your help.  The only part that didnt work was the " *.jpg " part in:

Quote
ffmpeg -r 30 -b 1800 -i *.jpg output.mp4

I had to go back to
Quote
ffmpeg -r 30 -b 1800 -i %03d.jpg output.mp4
but change all my file names to 000.jpg, 001.jpg, etc.  Do you know any way to make it work from 0.jpg to 555.jpg (for instance)?

Also, the quality seems a bit low.  I see in the manual that 200kbps is the default quality, and I notice that if I leave -b 1800 off the file looks the same as when I include it and its also the same file size, so I think some formatting in that line is being done wrong, because we certainly arent getting good quality. 

Thanks for your help, I have sent you an additional 0.314159 BTC and that should complete our transaction, thanks for your help.
CatsLikeToStretch (OP)
Newbie
*
Offline Offline

Activity: 31
Merit: 0


View Profile
April 26, 2012, 03:23:12 AM
 #8

Also, the quality seems a bit low.  I see in the manual that 200kbps is the default quality, and I notice that if I leave -b 1800 off the file looks the same as when I include it and its also the same file size, so I think some formatting in that line is being done wrong, because we certainly arent getting good quality. 

Thanks for your help, I have sent you an additional 0.314159 BTC and that should complete our transaction, thanks for your help.

I found the issue here, the "-b xxx" portion needs to be after the -i portion.  I got it to work.
daybyter
Legendary
*
Offline Offline

Activity: 965
Merit: 1000


View Profile
April 26, 2012, 09:55:59 AM
 #9

Congrats! Knowing the script-fu is always helpful... Smiley

BTW: if you want to edit your video, you might take a look at avidemux2 .

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!