(Update) Ruotare video di 90-180-270 gradi con FFmpeg

 

Aggiornamento al post fatto qualche tempo fa, su come riuscire a ruotare un video di 90-180-270 gradi, usando FFmpeg. Nell'esempio precedente si usava il filtro rotate, che adesso non c'è più, ed al suo posto c'è transpose:

 

Filters:
aconvert         Convert the input audio to sample_fmt:channel_layout:packed_fmt.
aformat          Convert the input audio to one of the specified formats.
anull            Pass the source unchanged to the output.
aresample        Resample audio data.
ashowinfo        Show textual information for each audio frame.
earwax           Widen the stereo image.
pan              Remix channels with coefficients (panning)
volume           Change input volume.
abuffer          Buffer audio frames, and make them accessible to the filterchain.
aevalsrc         Generate an audio signal generated by an expression.
amovie           Read audio from a movie source.
anullsrc         Null audio source, return empty audio frames.
abuffersink      Buffer audio frames, and make them available to the end of the filter graph.
anullsink        Do absolutely nothing with the input audio.
blackframe       Detect frames that are (almost) black.
boxblur          Blur the input.
copy             Copy the input video unchanged to the output.
crop             Crop the input video to width:height:x:y.
cropdetect       Auto-detect crop size.
delogo           Remove logo from input video.
deshake          Stabilize shaky video.
drawbox          Draw a colored box on the input video.
drawtext         Draw text on top of video frames using libfreetype library.
fade             Fade in/out input video
fieldorder       Set the field order.
fifo             Buffer input images and send them when they are requested.
format           Convert the input video to one of the specified pixel formats.
frei0r           Apply a frei0r effect.
gradfun          Debands video quickly using gradients.
hflip            Horizontally flip the input video.
hqdn3d           Apply a High Quality 3D Denoiser.
lut              Compute and apply a lookup table to the RGB/YUV input video.
lutrgb           Compute and apply a lookup table to the RGB input video.
lutyuv           Compute and apply a lookup table to the YUV input video.
mp               libmpcodecs wrapper.
negate           Negate input video.
noformat         Force libavfilter not to use any of the specified pixel formats for the input to the next filter.
null             Pass the source unchanged to the output.
overlay          Overlay a video source on top of the input.
pad              Pad input image to width:height[:x:y[:color]] (default x and y: 0, default color: black).
pixdesctest      Test pixel format definitions.
scale            Scale the input video to width:height size and/or convert the image format.
select           Select frames to pass in output.
setdar           Set the frame display aspect ratio.
setpts           Set PTS for the output video frame.
setsar           Set the pixel sample aspect ratio.
settb            Set timebase for the output link.
showinfo         Show textual information for each video frame.
slicify          Pass the images of input video on to next video filter as multiple slices.
split            Pass on the input to two outputs.
transpose        Transpose input video.
unsharp          Sharpen or blur the input video.
vflip            Flip the input video vertically.
yadif            Deinterlace the input image
buffer           Buffer video frames, and make them accessible to the filterchain.
color            Provide an uniformly colored input, syntax is: [color[:size[:rate]]]
frei0r_src       Generate a frei0r source.
mandelbrot       Mandelbrot fractal renderer
movie            Read from a movie source.
mptestsrc        Generate various test pattern.
nullsrc          Null video source, return unprocessed video frames.
rgbtestsrc       Generate RGB test pattern.
testsrc          Generate test pattern.
buffersink       Buffer video frames, and make them available to the end of the filter graph.
nullsink         Do absolutely nothing with the input video.
 

 

Ruotare video a sinistra:

 

$ ffmpeg -i input.avi -vf "transpose=2" -sameq -y output.avi

 

Ruotare video verso destra:



$ ffmpeg -i input.avi -vf "transpose=3" -sameq -y output.avi

 

Ruotare sotto sopra:

 

$ ffmpeg -i input.avi -vf vflip -y output.avi

 

oppure:

 

$ avconv -i input.avi -vf "vflip" output.avi

 

enjoy 😉

(FFmpeg) Screencast seguendo solo il mouse

 

 

Modi per fare Screencast con FFmpeg, ce ne sono molti, e si possono trovare nella categoria dedicata a FFmpeg. Questo è diverso dal solito, in quanto, lo screencast viene fatto nella zona del mouse, con un'ampiezza che noi possiamo chiaramente indicare. Di seguito 2 comandi, il primo si riferisce al video sopra, il secondo invece crea una specie di box visivo intorno al mouse.

 

$ ffmpeg -f x11grab -follow_mouse 100 -r 25 -s vga -i :0.0 output.mpg

$ ffmpeg -f x11grab -follow_mouse centered -show_region 1 -r 25 -s vga -i :0.0 output.mpg

enjoy 😉
 

(FFmpeg + Filtri) Deb per Debian Squeeze/Sid

 

 

 

Condivido pacchetti deb i386 e amd64, per Debian Squeeze/Sid, di FFmpeg compilato con l'aggiunta di molti filtri. Avendo fatto alcune guide, ed altre ne farò, sui filtri di FFmpeg, mi è sembrato giusto condividerli, con quei pochi che mi leggono 🙂

 

Debian Squeeze:

nella cartella ffmpeg-squeeze si trovano i 2 pacchetti, i386 ed amd64. Leggere il file README all'interno.

 

./configure –enable-libdc1394 –prefix=/usr –enable-shared –enable-libmp3lame –enable-gpl –enable-libvorbis –enable-pthreads –enable-libfaac –enable-libxvid –enable-postproc –enable-x11grab –enable-libgsm –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libx264 –enable-libspeex –enable-nonfree –disable-stripping –enable-avfilter –enable-libdirac –disable-decoder=libdirac –enable-libschroedinger –disable-encoder=libschroedinger –enable-version3 –enable-libopenjpeg –enable-libvpx –disable-altivec –disable-armv5te –disable-armv6 –disable-vis –enable-vdpau –enable-bzlib –enable-frei0r –enable-libfreetype –enable-libvo-aacenc –enable-libaacplus –enable-filter=delogo –enable-filter=boxblur –enable-filter=frei0r –enable-filter=drawtext –enable-filter=gradfun

 

Debian Sid:

nella cartella ffmpeg-sid, si trova solo il pacchetto per i386

 

configuration: –prefix=/usr –enable-vdpau –enable-bzlib –enable-libmp3lame –enable-gpl –enable-nonfree –enable-libdirac –disable-decoder=libdirac –enable-libvorbis –enable-pthreads –enable-libfaac –enable-libxvid –enable-postproc –enable-x11grab –enable-libgsm –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libx264 –enable-libspeex –enable-nonfree –disable-stripping –enable-libschroedinger –disable-encoder=libschroedinger –enable-version3 –enable-libopenjpeg –enable-libvpx –enable-librtmp –enable-avfilter –enable-frei0r –enable-libfreetype –enable-libvo-aacenc –disable-decoder=amrnb –enable-libvo-amrwbenc –enable-libaacplus –enable-libdc1394 –disable-altivec –disable-armv5te –disable-armv6 –disable-vis –enable-filter=delogo –enable-filter=boxblur –enable-filter=frei0r –enable-filter=drawtext –enable-filter=gradfun
  libavutil    51. 30. 0 / 51. 30. 0
  libavcodec   53. 40. 0 / 53. 40. 0
  libavformat  53. 24. 0 / 53. 24. 0
  libavdevice  53.  4. 0 / 53.  4. 0
  libavfilter   2. 50. 0 /  2. 50. 0
  libswscale    2.  1. 0 /  2.  1. 0
  libpostproc  51.  2. 0 / 51.  2. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]… {[outfile options] outfile}…
 

(FFmpeg) e filtro drawbox

 

 

Continuando con FFmpeg ed i suoi filtri, oggi tocca a drawbox, che serve ad inserire un box colorato in un video. Di seguito il comando che ho usato per il video sopra, da usare come base di partenza.

 

$ ffmpeg -i input.mp4 -vf "drawbox=150:90:320:180:red@0.8" -sameq -y output.mp4

 

ps: il video scelto serve come stimolo…..all'apprendimento 🙂

 

enjoy 😉

(FFmpeg) Applicare filtri drawtext + fade in un solo comando

 

           

   

 

Un altro filtro che si può usare con FFmpeg oltre a quelli gia visti, è l'effetto dissolvenza (fade). Nel secondo  video ho unito in un solo comando il filtro drawtext e fade.

 

$ ffmpeg -i input.avi -vf drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='TESTO':fontcolor=white@0.8:, fade=in:0:80" -y output.avi

 

enjoy 😉

(FFmpeg) Inserire testo in un video

 

Per inserire un testo in un video usando il solito FFmpeg, bisogna avere  il filtro drawtext:

$ ffmpeg -filters | grep drawtext

 

edmond@Debianbox:~$ ffmpeg -filters | grep drawtext
ffmpeg version 0.8.7, Copyright (c) 2000-2011 the FFmpeg developers
  built on Nov 22 2011 07:59:05 with gcc 4.6.2
  configuration: –prefix=/usr –extra-cflags='-Wall -g ' –cc='ccache cc' –enable-shared –enable-libmp3lame –enable-gpl –enable-nonfree –enable-libdirac –disable-decoder=libdirac –enable-libvorbis –enable-pthreads –enable-libfaac –enable-libxvid –enable-postproc –enable-x11grab –enable-libgsm –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libx264 –enable-libspeex –enable-nonfree –disable-stripping –enable-libschroedinger –disable-encoder=libschroedinger –enable-version3 –enable-libopenjpeg –enable-libvpx –enable-librtmp –enable-avfilter –enable-frei0r –enable-libopencv –enable-libfreetype –enable-libvo-aacenc –disable-decoder=amrnb –enable-libvo-amrwbenc –enable-libaacplus –libdir=/usr/lib/i386-linux-gnu –enable-libdc1394 –disable-altivec –disable-armv5te –disable-armv6 –disable-vis –shlibdir=/usr/lib/i386-linux-gnu
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  8. 0 / 53.  8. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0
drawtext         Draw text on top of video frames using libfreetype library.

il comando usato nel video è stato questo:

$ ffmpeg -i input.mp4 -vf drawtext="fontfile=/usr/share/fonts/truetype/freefont/FreeSerif.ttf: text='TESTO':fontcolor=white@1.0:fontsize=12:x=00: y=10" -y output.mp4

quella sopra è una buona base di partenza, poi si possono fare anche altre cose con il testo, ma quello sarà un capitolo a parte.

enjoy 😉
 

(Update) Inserire logo in un video con FFmpeg

 

                      

 

Questo è un'aggiornamento ad un post fatto un po di tempo fa, che parlava su come abilitare il filtro per poter inserire un logo in un video. Siccome FFmpeg è in continuo sviluppo, è normale che ci siano dei cambiamenti, come l'aggiunta o la rimozione di alcune cose. Nel caso specifico mi sono appena accorto che il comando precedente non funziona più, quindi elencherò 5 comandi "tipici".

 

La mia versione di FFmpeg è quella nei repo unstable:

 

ffmpeg version 0.8.7, Copyright (c) 2000-2011 the FFmpeg developers
  built on Nov 22 2011 07:59:05 with gcc 4.6.2
  configuration: –prefix=/usr –extra-cflags='-Wall -g ' –cc='ccache cc' –enable-shared –enable-libmp3lame –enable-gpl –enable-nonfree –enable-libdirac –disable-decoder=libdirac –enable-libvorbis –enable-pthreads –enable-libfaac –enable-libxvid –enable-postproc –enable-x11grab –enable-libgsm –enable-libtheora –enable-libopencore-amrnb –enable-libopencore-amrwb –enable-libx264 –enable-libspeex –enable-nonfree –disable-stripping –enable-libschroedinger –disable-encoder=libschroedinger –enable-version3 –enable-libopenjpeg –enable-libvpx –enable-librtmp –enable-avfilter –enable-frei0r –enable-libopencv –enable-libfreetype –enable-libvo-aacenc –disable-decoder=amrnb –enable-libvo-amrwbenc –enable-libaacplus –libdir=/usr/lib/i386-linux-gnu –enable-libdc1394 –disable-altivec –disable-armv5te –disable-armv6 –disable-vis –shlibdir=/usr/lib/i386-linux-gnu
  libavutil    51.  9. 1 / 51.  9. 1
  libavcodec   53.  8. 0 / 53.  8. 0
  libavformat  53.  5. 0 / 53.  5. 0
  libavdevice  53.  1. 1 / 53.  1. 1
  libavfilter   2. 23. 0 /  2. 23. 0
  libswscale    2.  0. 0 /  2.  0. 0
  libpostproc  51.  2. 0 / 51.  2. 0

 

Logo in alto a sinistra:

ffmpeg -i inputvideo.avi -vf "movie=logo.png [edm]; [in][edm] overlay=10:10 [out]" outputvideo.avi

 

Logo in alto a destra:

 

ffmpeg -i inputvideo.avi -vf "movie=logo.png [edm]; [in][edm] overlay=main_w-overlay_w-10:10 [out]" outputvideo.avi

 

Logo in basso a sinistra:

 

ffmpeg -i inputvideo.avi -vf "movie=logo.png [edm]; [in][edm] overlay=10:main_h-overlay_h-10 [out]" outputvideo.avi

 

Logo in basso a destra:

 

ffmpeg -i inputvideo.avi -vf "movie=logo.png [edm]; [in][edm] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputvideo.avi

 

invece per ottenere un' effetto come il primo video, bisogna scalare l'immagine all'altezza del video, e poi inserirla:

 

ffmpeg -i inputvideo.avi -vf "movie=logo.png [edm]; [in][edm] overlay=0:0 [out]" outputvideo.avi

 

enjoy 😉