How to build and run ffmpeg 0.8
1. download 0.8 ffmepg
2. Install libsdl libsdl-mix, using synaptic package manager
3 ./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-shared --disable-yasm --enable-debug=3 --disable-stripping --prefix=/home/xgu/ffmpeg
4. make; make install;
5. cd /home/xgu/ffmpeg/bin
6. LD_LIBRARY_PATH=../lib ./ffmpeg -s 640x480 -f video4linux2 -i /dev/video0 -f mpegts -vcodec mpeg2video out1.mpeg
7. LD_LIBRARY_PATH=../lib ./ffplay Some_Video_File
2011/07/27
2011/07/21
Video Audio Capture in Linux
Video
Webcam support in Linux is mainly provided by the Linux UVC Project's UVC driver.
The UVC driver implements the Video4Linux 2 (V4L2) API
The specification of V4L2 API can be found at http://v4l2spec.bytesex.org/
Example:
In ffmpeg, file libavdevice/v4l2.c
http://v4l2spec.bytesex.org/v4l2spec/capture.c
Command:
#To capture video
ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
Audio
Ubuntu is using ALSA for audio input output
Command:
#To capture audio
ffmpeg -f alsa -ac 2 -i hw:0 alsaout.wav
#To get hardware info
arecord -l
Reference:
http://ffmpeg.org/ffmpeg-doc.html
http://www.ideasonboard.org/uvc/
https://help.ubuntu.com/community/Webcam
https://help.ubuntu.com/community/UVC
http://v4l2spec.bytesex.org/
http://www.alsa-project.org/
Webcam support in Linux is mainly provided by the Linux UVC Project's UVC driver.
The UVC driver implements the Video4Linux 2 (V4L2) API
The specification of V4L2 API can be found at http://v4l2spec.bytesex.org/
Example:
In ffmpeg, file libavdevice/v4l2.c
http://v4l2spec.bytesex.org/v4l2spec/capture.c
Command:
#To capture video
ffmpeg -f video4linux2 -i /dev/video0 out.mpeg
Audio
Ubuntu is using ALSA for audio input output
Command:
#To capture audio
ffmpeg -f alsa -ac 2 -i hw:0 alsaout.wav
#To get hardware info
arecord -l
Reference:
http://ffmpeg.org/ffmpeg-doc.html
http://www.ideasonboard.org/uvc/
https://help.ubuntu.com/community/Webcam
https://help.ubuntu.com/community/UVC
http://v4l2spec.bytesex.org/
http://www.alsa-project.org/
2011/07/15
2011/07/13
Encode PCM to MP3
To encode PCM data to MP3 in Ubuntu 11.04:
Reference:
https://wiki.ubuntu.com/ffmpeg
http://turanct.wordpress.com/2010/04/03/convert-aiff-to-mp3-with-ffmpeg-on-ubuntu/
sudo apt-get build-dep ffmpeg sudo apt-get install libmp3lame-dev libfaad-dev libx264-dev libfaac-dev libxvidcore-dev liba52-0.7.4 liba52-0.7.4-dev libdts-dev checkinstall apt-get source ffmpeg cd libav-* ./configure --disable-debug --enable-libfaad --enable-libfaac --enable-gpl --enable-nonfree --enable-libx264 --enable-libxvid --enable-pthreads --enable-libvorbis --enable-libmp3lame --enable-libtheora --enable-libgsm --disable-debug --enable-shared --prefix=/usr make sudo checkinstall -D make install ffmpeg -i audiobo.aiff -f mp3 -acodec libmp3lame -ab 64k -ar 22050 output.mp3
Reference:
https://wiki.ubuntu.com/ffmpeg
http://turanct.wordpress.com/2010/04/03/convert-aiff-to-mp3-with-ffmpeg-on-ubuntu/
2011/07/10
Calculate Audio Level
How to calculate audio level from PCM sample data:
http://en.wikipedia.org/wiki/Root_mean_square
Sample Code
Reference:
http://wiki.hydrogenaudio.org/index.php?title=Replaygain
http://en.wikipedia.org/wiki/Root_mean_square
Sample Code
protected void updateLevelAndPeak(ByteBuffer bytebuffer, int bufferLen) { int numFrame = bufferLen / frameSizeInBytes; long sampleSqureTotal = 0L; long peak = 0L; ShortBuffer shortbuffer = bytebuffer.asShortBuffer(); for (int indexFrame = 0; indexFrame < numFrame; indexFrame++) { int sampleValue = 0; for (int indexChannel = 0; indexChannel < channels; indexChannel++) { sampleValue += shortbuffer.get(channels * indexFrame + indexChannel); } sampleValue /= channels; int k = Math.abs(sampleValue); sampleSqureTotal += sampleValue * sampleValue; if ((long) k > peak) { peak = k; } } currentLevel = numFrame <= 0 ? 0.0D : Math.sqrt(sampleSqureTotal / (long) numFrame); currentPeak = peak; }
Reference:
http://wiki.hydrogenaudio.org/index.php?title=Replaygain
2011/07/07
How to make JSONP call in GWT
Example goes here:
String url3 = "https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=barack%20obama"; JsonpRequestBuilder jsonp = new JsonpRequestBuilder(); //jsonp.setCallbackParam("callback"); //gwt will generate a java script object of url "http://url_of_some_service?para=value%callback=_xxxx_onSuccess" //the _xxxx_onSuccess points to below onSucess function. jsonp.requestObject(url3, new AsyncCallback<javascriptobject>() { public void onFailure(Throwable throwable) { GWT.log("got the JavaScriptObject"); Window.alert("jsonp failed"); } public void onSuccess(JavaScriptObject feed) { JSONObject obj = new JSONObject(feed); JSONValue val = obj.get("responseStatus"); if(val != null) { JSONNumber num = val.isNumber(); Window.alert("got the responseStatus " + num.doubleValue()); } else { Window.alert("not getting the responseData"); } } });
Subscribe to:
Posts (Atom)
Post Code on Blogger
Simplest way to post code to blogger for me: <pre style="background: #f0f0f0; border: 1px dashed #CCCCCC; color: black;overflow-x:...
-
Explain There is not interrupt PIN for PCIe interrupt. When device wants to raise an interrupt, an interrupt message is sent to host via ...
-
Configure Space Addressing One of the major improvements the PCI Local Bus had over other I/O architectures was its configuration mechanism...
-
What is LMA and VMA Every loadable or allocatable output section has two addresses. The first is the VMA, or virtual memory address. This ...