วันพฤหัสบดีที่ 28 เมษายน พ.ศ. 2554

Compile/build api-example of libavcodec on window with visual c++ 2008.

This post will show, how to compile and build api-exampl.c with visual c++ 2008.

api-example.c is contained in libavcodec folder, this file show you how to use api of libavcodec.
If you can compile it on window you will get idea to use it on your window application.

An example assume, you already have dll, lib and necessary include file on your machine.

1.Create VS C++ with console application project and add api-example.cpp (change file extension form .c to .cpp) to your project.

2.At this step if you compile you will get error message about cannot open include file. you need to set include files path of your visual studio.



- D:\TSL_Project\include; contain inttypes.h and stdint.h these files aren't in VS2008.
- C:\msys\1.0\local\include; contain libavcodec and other necessary include files.

3.Modify your api-example code by
- put extern "C" keywords between include header file of ffmpeg because it come form C coding style
- define "__STDC_CONSTANT_MACROS" this will remove error about "error C3861: 'INT64_C': identifier not found"



4.At this step if you compile code you will get 2 types of error first is cannot convert pointer and second is "snprintf': identifier not found". You need to fix it by.

- For pointer type you can convert it manually by yourself.
- For snprintf you need to use _snprintf instead.

5.At this step you can compile without error, BUT when you build project you will get a error like "unresolved external symbol" , because you still not set linker to your project.

- Add lib directory to VS2008



- Add lib to linker input



6.After add linker you can completely build your project BUT!!! it still not complete process to run your application,

You can build your project without error but you cannot launch your application because you don't have ".dll" in your directory so let's copy it all and paste to your directory and it will work :) .

Simple software for playing/encoding qcif and yuv.

Last post I talk about yuv, qcif player.

So I wanna show my software that I wrote it longtime ago. This software use for playing and encoding h.264. Encoder of this software is very old JM h.264 version.

This software develop by c++builder6 the easy platform to make GUI by C++ language.

The main window after open qcif file is look like this.
















You can play sequence in sequence player of open more clip.
And then if you want to encode it you can set encode parameter by using h.264 option like this.

















And then you can encode by select File->start encoding . Software will encode your sequence to h.264 format. And save it to .264 format and .yuv that already reconstruct.

















This software is not good design and coding but if you wanna demonstrate encode/decode h.264 and wanna see input/output of sequence with simple way you can use it.

p.s. you can email to me if wanna try this software :) .

How to encode and decode h.264 by using ffmpeg.

Today I take time to demonstrate encode and decode process with ffmpeg/x264.

first I will show about how to encode h.264 by ffmpeg and then I will show decode.
This demonstration work on windows7 32bits.

Encode h.264
1.We need to prepare environment like this.
- ffmpeg.exe and its dll.
- libx264
* You can get ffmpeg and libx264 library by download from website or you can get its source code and make install to msys. I will talk about how to build ffmpeg on window on the next post.

2.go to directory that contain your ffmpeg lib and type this command on your console.

ffmpeg.exe -s qcif -i Foreman.qcif -r 25 -an -pass 1 -vcodec libx264 -fpre libx264-lossless_fast.ffpreset -b 32000 -threads 0 test.mp4

parameter meaning will describe here.

-s qcif ; tell ffmpeg that we will encode input yuv video with qcif(176*144) size.

-i Foreman.qcif ; define input sequence I use the test classic test sequence that name foreman.qcif , I think you can get it on google.

-r 25; set frame rate

-an; disable audio we will encode only video data

-pass 1; use 1 pass video coding

-vcodec libx264; use libx264 for codec

-fpre libx264-lossless_fast.ffpreset; define encoding parameter for h.264 that contain in ffpreset file.

-b 32000; set bit rate as 32kbps.

-threads 0; set thread for encoding to zero.

test.mp4; define output file.

And after run this command encoded sequence will be created to test.mp4 and console log will shown like this.









you can play test.mp4 to see the result clip by using player that contain h.264 codec.


Decode h.264

decode process is easier, it just type a few command line to ffmpeg like this.

ffmpeg -i test.mp4 decode_out.yuv

-i test.mp4 ; define input sequence to decode.
- decode_out.yuv; define output sequence in format of yuv.

And the output that show on console will look like this.













decode_out.yuv can open by using yuv player.

That's all for this post, next post I will show about how to write code in c++ to encode/decode h.264 by using libavcodec of ffmpeg.

วันพุธที่ 16 มีนาคม พ.ศ. 2554

วันอาทิตย์ที่ 13 มีนาคม พ.ศ. 2554

My future again.

About 1 year that I have worked at Vizrt Thailand, This company is really cool place you can get free food free drunk free party and beautiful friendship.

But for now I take a look for a new challenge job that can made inspiration to me. If everything is ok, I tihnk I will get that job in soon.

:)

วันอังคารที่ 25 พฤษภาคม พ.ศ. 2553

My work and Future.

Long time since I write latest post. Now I work as Software developer at software company.
My work is about C++ . In next 2-3 months I plan to study java more to create some app in android plattfrom. And I still sell sushi 2 day/week at weekend market. And oneday I dream to have my own business work about smthing I like maybe music, food or technology.
:)

วันพฤหัสบดีที่ 1 พฤษภาคม พ.ศ. 2551

Change oracle database character set

I had problem with AL32UTF8 character from Oracle ... so I want to change character set to THTISASCII by follow as step

sqlplus "/as sysdba"
startup;
select * from nls_database_parameters;
shutdown immediate;

STARTUP MOUNT;

ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE CHARACTER SET TH8TISASCII;

SHUTDOWN;
STARTUP;

After follow this step as my friend suggest I found error with command

ALTER DATABASE CHARACTER SET TH8TISASCII;
ORA-12712: new character set must be a superset of old character set

Because old character set is Superset of new character set so Oracle does not allow to change character set.

Anyway you can avoid this problem if you really want to change it by using command
ALTER DATABASE CHARACTER SET INTERNAL_USE TH8TISASCII;

Oracle will allow you to change character set although old character set is a superset of new character set but you must make sure that this change will not impact your database.

:)