Linux ffmpeg compile Configuration installation detailed

Source: Internet
Author: User

About FFmpeg

FFmpeg is an open source free Cross-platform video and audio streaming program that belongs to free software, using LGPL or GPL licenses (based on the components you choose). It provides a complete solution for recording, converting, and streaming audio and video. It contains a very advanced audio/video codec library Libavcodec, in order to ensure high portability and codec quality, Libavcodec Many codec are developed from scratch.

ffmpeg Configuration

Ubuntu 12.04

Before installing FFmpeg, you first install Yasm

1. Install Yasm

The yasm I used was yasm-1.2.0.tar.gz this version.

The code is as follows Copy Code

#wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
#tar XZVF yasm-1.2.0.tar.gz

# CD yasm-1.2.0

#./configure

Note: Do not use prefix to specify the installation path or whatever, otherwise it will be endless.

The code is as follows Copy Code

#make

#make Install

2. Install FFmpeg

The ffmpeg I use is ffmpeg-0.10.2.tar.bz2 this version of the

The code is as follows Copy Code

# wget http://ffmpeg.org/releases/ffmpeg-2.0.1.tar.gz

#tar XVFJ ffmpeg-2.0.1.tar.gz

#cd ffmpeg-2.0.1

#./configure

#make

#make Install

At this point, the FFmpeg has been installed.

Test
Video screenshot:

The code is as follows Copy Code
Ffmpeg-i 02c692c38a1c352e4c70cf086cfffa48_1380258978_2168.flv-y-F image2-ss 8-frames 1/1.jpg

Success

PHP Call Video screenshot

The code is as follows Copy Code


Private Function Takepiconvideo ($file, $time)
{
$videoFile = ' upload/lessions/'. $file;
$videoTime = $time;
if (Is_file ($videoFile))
{
$image _file= "$videoFile. jpg";
$command = "Ffmpeg-i $videoFile-y-F image2-ss $videoTime-T 0.001 $image _file";
$command = "Ffmpeg-i $videoFile-y-F image2-ss $videoTime-frames 1 $image _file";
Set_time_limit (0);
EXEC ($command);
return $image _file;
}
Else
{
Return ";
}
}


Report:
ffmpeg using syntax
ffmpeg [[options]['-i ' input_file]] ... {[options] output_file} ...

If there is no input file, the video audio capture (which is only valid under Linux) will work if the audio and video device is handled as a file handle under Linux. As a general rule, options are generally used for the next specific file. If you give –b 64 option, re-election will set the next video rate. For the original input file, the formatting options may be required. By default, FFmpeg tries to do as much lossless conversion as possible, using the same audio video parameters as input to output.

FFmpeg conversion involves more options, you can refer to the FFmpeg option detailed.

FFmpeg supports a variety of file formats and a variety of audio, video encoders, can refer to the FFMEPG format, (with: Common video file format detailed)

Screenshot of video file
To intercept a picture of a 352x240 size, formatted as JPG
Ffmpeg-i test.asf-y-F image2-t 0.001-s 352x240 a.jpg

Convert the first 30 frames of the video into a animated Gif
Ffmpeg-i test.asf-vframes 30-y-F gif a.gif

Intercept a thumbnail for a specified time
Ffmpeg-i test.avi-y-F image2-ss 8-t 0.001-s 350x240 test.jpg

The time unit followed by the-SS is seconds
Convert file to 3GP format
Ffmpeg-y-I test.mpeg-bitexact-vcodec h263-b 128-r 15-s 176x144

-acodec aac-ac 2-ar 22500-ab 24-f 3gp test.3gp

Or
Ffmpeg-y-I test.wmv-ac 1-acodec libamr_nb-ar 8000-ab 12200-s 176x144-b 128-r

Video format Conversion
How to use ffmpeg encoding to get high-quality video
Ffmpeg.exe-i "D:videofearlessfearless.avi"-target film-dvd-s 720x352

-padtop 64-padbottom 64-maxrate 7350000-b 3700000-sc_threshold 1000000000

-trellis-cgop-g 12-bf 2-qblur 0.3-qcomp 0.7-me full-dc 10-mbd 2

-aspect 16:9-pass 2-passlogfile "D:videoffmpegencode"-an-f mpeg2video "D:FEARLESS.M2V"

Convert the specified format file to FLV format
Ffmpeg.exe-i test.mp3-ab 56-ar 22050-b 500-r 15-s 320x240 f:test.flv

Ffmpeg.exe-i test.wmv-ab 56-ar 22050-b 500-r 15-s 320x240 f:test.flv

VOB of transcoding and decoding
Ffmpeg-i snatch_1.vob-f avi-vcodec mpeg4-b 800-g 300-bf 2-acodec mp3-ab 128 Snatch.avi

The command line above converts the VOB file into an AVI file, MPEG4 video and MP3 audio. Note that frame B is used in the command, so the MPEG4 stream is divx5 compatible. A GOP size of 300 means that there are intra frames every 10 seconds at 29.97 frame frequencies. This mapping is especially useful when you are in the audio language for DVD transcoding.
Encode into several formats at the same time and create a mapping between the input stream and the output stream
Ffmpeg-i/tmp/a.wav-ab 64/tmp/a.mp2-ab 128/tmp/b.mp2-map 0:0-map 0:0

The command line above converts a 64Kbits a.wav to 128kbits a.mp2 '-map file:index ' defines in the order of output flows which input stream is used for each output stream.
Convert file to 3GP format
Ffmpeg-i test.avi-y-B 20-s sqcif-r 10-acodec amr_wb-ab 23.85-ac 1-ar 16000 test.3gp

Note: If you want to convert to 3GP format, ffmpeg must add –ENABLE-AMR_NB–ENABLE-AMR_WB at compile time, details can refer to: Convert video to 3GPP format
Convert file to MP4 format (support Iphone/itouch)
Ffmpeg-y-I input.wmv-f mp4-async 1-s 480x320-acodec libfaac-vcodec libxvid-qscale 7-dts_delta_threshold 1 output.m P4

Ffmpeg-y-I Source_video.avi input-acodec libfaac-ab 128000-vcodec mpeg4-b 1200000-mbd 2-flags +4mv+trell-aic 2-c MP 2-subcmp 2-s 320x180-title X final_video.mp4

Mix a piece of audio with a video
Ffmpeg-i son.wav-i Video_origine.avi Video_finale.mpg

Convert a video to DVD format
Ffmpeg-i source_video.avi-target pal-dvd-ps 2000000000-aspect 16:9 finale_video.mpeg

Note: Target pal-dvd:output format PS 2000000000 maximum size for the Output file, in bits (here, 2 Gb) aspect 16:9: Widesc Reen
Convert a video to DivX format
Ffmpeg-i video_origine.avi-s 320x240-vcodec msmpeg4v2 Video_finale.avi

Turn X images to a video sequence
Ffmpeg-f image2-i image%d.jpg Video.mpg

Note: This command would transform the images from the current directory (named Image1.jpg, image2.jpg, etc ...) to a File named Video.mpg.
Turn a video to X images
Ffmpeg-i Video.mpg image%d.jpg

Note: This command would generate the files named image1.jpg, Image2.jpg, ...
The following image formats are also AVAILABLES:PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
Screen recording
Use FFmpeg video screen
Ffmpeg-vcodec mpeg4-b 1000-r 10-g 300-vd x11:0,0-s 1024x768 ~/test.avi

: where-VD x11:0,0 refers to the offset used by the recording for X=0 and y=0,-s 1024x768 The size of the recorded video is 1024x768. The recorded video file is Test.avi and will be saved to the user's home directory

If you only want to record an application window or a fixed area on the desktop, you can specify the offset position and the area size. You can use the Xwininfo-frame command to find the above parameters.
Resize Video size
Ffmpeg-vcodec mpeg4-b 1000-r 10-g 300-i ~/test.avi-s 800x600 ~/test-800-600.avi

Note: The FFmpeg screen recording function can only be effective in a Linux environment.
Video capture
Record live video of the camera and save it as a file
Ffmpeg-f video4linux-s 320*240-r 10-i/dev/video0 test.asf

For more information, refer to the discussion post at the FFmpeg Engineering Group Forum: Video capture of FFmpeg
Note: FFmpeg's video capture function can only be used in Linux environment
Use FFmpeg to suppress H.264 video
Ffmpeg-threads 4-i input-r 29.97-vcodec libx264-s 480x272-flags +loop-cmp +chroma-deblockalpha 0-deblockbeta 0-c RF 24

-BT 256k-refs 1-coder 0-me umh-me_range 16-subq 5-partitions +parti4x4+parti8x8+partp8x8-g 250-keyint_min 25-leve L 30

-qmin 10-qmax 51-trellis 2-sc_threshold 40-i_qfactor 0.71-acodec libfaac-ab 128k-ar 48000-ac 2 OUTPUT

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.