Tag Archives: Video coding

Methods of compiling and installing ffmpeg and libx264 in Linux

Recently in the study of TS stream video preparation FFMPEG video format encoding and conversion
Compiling FFMPEG was smooth but integrating with Libx264 was tedious
It took me a long time to find it online
It is hereby sorted here

Operating system: CentOS 6.4 64-bit kernel 2.6.32
Compiling environment: GCC 4.4.7
FFMPEG version: 2.4
X264 version: X264 0.142.2479 DD79A61
YASM version: 1.3

Prepare documents:
Ffmpeg source
https://www.ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2
x264
Git clone git://git.videolan.org/x264.git
yasm
http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

Compile and install procedure:
1. Install YASM

tar zxvf yasm-1.3.0.tar.gz 
cd yasm-1.3.0
 ./configure 
 make
 make install
 yasm --version

2. Compile and install X264

cd x264 
./configure --enable-shared --enable-pthread --enable-pic
make
make install

3. Compile FFMPEG

cd ffmpeg
./configure --enable-libx264 --enable-gpl --enable-shared  --extra-cflags=-I/usr/local/include --extra-ldflags=-L/usr/local/lib --enable-pic
make
make install

Install well at FFMPEG runtime if prompted

ffmpeg: error while loading shared libraries: libavdevice.so.52: cannot open shared object file: No such file or directory

You will need to modify the file: /etc/ld.so.conf

Add a line at the end of the file:
/usr/local/lib
Then execute the command:
ldconfig

Rerun the ffmpeg – encoders | grep x264 will find successful installation

Android Development notes — mediaplayer error (1, – 2147483648)

Today, I recorded a pit. When I used MediaPlayer to play the video, the screen went black. Then, I saw that the system log output by the console contained a “MediaPlayer Error (1, -2147483648)”.
Then I went to the source code and found this

public interface OnErrorListener
    {
        /**
         * Called to indicate an error.
         *
         * @param mp      the MediaPlayer the error pertains to
         * @param what    the type of error that has occurred:
         * <ul>
         * <li>{@link #MEDIA_ERROR_UNKNOWN}
         * <li>{@link #MEDIA_ERROR_SERVER_DIED}
         * </ul>
         * @param extra an extra code, specific to the error. Typically
         * implementation dependent.
         * <ul>
         * <li>{@link #MEDIA_ERROR_IO}
         * <li>{@link #MEDIA_ERROR_MALFORMED}
         * <li>{@link #MEDIA_ERROR_UNSUPPORTED}
         * <li>{@link #MEDIA_ERROR_TIMED_OUT}
         * <li><code>MEDIA_ERROR_SYSTEM (-2147483648)</code> - low-level system error.
         * </ul>
         * @return True if the method handled the error, false if it didn't.
         * Returning false, or not having an OnErrorListener at all, will
         * cause the OnCompletionListener to be called.
         */
        boolean onError(MediaPlayer mp, int what, int extra);
    }

So the problem I have is the error “MEDIA_ERROR_SYSTEM”, the reason is “system version is too low error”… Then I looked it up on the Internet and found that video files are usually in MP4, AVI, etc., but even if they are in the same file format, they may have different encoding formats. For example, common coding formats are: H.264, H.263 and so on. However, many Andorid devices can only support partial encoding, which results in some videos that cannot be played on Andorid devices. If you have to play these videos, it involves the complicated operation of video transcoding… I haven’t learned this skill yet, so I’ll dig a hole and fill it up later