(often used to ffmpeg to do some video data processing conversion, etc., used to do testing, summed up today, reference to some of the experience of friends on the Internet, together in this summary, there is a need for friends to collect test, there are questions welcome in the following replies exchange, thank you; by Ternence.hsu)
1, FFmpeg use grammar
Command format: ffmpeg-i [input filename] [parameter options]-f [format] [output FILE] ffmpeg [[options]['-i ' input_file]] ... {[options] output_file} ... 1. Parameter options: (1)-an: Remove audio (2)-acodec: Audio options, generally followed by copy to indicate the copy (3)-vcodec: Video options, generally followed by copy to indicate the copy 2. Format: (1) H264: Indicates that the output is h264 video bare stream (2) MP4: Indicates that the output is MP4 video (3) Mpegts: TS video Streaming 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. (by TERNENCE.HSU)
|
2. Video Conversion
H264 Video turn TS video stream
Ffmpeg-i Test.h264-vcodec copy-f Mpegts test.ts
H264 Video transfer mp4
Ffmpeg-i test.h264-vcodec copy-f mp4 test.mp4
TS Video Transfer mp4
Ffmpeg-i test.ts-acodec copy-vcodec copy-f mp4 test.mp4 MP4 video to FLV Ffmpeg-i test.mp4-acodec copy-vcodec copy-f flv test.flv
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
Convert file to 3GP format v2
Ffmpeg-y-I test.wmv-ac 1-acodec libamr_nb-ar 8000-ab 12200-s 176x144-b 128-r
Use ffmpeg encoding to get high quality video
Ffmpeg.exe-i "D:\Video\Fearless\Fearless.avi"-target film-dvd-s 720x352-padtop 64-padbottom 64-maxrate 7350000-b 37 00000-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 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 will convert VOB files into AVI files, 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 in audio language DVD transcoding while encoding into several formats and mapping between input and output streams.
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
(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 out Put.mp4 Ffmpeg-y-I Source_video.avi input-acodec libfaac-ab 128000-vcodec mpeg4-b 1200000-mbd 2-flags +4mv+trell-aic 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
(Target pal-dvd:output format PS 2000000000 maximum size for the Output file, in bits (here, 2 Gb) aspect 16:9: WIDESCR een)
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
(This command would transform all images from the current directory (named Image1.jpg, image2.jpg, etc ...) to a video F Ile named Video.mpg.)
Turn a video to X images
Ffmpeg-i Video.mpg image%d.jpg
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.)
Use FFmpeg video screen (Linux platform only)
Ffmpeg-vcodec mpeg4-b 1000-r 10-g 300-vd x11:0,0-s 1024x768 ~/test.avi
(-vd x11:0,0 refers to the offset used by the recording to be 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, and 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 (Linux platform only)
Ffmpeg-vcodec mpeg4-b 1000-r 10-g 300-i ~/test.avi-s 800x600 ~/test-800-600.avi
Recording the real-time video of the camera and storing it as a file (Linux platform only)
Ffmpeg-f video4linux-s 320*240-r 10-i/dev/video0 test.asf
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-CR F 24-bt 256k-refs 1-coder 0-me umh-me_range 16-subq 5-partitions parti4x4+parti8x8+partp8x8-g 250-keyint_min 25- Level 30-qmin 10-qmax 51-trellis 2-sc_threshold 40-i_qfactor 0.71-acodec libfaac-ab 128k-ar 48000-ac 2 OUTPUT
(Use this directive to compress the H.264 video file which is clearer and the file turns small)
|
3, Network push
Push of UDP video stream Ffmpeg-re-i 1.ts-c copy-f Mpegts udp://192.168.0.106:1234
|
4. Video Stitching
Raw code stream stitching, first splicing naked code flow, and then do the packaging container Ffmpeg-i "concat:test1.h264|test2.h264"-vcodec copy-f h264 out12.h264
|
5, image-related
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
Intercepts a thumbnail of a specified time,-ss followed by a time unit of seconds
Ffmpeg-i test.avi-y-F image2-ss 8-t 0.001-s 350x240 test.jpg
|
6, audio processing
Convert WAV to MP2 format
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 of A.MP2 '-map File:index ' defines in the order of the output stream which input stream is used for each output stream.) ) |
7. Cutting TS Fragment
Ffmpeg-i input.mp4-c:v libx264-c:a aac-strict-2-F hls-hls_list_size 6-hls_time 5 output1.m3u8