FFmpeg

Ultra easy way to convert files with terminal and ffmpeg

for file in *.* ;do ffmpeg -i "$file" -ab 128k  "${file%%.*}".mp3 ; done

Ultra easy way to Cut video

ffmpeg -sameq -ss [start_seconds] /
-t [duration_seconds] -i [input_file] [outputfile]

example 5 minutes and 21 seconds and 16 cents

ffmpeg -i 1.avi -sameq -t 00:05:21:16 panelss.webm

HOW TO TEST YOUR FFMPEG

FFmpeg handles a lots of formats but only if you install it correctly let’s go to test it

Type in a terminal :

ffmpeg -formats 2>&1 | grep aac

if you get

 D  aac             ADTS AAC D A    mpeg4aac

E=Encoder and so…

Your ffmpeg is not able to use restricted formats like ac3 wma etc etc ! and you’ll get problems !

if you get

 D  aac             ADTS AAC DEA    aac D A    mpeg4aac

your FFmpeg is compiled with aac supports and if you wanna encode on ac3 formats you HAVE TO USE like codec name aac!

EXAMPLE: ffmpeg -i INPUT -acodec aac OUTPUT
fi you get

 D  aac             ADTS AAC DEA    libfaac D A    mpeg4aac

Your FFmpeg is compiled with aac supports but YOU HAVE TO USE LIBFAAC like codec name!

EXAMPLE: ffmpeg -i INPUT -acodec libfaac OUTPUT

this works for many codecs example xvid h264 etc etc

etc etc

HOW TO FIX FFMPEG on Kubuntu system WITH MEDIBUNTU REPOSITORY

1-Add Medibuntu repository

sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

Medibuntu’s repository is deactivated by upgrading to a newer Ubuntu release, so you should run this command again after the release upgrade.

You may also wish to add the following packages. The first will cause many apps from the Medibuntu repository to appear in Ubuntu Software Center (Ubuntu 9.10+) or Add/Remove Applications (versions prior to 9.10). The second will allow users to generate crash reports against Medibuntu packages and submit them to the Medibuntu bugtracker.

sudo apt-get --yes install app-install-data-medibuntu apport-hooks-medibuntu

Please note you may have to use –force-yes instead of –yes in order for this command to succeed.

then reinstall FFmpeg + these packages (NUMBER COULD CHANGE BUT YOU CAN SEARCH WITH SYNAPTIC O KPACKAGEKIT )

 sudo apt-get install ffmpeg libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-49 libpostproc-unstripped-51 libswscale-unstripped-0

kubuntu 10.10 has changed instead of 49 you will find 50  so….

 sudo apt-get install ffmpeg libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-50 libpostproc-unstripped-51 libswscale-unstripped-0

kubuntu 11.10

sudo apt-get install libavfilter-extra-2 libavcodec-extra-53 libavformat-extra-53 libavutil-extra-51 libavdevice-extra-53 libswscale-extra-2
 

COMPILING FFMPEG

Something you should know

If you see on the configure script many times you see –enable-shared and –prefix=/usr/local/ why?

–enable-shared

Software like kdenlive use ffmpeg so they need to know where libraries are in order to use them … so YOU NEED TO ENABLE THIS OPTION , if you don’t kdenlive will use the SYSTEM FFMPEG that typically is installed on /usr/bin…. so kdenlive will not use the new ffmpeg.. with the newest features… on /usr/local but there is more one thing …

with “shared” option you could get errors if you have installed via sudo apt-get install ffmepg like

 error while loading shared libraries: libavutil.so.50: cannot open shared object file: No such file or directory

you can try this to solve

sudo apt-get remove –-purge ffmpeg   libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-49 libpostproc-unstripped-51 libswscale-unstripped-0

or you can solve removing –enable-shared on your configure settings , if you do that you would not able to use ffmpeg in other software like kdenlive or or or

So and if i want test newest ffmpeg ? and keep the system ffmpeg ?

OF course you can ….
1 install the ffmpeg with sudo apt-get install ffmpeg
2 compile your ffmpeg without –enable-shared and with –prefix=/usr/loca/
3 if you have compiled here $HOME/src/ffmpeg/ffmpeg DO NOT RUN sudo make install , test it with

$HOME/src/ffmpeg/./ffmpeg

4 if it works you can run this

 alias tffmpeg='$HOME/src/ffmpeg/ffmpeg' 

now type this 🙂

tffmpeg

now your system will use tffmpeg 🙂

–prefix=/usr/local
to avoid some problems with libraries you need to install ffmpeg on /usr/local , the most of configure script has

/usr/local like prefix by default anyway to be sure ….

–prefix=/usr/local

HOW To FIX FFMPEG on Kubuntu 12.04 system COMPILING

https://nowardev.wordpress.com/2012/02/07/ffmpeg-12-04/

INSTALL DEPENDENCES fast way

sudo apt-get build-dep can install dependences easily but you could get some error on configure if there is not all libraries especially if they are not so free as gnu says…

sudo apt-get build-dep ffmpeg && sudo apt-get install libx264-dev  libxvidcore4-dev libopenjpeg-dev libamrwb-dev libamrnb-dev  checkinstall  libasound2-dev   libdc1394-22-dev   libgsm1-dev  libimlib2-dev libraw1394-dev libsdl1.2-dev libschroedinger-dev libspeex-dev  libtheora-dev  libvorbis-dev libx11-dev libxext-dev libxvmc-dev quilt texi2html zlib1g-dev libfaad-dev libdirac-dev libfaac-dev libmp3lame-dev

This could help you to add some feauters on your ffmpeg when this article will get old.The most of configuration can be found here , i mean to enable codecs,

./configure --help | awk -v ORS=" " '/enable/{print $1} END{printf "\n"}' 

that should list every library you can enable. And as you can see on karmic koala 9.10 the old way to compile ffmpeg can not be used again, just because amr libraries have changed name and some feauters have been added like vdpau for nvdia cars only. So now you need to install :

sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev

when i tried to compile ffmpeg then i get some errors like this

 ibavcodec/vdpau.h:76: error: expected specifier-qualifier-list before ‘VdpPictureInfoMPEG4Part2’

and of course this is an error because i have not disabled vdpau support that is only for nvidia cards. and i have an intel… well so you should search something to disable with

./configure --help | grep disable- 

if you prefer

  ./configure --help | awk -v ORS=" " '/disable/{print $1} END{printf "\n"}'

So this could be a configuration :(here there is not x264 becasue on kubuntu karmic seems there are some problems with x264 version… -.-” **)

--prefix=/usr/local --enable-shared --enable-gpl --enable-version3 --enable-nonfree  --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab  --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libdc1394 --enable-libdirac  --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame  --enable-libopenjpeg --enable-libschroedinger --enable-libtheora --enable-libvorbis  --enable-libxvid --disable-vdpau

and this one another to add some libraries that you never use in your life …

./configure  --prefix=/usr/local --enable-shared  --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-avfilter --enable-avfilter-lavf --enable-pthreads --enable-x11grab --enable-gray    --enable-bzlib --enable-libopencore-amrnb  --enable-libopencore-amrwb --enable-libdc1394  --enable-libdirac   --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame  --enable-libopenjpeg  --enable-libschroedinger  --enable-libspeex --enable-libtheora  --enable-libvorbis     --enable-libxvid   --enable-zlib  --enable-gprof  --enable-extra-warnings --disable-vdpau

if you want 264 encoder you should download and installl libx264 too… -.-”

git clone git://git.videolan.org/x264.git
cd x264  &&  ./configure --enable-shared  &&  make -j3  &&  sudo checkinstall

**if you want install normally you should use sudo make install instead of sudo checkinstall.

then recompile ffmpeg you should get errors on compiling ffmpeg just because this library is going to be installed in /usr/local/lib instead of /usr/lib…

for my own use i installed ffmpeg on /usr … even if this can be a pain in some situations

a nice article has been made here

kubuntu 11.04 alpha

2011 tested configuration NOTE THIS WAS A TEST SO I HAVE DISABLE SHARED

sudo apt-get install libopencore-amrnb-dev libopencore-amrwb-dev libopenjpeg-dev libx264-dev libxvidcore-dev && sudo apt-get build-dep ffmpeg && mkdir ~/src &&  cd ~/src && git clone git://git.ffmpeg.org/ffmpeg.git && cd ~/src/ffmpeg &&./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc  --enable-x11grab --enable-gray --enable-small --enable-runtime-cpudetect --enable-hardcoded-tables --enable-memalign-hack   --enable-bzlib --enable-frei0r --enable-libopencore-amrnb --enable-libopencore-amrwb  --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libgsm  --enable-libopenjpeg  --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264  --enable-libxvid  --enable-zlib  --enable-pic --enable-sram   --enable-extra-warnings 

note these was giving errror ..

 --enable-avisynth  --enable-libmp3lame --enable-libnut --enable-libopencv --enable-librtmp --enable-libxavs --enable-mlib

now you could test your ffmpeg… to do this we do alias so your system can use your compiled ffmpeg without installing on the system

 alias tffmpeg='$HOME/src/ffmpeg/ffmpeg' && tffmpeg 

save the presets!!

mkdir $HOME/.ffmpeg && cd ~/src/ffmpeg/ffpresets/  && for file in * ; do cp "$file" $HOME/.ffmpeg ; done 

Screencast with FFmpeg

(huge files maker.. here you can find a nice tutorial)

get your audio capture card :

 cat /proc/asound/pcm 

i get

 00-00: ALC861-VD Analog : ALC861-VD Analog : playback 1 : capture 1
00-06: Si3054 Modem : Si3054 Modem : playback 1 : capture 1
01-00: USB Audio : USB Audio : capture 1

so i have want alc861vd so i have to use -i hw:0,0

ffmpeg -f  alsa  -ac 2 -ar 48000  -i hw:0,0   -s $(xrandr  | awk '/, current /{print $8}')x$(xrandr  | awk '/, current /{gsub(/\,/,"");print $10}') -f x11grab -r 30  -i :0.0 -acodec pcm_s16le -vcodec  ljpeg output.mkv 

this will use sampling rate to 48000 usefull if you card got sound noise (tic tic)

 ffmpeg -f  alsa  -ac 2 -ar 48000  -i hw:0,0   -s $(xrandr  | awk '/, current /{print $8}')x$(xrandr  | awk '/, current /{gsub(/\,/,"");print $10}') -f x11grab -r 30  -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast  -threads 2 output.mkv 

smoller file …. with libx264 .. pulse like sound stuff instead of alsa

ffmpeg -f alsa -ac 2 -i pulse -s $(xrandr  | awk '/, current /{print $8}')x$(xrandr  | awk '/, current /{gsub(/\,/,"");print $10}') -f x11grab -r 30  -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 output.mkv

create gif

byzanz-record  --delay=3 --duration=8 --cursor  plasma_howto-throw-ball.gif

other resources

https://develop.participatoryculture.org/index.php/ConversionMatrix

vhs ripping

avconv -f  alsa  -ac 2 -ar 48000  -i hw:0,0 -acodec mp2 -f video4linux2 -channel 1 -i /dev/video0 -vcodec mjpeg test.avi

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.