Introduction and use of Linux ffmpeg commands

Source: Internet
Author: User

ffmpeg using Syntax
ffmpeg [[options]['-i ' input_file] ... {[options] output_file} ...  

If there is no input file, then AV Capture (only works under Linux, because the audio and video device is handled as a file handle under Linux) will work. As a general rule, options are typically used for the next specific file. If you give the –B 64 option, the re-election will set the next video rate. For the original input file, the format option may be required. By default, FFmpeg attempts to convert as much as possible, using the same audio video parameters as the input output.


There are many options involved in ffmpeg conversion, so refer to the FFmpeg option.


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

Video Files
    • Capture a 352x240 size, JPG-formatted picture
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  
    • To intercept a thumbnail of a specified time
Ffmpeg-i test.avi-y-F image2-ss 8-t 0.001-s 350x240 test.jpg  
the time unit followed by-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.3 Gp  
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 get high-quality video using FFMPEG encoding
Ffmpeg.exe-i "D:\Video\Fearless\Fearless.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:\Video\ffmpegencode"-an-f mpeg2video "D:\FEARLESS.M2V"  
    • Convert the specified format file to the FLV format
Ffmpeg.exe-i test.mp3-ab 56-ar 22050-b 500-r 15-s f:\test.flv ffmpeg.exe-i test.wmv-ab 56-ar 22050-b   500-r 15-s f:\test.flv  
    • Transcoding and decrypting VOB
Ffmpeg-i snatch_1.vob-f avi-vcodec mpeg4-b 800-g 300-bf 2-acodec mp3-ab  
The above command lines the VOB files into AVI files, MPEG4 video and MP3 audio. Note that B-frames are used in the command, so the MPEG4 stream is divx5 compatible. A GOP size of 300 means that there are intra frames at 29.97 frames per 10 seconds. This mapping is especially useful for DVD transcoding of audio languages.
    • Encode into several formats simultaneously and establish mappings 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 above command line converts a 64Kbits a.wav to 128kbits a.mp2 '-map file:index ' defined in the order of the output stream which one 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 be –ENABLE-AMR_NB–ENABLE-AMR_WB at compile time, for more information: 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-a IC 2-cmp 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, with bits (here, 2 Gb) aspect 16:9: Widescreen
    • 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 all the images from the current directory (named Image1.jpg, image2.jpg, etc ...) to a Video 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 is also AVAILABLES:PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI.
Screen Recording
    • Using the FFmpeg video screen
Ffmpeg-vcodec mpeg4-b 1000-r 10-g 300-vd x11:0,0-s 1024x768 ~/test.avi  

: Wherein,-VD x11:0,0 refers to the recording using an offset of x=0 and y=0,-s 1024x768 refers to the size of the recorded video as 1024x768. The recorded video file is Test.avi and will be saved to the user's home directory

if you want to record only one application window or a fixed area on the desktop, you can specify the offset position and the area size. Use the Xwininfo-frame command to complete the lookup of 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: FFmpeg's screen recording function is only available in Linux environments.
Video Capture
    • Record the camera's live video 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 of the FFmpeg Engineering Group Forum: Video capture for FFmpeg
Note: The FFmpeg video capture function can only be used in Linux environments
using ffmpeg to suppress the video of H .
Ffmpeg-threads 4-i input-r 29.97-vcodec libx264-s 480x272-flags +loop-cmp +chroma-deblockalpha 0-deblockbeta 0-c RF   -BT 256k-refs 1-coder 0-me umh-me_range 16-subq 5-partitions +parti4x4+parti8x8+partp8x8-g 250-keyint_mi n 25-level   -qmin 10-qmax 51-trellis 2-sc_threshold 40-i_qfactor 0.71-acodec libfaac-ab 128k-ar 48000-ac 2 OUTPUT  
Note: The use of this directive can compress the clearer, and the file to a small size of the video file

Introduction and use of Linux ffmpeg commands

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.