- 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:
- Apriamo il terminale e andiamo nella directory dove è presente il nostro .pdf
- 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
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!
Now, it saved the file in your home folder. Using the terminal type in
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.
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:
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:
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
http://superuser.com/questions/135117/how-to-convert-video-to-images
http://ubuntuforums.org/showthread.php?t=1042249