conversioni documenti

  • da video a immagini

Per fortuna ci da una mano il pacchetto imagemagick. Si installa facilmente da gestore di pacchetti (synaptic) oppure da terminale con sudo apt-get install imagemagick. Uno volta installato basta aprire un terminale, spostarsi nella cartella dove si ha il pdf e dare il seguente comando: convert miofile.pdf miofileoutput.jpg ed un attimo si avrà convertite tutte le pagine in relative immagini jpg. Siccome per ogni pagina corrisponde un immagine, conviene creare una cartella ad hoc per il salvataggio ed evitare la saturazione della cartella corrente (in generale “Documenti”).

  • da pdf a immagine

Vediamo come convertire agevolmente un file pdf in jpg con Ubuntu:
Ubuntu ha di default il pacchetto imagemagick preinstallato, ci servirà per poter convertire il nostro pdf:

  1. Apriamo il terminale e andiamo nella directory dove è presente il nostro .pdf
  2. Diamo il comando:
    convert -density 300 nomefile.pdf nomefilechevogliamo.jpg

Il valore 300 dopo -density indica i DPI che vogliamo per la nostra immagine, se non lo specifichiamo il valore di default è 72;
Nel caso il pdf sia di più pagine il comando convertirà tutte le pagine salvandole con nomefile-1.jpg, nomefile-2.jpg, ecc..

 

Convert PDF to JPG

We’ll use imagemagick to make this, and it is fairly easy, just enter this command.

convert file.pdf file.jpg 

And all is done, if your PDF file has a lot of pages, you will find a file-0.jpg file-1.jpg file-2.jpg and file-n.jpg, being n the number of pages your PDF file had.

Convert PDF to PNG

In this case, just change the extension in the command.

convert file.pdf file.png 

The consideration about the number of pages in the PDF file is the same as with JPG.

Conclusion

As you can see it is really easy to convert a PDF file to JPG or PNG, you just need to install imagemagick, imagemagick is also useful to take screenshots, and lots of other things.

ALTRO

19 ffmpeg commands for all needs

Published on September 22nd, 2008 by Jean-Baptiste Jung. 149 Comments

ffmpeg is a multiplatform, open-source library for video and audio files. I have compiled 19 useful and amazing commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.

 

Getting infos from a video file
ffmpeg -i video.avi
Turn X images to a video sequence
ffmpeg -f image2 -i image%d.jpg video.mpg

This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named video.mpg.

Turn a video to X images
ffmpeg -i video.mpg image%d.jpg

This command will generate the files named image1.jpg, image2.jpg, …

The following image formats are also availables : PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.

Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 128kb/s
  • Video codec : mpeg4
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Encode video for the PSP
ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4

Explanations :

  • Source : source_video.avi
  • Audio codec : aac
  • Audio bitrate : 32kb/s
  • Video codec : xvid
  • Video bitrate : 1200kb/s
  • Video size : 320px par 180px
  • Generated video : final_video.mp4
Extracting sound from a video, and save it as Mp3
ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 sound.mp3

Explanations :

  • Source video : source_video.avi
  • Audio bitrate : 192kb/s
  • output format : mp3
  • Generated sound : sound.mp3
Convert a wav file to Mp3
ffmpeg -i son_origine.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3
Convert .avi video to .mpg
ffmpeg -i video_origine.avi video_finale.mpg
Convert .mpg to .avi
ffmpeg -i video_origine.mpg video_finale.avi
Convert .avi to animated gif(uncompressed)
ffmpeg -i video_origine.avi gif_anime.gif
Mix a video with a sound file
ffmpeg -i son.wav -i video_origine.avi video_finale.mpg
Convert .avi to .flv
ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv
Convert .avi to dv
ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv

Or:

ffmpeg -i video_origine.avi -target pal-dv video_finale.dv
Convert .avi to mpeg for dvd players
ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg

Explanations :

  • target pal-dvd : Output format
  • ps 2000000000 maximum size for the output file, in bits (here, 2 Gb)
  • aspect 16:9 : Widescreen
Compress .avi to divx
ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi
Compress Ogg Theora to Mpeg dvd
ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_terminée.mpg
Compress .avi to SVCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg
Compress .avi to VCD mpeg2

NTSC format:

ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg

PAL format:

ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg
Multi-pass encoding with ffmpeg
ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2
 >>>>

time lapse: convert single jpg images to a movie

Posted on July 23, 2008

since they’re tearing down the buildings in front of our office and there’s been a cool webcam positioned near the site i wrote a little script to get the images and wanted to convert them into a time-lapse…

here’s the knowledge i gained from this little experiment.

first i thought that image magick could do the trick, i noticed that to create a mpeg2 video i needed a little encode program that i found here.
compiled this and moved it to /usr/bin

then i executed convert in my image directory

convert -delay 10 *.jpg m2v:time_lapse-test.mpg

the output was a nice little motion jpeg which i couldn’t use in my little video software called open movie editor (there’s probably better stuff out there but this is the first one i found and tried and seemed simple)

so i tried the ffmpeg approach

ffmpeg -r 5 -i %12d.jpg -y -an time_lapse-test.mpg

which i didn’t get working at all since the regex type image path just didn’t seem to find any images… so i gave up quite quickly.

so the next try was mencoder (should’ve tried this to begin with since mplayer/mencoder can just about do anything)

mencoder -ovc lavc -mf fps=3:type=jpg 'mf://*.jpg' -o time_lapse-test.avi

the result was a bad quality video… so i started using some params to get this sorted out

using this as help i tried “-ovc copy”, which was great and gave me a 1 to 1 copy of the jpegs

mencoder -ovc copy -mf w=800:h=371:fps=6:type=jpg 'mf://*.jpg' -o time_lapse-test.avi

great!! … i’m back at the mjpg which i can’t use in open movie editor!

so let’s encode it into some other video codec… i installed x264 and tried:

mencoder mf://*.jpg -mf w=800:h=371:fps=15:type=jpg -ovc x264 -x264encopts subq=5:8x8dct:frameref=2:bframes=3:b_pyramid:weight_b:qp_constant=26 -o time_lapse-test.avi

and i just didn’t get it to work without having to compile things… so i gave up once more 😉

some more research and after testing a few different bitrates, this is what gave me good results:

mencoder -nosound mf://*.jpg -mf w=800:h=371:type=jpg:fps=15 -ovc lavc -lavcopts vcodec=mpeg4:vbitrate=2160000:mbd=2:keyint=132:v4mv:vqmin=3:lumi_mask=0.07:dark_mask=0.2:mpeg_quant:scplx_mask=0.1:tcplx_mask=0.1:naq -o time_lapse-test.avi

the important things here is setting the frames per second to 15 and the codec to mpeg4 with a bitrate of 2160000. everything else was gathered on different sites and really almost make no difference (in what you see at least)

so then i quickly edited movie… and saved it, it was way too big so encoded it again but this time with 2 passes and a smaller bitrate:

mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=1:vbitrate=1620000:mbd=2:keyint=132:v4mv:vqmin=3:vlelim=-4:vcelim=7:lumi_mask=0.07:dark_mask=0.10:naq:vqcomp=0.7:vqblur=0.2:mpeg_quant -mf type=sgi:fps=25 -nosound -o /dev/null time_lapse-test.avi

to generate the divx2pass.log then in the second pass i also added the mp3 music:

mencoder -ovc lavc -lavcopts vcodec=mpeg4:vpass=2:vbitrate=1620000:mbd=2:keyint=132:v4mv:vqmin=3:vlelim=-4:vcelim=7:lumi_mask=0.07:dark_mask=0.10:naq:vqcomp=0.7:vqblur=0.2:mpeg_quant -mf type=sgi:fps=25  -audiofile "/home/me/music.mp3" -oac copy -o time-lapse_216k_mp3.avi time_lapse-test.avi

and there you have the final movie!

delete divx2pass.log and upload to youtube 🙂

oh yeah… and added some meta tags

ffmpeg -title "destruction time-lapse" -author "munzli" -comment "www.munz.li" -acodec copy -vcodec copy -i time-lapse_162k_mp3.avi time-lapse_162k_mp3_meta.avi

and here you have it (needs to be high quality because compressed it looks even worse)

[edit]
well youtube blocked my video saying that a copyright owner has claimed it owns some or all of the audio content in my video. oh well the music industry is just something you shouldn’t support! just don’t understand why you can’t have a little video online that even mentions the music at the end and might even bring a song to a wider audience!

i encourage everybody to use riaaradar before purchasing their next album!

^^^^^^^

Short version:

ffmpeg -itsoffset -4 -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg 

This command generates a 320×240 sized PNG thumbnail at the 4th second in the video. Put this in a script that changes the time and file name and you’re done .

Long version: http://blog.prashanthellina.com/2008/03/29/creating-video-thumbnails-using-ffmpeg/

answered Apr 27 ’10 at 11:41
Nifle
15.2k22256
This seems to do what I want, but with one problem. It will process the file from the start on each iteration, getting exponentially slow. – Liam Apr 27 ’10 at 14:42
@Liam – Does it help if you leave the offset time alone (set it at 1) and use the -ss position flag to seek further into the file instead? -ss Seek to given time position in seconds. hh:mm:ss[.xxx] syntax is also supported – Nifle Apr 29 ’10 at 7:53
@liam: put the -ss before the -i so that the seek happens before the input video gets decoded. this should speed it up. source – quack quixote Apr 29 ’10 at 17:03
feedback

If

$ mplayer -vo help | grep JPEG 

finds something, you can use it to dump the video into a sequence of jpg files.

answered Apr 27 ’10 at 10:53
geek
1,379610
feedback

up vote 1 down vote accepted
mplayer -vo jpeg -sstep 5 file.avi 

will save a frame as a jpeg file every 5 seconds.

However, it will not stop at the end of the file, it will continue producing copies of the last frame. To avoid this, find the duration of the video in seconds (using another player) and subtract 2, and use this value for the -endposoption. For example, for a 147 second video:

mplayer -vo jpeg -sstep 5 -endpos 145 file.avi 
answered Apr 28 ’10 at 10:08
Liam
271310
this sounds like an mplayer bug. nice workaround. – quack quixote Apr 29 ’10 at 17:04
feedback

You can skip frames in VirtualDub. Just use “Decimate By” option located at Video -> Frame Rate menu. For example if you set “Decimate By 100” then use File -> Export -> Image sequence, it will save only every 100th frame.

answered Nov 30 ’11 at 22:06
Alex
111
feedback

Media Player Classic (MPC) can do this, too.

answered Apr 27 ’10 at 10:50
Martin
1,716414
feedback

You could also try this

from the VLC command line…

vlc “C:\YOUR\file\path\file.avi” -V image –image-out-prefix=capname –image-out-ratio=60

file.avi is the video you want to capture from, capname is the prefix of the saved images, you might want to play around with the ratio (60 means that 1 out of 60 images is captured) You can add more commands, for example –image-out-format jpeg will save your caps as jpegs instead of of pngs, –snapshot-path lets you choose where to save your caps.

Source of above

Now, it saved the file in your home folder. Using the terminal type in

Code:
ffmpeg -i Video.mpg Pictures%d.jpg

You can probably change the JPG to PNG. If it doesn’t work using PNG, then use JPG. Just fire up GIMP and save the JPGs as PNGs.

I have a video recorded from my camera (encoded in mp4) and I want to convert it into a series of png images that I need to process separately.

MPlayer has a png output that should do what you are after. You can see if your version of MPlayer has this capability as follows:

Code:
andrew@skamandros~$ mplayer -vo help | grep png
	png	PNG file

Just be a little careful to put some time limits in place or your disk will fill vey quickly:

Code:
mplayer inputfile -vo png:z=8 -endpos 5 -ao null

This command stops after 5 seconds of playback but still generated an impressive number of images . To start a little way into your video use the -ss option.

All the best,

Andrew

 

Avidemux (GTK+) has this if you want something that has a GUI.

  • fonte

http://iglu.cc.uniud.it/?p=202

http://adf.ly/1526574/banner/http://skazzo.blogspot.it/2010/03/convertire-pdf-in-jpg-con-ubuntu.html

http://www.catswhocode.com/blog/19-ffmpeg-commands-for-all-needs

time lapse: convert single jpg images to a movie

http://superuser.com/questions/135117/how-to-convert-video-to-images

http://ubuntuforums.org/showthread.php?t=1042249

 

Lascia un commento