Use FFmpeg video format conversion, video capture, video capture, screen recording

Source: Internet
Author: User
FFmpeg is so powerful that you can do your job with a few simple commands.

Put Darkdoor. [001-100].jpg sequence frames and 001.mp3 audio files use MPEG4 encoding to synthesize video files Darkdoor.avi:
$ ffmpeg-i 001.mp3-i darkdoor.%3d.jpg-s 1024x768-author skypp-vcodec MPEG4 Darkdoor.avi

FFmpeg also supports MOV format:
$ ffmpeg-i darkdoor.%3d.jpg Darkdoor.mov

To see which formats your ffmpeg supports, you can use the following command:
$ ffmpeg-formats | Less

You can also export video files to JPG sequence frames:
$ ffmpeg-i Bc-cinematic-en.avi example.%d.jpg

Installing FFmpeg under Debian is simple:
#apt-get Install FFmpeg
Video File screenshotCapture 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 of the-SS followed by the conversion 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:videofearlessfearless.avi"-target film-dvd-s 720x352-padtop
 64-padbottom 64-maxrate 73 50000-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 the FLV format
Ffmpeg.exe -i test.mp3-ab 56-ar 22050-b 500-r 15-s flv 
Ffmpeg.exe -i test.wmv-ab 56-ar 22050-b 500-r 15-s. 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


screen recording using ffmpeg recording 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 to record real-time video of the camera and store it as a file


FFmpeg-  F video4linux-s 320*240-r 10-i/dev/video0  test.asf
Third, the use of FFMEPG


Examples of conversions are shown below:
FFmpeg Howto
Program Download:
Unofficial FFmpeg Win32 Builds (need to use proxy access)
Or:
FFMPEG Full SDK V3.0



The generic syntax is:



ffmpeg [[infile options]['-i ' infile] ... {[outfile options] outfile} ...



As a general rule, options is applied to the next specified file. Therefore, order is important, and can has the same option on the command line multiple times. Each occurrence was then applied to the next input or output file.



* To set the video bitrate of the output file to 64kbit/s:

Ffmpeg-i Input.avi-b 64k Output.avi



* To force the frame rate of the input and output file to FPS:



Ffmpeg-r 24-i Input.avi Output.avi



* To-force the frame rate of the output file to FPS:



Ffmpeg-i Input.avi-r Output.avi



* To force the frame rate of input file to 1 fps and the output file to FPS:



Ffmpeg-r 1-i input.avi-r Output.avi



The format option is needed for raw input files.



By default, FFmpeg tries to convert as losslessly as Possible:it uses the same audio and video parameters for the outputs As the one specified for the inputs.



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.mpeg-ac 1-acodec amr_nb-ar 8000-s 176x144-b 128-r



Convert the specified format file to the FLV format



Ffmpeg.exe-i test.mp3-ab 56-ar 22050-b 500-r 15-s flv
Ffmpeg.exe-i test.wmv-ab 56-ar 22050-b 500-r 15-s flv
***************************************************************************
Ffmpeg-i f:toolsffmpeg.rev10464test.avi-ab 56-ar 22050-b 500-r 15-s. flv
Ffmpeg-i "F:toolsffmpeg.rev10464test. flv"-y-f image2-ss 8-t 0.001-s 350x240" Test.jpg "





Ffmpeg.exe-I F: The song of the Semitic home Flash guest. Mp3-ab 56-ar 22050-b 500-r 15-s.flv
Ffmpeg-i f:01.wmv-ab 56-ar 22050-b 500-r 15-s.flv
Using the-SS parameter function (Time_off set the start time offset), you can start the conversion task from a specified point. Such as:
Convert file formats while grasping thumbnails:
Ffmpeg-i "Test.avi"-y-f image2-ss 8-t 0.001-s 350x240 ' test.jpg '
For existingflvCapture Image:
Ffmpeg-i "Test.flv"-y-f image2-ss 8-t 0.001-s 350x240 ' test.jpg '
The time unit followed by-ss is seconds
FFmpeg conversion Command
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.mpeg-ac 1-acodec amr_nb-ar 8000-s 176x144-b 128-r


FFmpeg parameter Setting explanation
-bitexact using standard bit rate
-vcodec xvid using XviD compression
-S-----
-R 29.97 Frame rate (can be changed to confirm that non-standard frames will cause the tone to be out of sync, so it can only be set to 15 or 29.97)
Screen section, select one
-b < bit rate > Specifies the compression bitrate, it seems that ffmpeg is automatic VBR, specifying the average bit rate, such as 768,1500
is the original default project.
-qscale < values > to < value > mass-based VBR, with a value of 0.01-255, the better the smaller the quality
-qmin < values > set minimum quality, shared with-qmax (set maximum mass), e.g.-qmin 10-qmax 31
-sameq using the same quality as the source
Sound section
-ACODEC AAC Set Sound encoding
-ac < values > Set number of channels, 1 is mono, 2 is stereo, convert mono TVRip can be 1 (save half capacity), high quality
DVDRip can be used for 2
-ar < sample rate > Set sound sampling rate, PSP only 24000
-ab < bit rate > set the sound bit rate, the front-ac is set to stereo at half the bit rate, such as 192kbps is set to 96, conversion
The default bit rate is small, to hear high-quality sound, it is recommended to set to 160kbps (80) or more
-vol < percent > Set volume, some DVDRip AC3 track volume is very small, the conversion can use this to increase the volume, such as 200 is the original twice times
In this way, to get a high-quality sound quality low-capacity MP4, the first picture is best not to use a fixed bit rate, and the VBR parameter to let the program itself
Judgment, and the sound quality parameters can be raised on the original basis, it sounds more comfortable, it will not be too large (see situation adjustment


Example: Ffmpeg-y-i "1.avi"-title "Test"-vcodec xvid-s 368x208-r 29.97-b 1500-acodec aac-ac 2-ar 24000-ab 128-vol 20 0-f psp-muxvb 768 "1.***"

Explanation: The above command can be entered on the DOS command line, or it can be created to run in a batch file. However, the prerequisite is to execute in the directory where the FFmpeg resides (cores subdirectories under the directory where the conversion is located).
Parameters:
-Y (overwrite the output file, that is, if the 1.*** file already exists, overwrite it without prompting)
-I "1.avi" (input file is a 1.avi file with FFmpeg in the same directory, you can add the path, change the name)
-title "Test" (title of the movie shown in the PSP)
-vcodec XviD (compressed video using XviD encoding,can'tChange)
-S 368x208 (output resolution is 368x208, note that the source must be 16:9 or deformation)
-R 29.97 (frame number, usually use this bar)
-B 1500 (video data traffic, with-b xxxx command is used fixed code rate, the number of random change, more than 1500 no effect; You can also use dynamic bitrate such as:-qscale 4 and-qscale 6,4 of the mass ratio of 6 high)
-acodec AAC (audio codec with AAC)
-ac 2 (number of channels 1 or 2)
-ar 24000 (sound sampling frequency, as if the PSP can only support 24000Hz)
-ab 128 (audio data flow, 32, 64, 96, 128 general selection)
-vol 200 (200% of the volume, self-change)
-F PSP (output PSP private format)
-muxvb 768 (seems to be to the PSP machine recognition of the bitrate, generally choose 384, 512 and 768, I changed to 1500,PSP said the file is damaged)
"1.***" (output file name, can also add path to file name)

If the machine is strong, you can open several batch files and let them work in parallel.

===========================================
Ffmpeg.exe-I F: The song of the Semitic home Flash guest. Mp3-ab 56-ar 22050-b 500-r 15-s.flvFfmpeg-i f:01.wmv-ab 56-ar 22050-b 500-r 15-s.flvUsing the-SS parameter function (Time_off set the start time offset), you can start the conversion task from a specified point. Such as:
Convert file formats while grasping thumbnails:
Ffmpeg-i "Test.avi"-y-f image2-ss 8-t 0.001-s 350x240 ' test.jpg '
For existingflvCapture Image:
Ffmpeg-i "Test.flv"-y-f image2-ss 8-t 0.001-s 350x240 ' test.jpg '
-ss the time unit followed by the seconds ffmpeg conversion command
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.mpeg-ac 1-acodec amr_nb-ar 8000-s 176x144-b 128-r all test.3gp ffmpeg parameter setting explanation
-bitexact using standard bit rate
-vcodec xvid using XviD compression
-S-----
-R 29.97 Frame rate (can be changed to confirm that non-standard frames will cause the tone to be out of sync, so it can only be set to 15 or 29.97)


Screen section, select one
-b < bit rate > Specifies the compression bitrate, it seems that ffmpeg is automatic VBR, the specified is about the average bitrate, such as 768,1500 is the original default project has
-qscale < values > to < value > mass-based VBR, with a value of 0.01-255, the better the smaller the quality
-qmin < values > set minimum quality, shared with-qmax (set maximum mass), e.g.-qmin 10-qmax 31
-sameq use and source the same quality sound part
-ACODEC AAC Set Sound encoding
-ac < values > Set number of channels, 1 is mono, 2 is stereo, convert mono TVRip can use 1 (save half capacity), high-quality DVDRip can use 2
-ar < sample rate > Set sound sampling rate, PSP only 24000
-ab < bit rate > set the sound bit rate, the front-ac set to stereo in half bit rate to set, such as 192kbps is set to 96, conversion June default bit rate is small, to hear the high quality sound, it is recommended to set to 160kbps (80) or more
-vol < percent > Set volume, some DVDRip AC3 track volume is very small, the conversion can use this to increase the volume, such as 200 is the original twice times so, to get a high-quality sound quality low-capacity MP4, the first screen is best not to use a fixed bit rate, And with the VBR parameter let the program itself to judge, and the sound quality parameters can be improved on the original basis, it sounds to be more comfortable, not too big (see case Adjustment Example: ffmpeg-y-i "1.avi"-title "Test"-vcodec xvid-s 368x208-r 2 9.97-b 1500-acodec aac-ac 2-ar 24000-ab 128-vol 200-f psp-muxvb 768 "1.***"

Explanation: The above command can be entered on the DOS command line, or it can be created to run in a batch file. However, the prerequisite is to execute in the directory where the FFmpeg resides (cores subdirectories under the directory where the conversion is located).
Parameters:
-Y (overwrite the output file, that is, if the 1.*** file already exists, overwrite it without prompting)
-I "1.avi" (input file is a 1.avi file with FFmpeg in the same directory, you can add the path, change the name)
-title "Test" (title of the movie shown in the PSP)
-vcodec XviD (compressed video using XviD encoding,can'tChange)
-S 368x208 (output resolution is 368x208, note that the source must be 16:9 or deformation)
-R 29.97 (frame number, usually use this bar)
-B 1500 (video data traffic, with-b xxxx command is used fixed code rate, the number of random change, more than 1500 no effect; You can also use dynamic bitrate such as:-qscale 4 and-qscale 6,4 of the mass ratio of 6 high)
-acodec AAC (audio codec with AAC)
-ac 2 (number of channels 1 or 2)
-ar 24000 (sound sampling frequency, as if the PSP can only support 24000Hz)
-ab 128 (audio data flow, 32, 64, 96, 128 general selection)
-vol 200 (200% of the volume, self-change)
-F PSP (output PSP private format)
-muxvb 768 (seems to be to the PSP machine recognition of the bitrate, generally choose 384, 512 and 768, I changed to 1500,PSP said the file is damaged)
"1.***" (output file name, can also add path to file name)

P.s. If the moderator machine is strong, you can open several batch files and let them work in parallel. E:Ffmpeg.exe-I i:1.wmv-b -r 25-s 320x240-hq-deinterlace-ab 56-ar 22050-ac

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.