command – tail (part 1)

Linux Tips No Comments »

This tutorial is meant for those who are newbies to the Linux environment and please feel free to add any suggestion to this material. The command tail is used to output the last part of a file (e.g tail mylog.txt ) this will output the last 10 lines of mylog.txt by default , you can change this by adding an extra parameter to your tail command (e.g tail -n 100 mylog.txt) this will now return the last 100 lines from mylog.txt as suppose to the default 10 lines.

My favorite parameter which you can use with tail command allows you to monitor log files as they are being populated (e.g tail -f mylog.txt) first it will show me the default 10 lines but then as soon as a new entry is inserted into the mylog.txt I will be able to see it without reloading the file or the command, This is useful if you are debugging anything that writes to a log file because you can monitor the log while you attempting to fix your problem.

So next time you want to monitor your log files try and use tail to capture your errors and please try not use vi on log files which are very big(e.g A 5 gigabyte log file will crash your server if you do a vi on it,unless you have a very very very big server thats never worries about Ram ) But you can always tail a big log file and if that does not help then you can try using grep which is something else all together.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Tags: ,

Converting mp3 to flv with ffmpeg

FFmpeg 9 Comments »

Sometime last year I encountered a problem with playing mp3 flies online, The problem I had was the player which I had embedded on the page only worked for windows machines which was a problem because I work on a Linux machine all the time. I then decided to convert the mp3 files to a flv format and use a flv player on the site,this setup allowed for songs to be played on site via a flash player which worked on a Windows,Linux and Mac environments as long as the browser supported flash.

The code that did the trick:

ffmpeg -y -i myfile.mp3 -f flv -acodec libmp3 -ab 64 -ac 1 myfile.flv

This is useful if you are running a music site of some sort where you want to make sure that users can listen to the site music files online regard less of what operating system they are running.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Tags: , ,

Converting mp3 to amr with ffmpeg

FFmpeg No Comments »

Lets start by checking if you have amr support enabled with ffmpeg, Type ffmpeg in you console to check if it is in your $PATH Or preferable you can run it from where it is installed e.g /usr/local/ffmpeg/bin/ffmpeg

When I run my ffmpeg without any parameters this is what I get.

FFmpeg version SVN-r9833, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: –enable-shared –enable-gpl –enable-pp –enable-liba52 –enable-libamr-nb –enable-libamr-wb –enable-libfaac –enable-libfaad –enable-libmp3lame –enable-libogg –enable-libvorbis –enable-libx264 –enable-libxvid –disable-mmx –enable-libtheora

Which means I have both versions of amr installed. For the sake of demonstration I a m going to use libamr_wb which is what I need to create true tones from mp3, Just remember you can use other formats besides amr to create ring tones.

ffmpeg -y -i myaudio.mp3 -ab 18.25k -ar 16000 -acodec libamr_wb -ac 1 mynewaudio.amr 2>&1

Be careful on which libamr you decide to use because they accept sampling rates which are very different, If you upload this to your phone it should play. The One nice thing about using amr is that you can cut down on the mp3 file size by more than 200% e.g. take a mp3 song which is 2.5mb in size and you convert that with the settings given above, you will have an amr file which is roughly at 500kb in size and it is still a full length song but just the quality is not as good as mp3. For best results try to play around with bit rate(-ab) variables.

Please note that some cellphones don’t support amr, so you will still have to try out other formats for them.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Tags: , ,

How I installed my FFMPEG

FFmpeg 2 Comments »

I have read through a lot of tutorial about installing ffmpeg and I guess you can say that I’m giving back some of the experience I have sort of acquired along the way. First thing you need to do is decide what codecs/formats you want to use based on the codecs which ffmpeg supports.

  • AMR and 3gp [http://www.penguin.cz/~utx/amr]
  • X264 [http://www.videolan.org/developers/x264.html]
  • Xvid [http://www.xvid.org/Downloads.43.0.html]
  • FAAC and FAAD2 [http://faac.sourceforge.net/oldsite/index.php]
  • Libmp4v2 [http://resare.com/libmp4v2/]
  • Libogg , Libvorbis and Libtheora [http://xiph.org/downloads/]
  • Mplayer + Mencoder [svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer]
  • FFMPEG [svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg]
  • Lame [http://lame.sourceforge.net/index.php]
  • Flv tools [http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz]

After you have decided which ones you gonna install you can now start downloading and compiling them, just decide on your installation if you gonna install them with default parameters e.g. ./configure or with a directory e.g ./configure –prefix=$HOME.

Here are two tutorials which talk about the same thing but do help with the installations.

installing ffmpeg – the easy way

FFmpeg, FFmpeg-PHP, Lame, Libogg, Libvorbis, FLVtool2, Mplayer, Mencoder, AMR Installation

the both look very similar in approach but they both help.

when installing my codecs I prefixed them to their own directories e.g ./configure –prefix=/usr/local/lame which gave me a hard time when compiling ffmpeg to support them. After going through enough forums and maillists I finally got it to it to compile as follows,

./configure –prefix=/usr/local/ffmpeg –disable-mmx –enable-gpl –enable-pp –enable-liba52 –extra-ldflags=-L/usr/local/liba52dec/lib/ –extra-cflags=-I/usr/local/liba52dec/include/ –enable-libmp3lame –extra-ldflags=-L/usr/local/lame/lib/ –extra-cflags=-I/usr/local/lame/include/ –enable-libamr-nb –extra-ldflags=-L/usr/local/amrnb/lib/ –extra-cflags=-I/usr/local/amrnb/include/ –enable-libamr-wb –extra-ldflags=-L/usr/local/amrwb/lib/ –extra-cflags=-I/usr/local/amrwb/include/ –enable-libfaac –extra-ldflags=-L/usr/local/faac/lib/ –extra-cflags=-I/usr/local/faac/include/ –enable-libfaad –enable-libx264 –enable-libxvid –extra-ldflags=-L/usr/local/xvidcore/lib/ –extra-cflags=-I/usr/local/xvidcore/include/ –enable-libogg –extra-ldflags=-L/usr/local/libogg/lib/ –extra-cflags=-I/usr/local/libogg/include/ –enable-libvorbis –extra-ldflags=-L/usr/local/libvorbis/lib/ –extra-cflags=-I/usr/local/libvorbis/include/ –enable-libtheora –extra-ldflags=-L/usr/local/libtheora/lib/ –extra-cflags=-I/usr/local/libtheora/include/

after you are done you ffmpeg should now work fine, but if it complains about missing libraries you can append them to /etc/ld.so.conf file e.g echo “/usr/local/xvidcore/lib/” >> /etc/ld.so.conf and then do an ldconfig. That should get you converting videos and audio files with ffmpeg.

when I run ffmpeg on my server

/usr/local/ffmpeg/bin # ./ffmpeg

FFmpeg version SVN-r10131, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: –prefix=/usr/local/ffmpeg –disable-mmx –enable-gpl –enable-pp –enable-liba52 –extra-ldflags=-L/usr/local/liba52dec/lib/ –extra-cflags=-I/usr/local/liba52dec/include/ –enable-libmp3lame –extra-ldflags=-L/usr/local/lame/lib/ –extra-cflags=-I/usr/local/lame/include/ –enable-libamr-nb –extra-ldflags=-L/usr/local/amrnb/lib/ –extra-cflags=-I/usr/local/amrnb/include/ –enable-libamr-wb –extra-ldflags=-L/usr/local/amrwb/lib/ –extra-cflags=-I/usr/local/amrwb/include/ –enable-libfaac –extra-ldflags=-L/usr/local/faac/lib/ –extra-cflags=-I/usr/local/faac/include/ –enable-libfaad –enable-libx264 –enable-libxvid –extra-ldflags=-L/usr/local/xvidcore/lib/ –extra-cflags=-I/usr/local/xvidcore/include/ –enable-libogg –extra-ldflags=-L/usr/local/libogg/lib/ –extra-cflags=-I/usr/local/libogg/include/ –enable-libvorbis –extra-ldflags=-L/usr/local/libvorbis/lib/ –extra-cflags=-I/usr/local/libvorbis/include/ –enable-libtheora –extra-ldflags=-L/usr/local/libtheora/lib/ –extra-cflags=-I/usr/local/libtheora/include/
libavutil version: 49.5.0
libavcodec version: 51.41.0
libavformat version: 51.12.2
built on Aug 21 2007 15:30:46, gcc: 4.1.2 20061115 (prerelease) (SUSE Linux)
usage: ffmpeg [[infile options] -i infile]… {[outfile options] outfile}…
Hyper fast Audio and Video encoder

I hope this help, If you are still having problems getting ffmpeg to work on you machine atfer following all the links I provided Please let me know. If you have any suggestions please leave a comment.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]
Tags: , , , , , , ,
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in