Posts

Showing posts from June, 2010

FFMPEG - Transcoding Commands

Getting information 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.
So, if your image name is image-100 - image 199, your command will be 
ffmpeg -f image2 -i image-1%02d.jpg mp4
%02 means use 2 digit starting from 00 for the input file name
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 -acodec aac -ab 128 -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 …

FFMPEG - Compiling with Cygwin Window

You need the following to compile FFMPEG on window. Cygwin seems to be an easier choice than MingW
1. Install your Cygwin with all the "Base" packages, plus the following "Devel" ones: binutils, gcc4-core, make, subversion, mingw-runtime, texi2html, diffutils
2. Load Cygwin and navigate to the ffmpeg source
3. type dos2unix configure to convert the file to dos compatible text
4. Type make distclean to clean the past distribution if any
5. Then run ./configure --enable-static --disable-shared to make a static build.5. The current gcc4-core package is buggy and needs this flag to build shared libraries: ./configure --enable-shared --disable-static --extra-cflags=-fno-reorder-functions6. Then perform make and make install7. You should have all your builds at \Cygwin\usr\local folderAlternatively, you can download nightly build from http://ffmpeg.arrozcru.org/autobuilds/

C# - Timer Precision Issue

Timer precision issue doesn't only affect Java, it should affect most programming language. It is because when you pause a thread, it gives away its right and allow the OS to schedule their job.
Thus, Thead.Sleep/Monitor.Wait does not guarantee the sleep time.
To archive high resolution, you can try using multimedia timer such as QueryPerformanceCounter . This is good for perform elapse calculations.
Or you can use timeBeginPeriod to requests a minimum resolution for periodic timers.
For example, to reduce the resolution to 1 ms
[DllImport("winmm.dll")] internal static extern uint timeBeginPeriod(uint period); [DllImport("winmm.dll")] internal static extern uint timeEndPeriod(uint period);
timeBeginPeriod(1); while(true) { Thread.Sleep(1); // will sleep 1ms every time } timeEndPeriod(1);

http://msdn.microsoft.com/en-us/library/dd757624(v=VS.85).aspx http://msdn.microsoft.com/en-us/library/ms632592(v=VS.85).aspx http://www.codeguru.com…

Java - Timer Precision Issue

Image
When you have more experience with Thread.sleep/Object.wait, you will soon realize that this method often sleep more than you want.Java does not guarantee the resolution archived. Java uses underlying OS interrupt to trigger timed event and this interrupt are often in the resolution of 10ms. For example, System.currentTimeMillis return the clock time in millisecond. However, the update of this clock reference is often same as time interrupt (10ms). This issue is a problem for application that requires high timer resolution. So, Java provides a switch -XX:ForceTimeHighResolution to force the OS time interrupt to 1ms interval. It will set OS interrupt to 1ms when VM starts and reset to original value when VM exit.But, it seems that -XX:ForceTimeHighResolution is not perfect and is a use at your own risk switch (http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=5005837). Also, setting OS interrupt to 1ms may have big effect on OS performance. In general, you can use System.currentTimeMi…

MS Outlook and AVAST 5.0 Hangs

If you encounter MS Outlook busy writing to disk and hang, please check if you have Avast 5.0 and above installed. If Avast is installed, it has a very high chance that Avast is not working well with MS Outlook together.
The best solution is to uninstall Avast and stop the hangs.
On top of that, you should consider repairing your Outlook after you have uninstalled Avast.
1. Go to :\Program Files\Microsoft Office\Office12\SCANPST.exe to repair your PST folder. Your pst file should be contained at C:\Documents and Settings\\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst. Repairing PST takes several minutes.
2. Next, run Microsoft Office Diagnostics to repair Office issues. You can find this application at Microsoft Office Tools start menu.
3. Run MS Outlook, you should see that your outlook will not grind your harddisk after these operations.

ADTS - Audio Data Transport Stream Frame

ADTS is an audio interchange format for storage and transporting audio object.
A ADTS structure contains a fixed header, variable header and a error check
Most importantly, ADTS contains decoding information for decoder. If you wants to initialize a decoded with specific information, you will requires information in the fixed header
Below is the layout for fixed header in
Syncword 12 bits ID 1 bits Layer 2 bits protection_absent 1 bits Profile_ObjectType 2 bits sampling_frequency_index 4 bits private_bit 1 bits channel_configuration 3 bits original/copy 1 bits home 1 bits Emphasis 2 bits
Full information can be located at ISO/IEC 14496-3 Annex 1.A