Frame generation video command:
ffmpeg -threads 2 -y -r 24 -i %05d.jpg output.mp4
Video generation frame command (generate pictures by frame):
ffmpeg -i checkpoints_dstt_car-turn_result.mp4 chaifen/%06d.png
1. Download the ffmpeg installation package
https://github.com/BtbN/FFmpeg-Builds/releases
Unzip the file, enter the bin directory , and you can see three files: ffmpeg.exe, ffplay.exe, and ffprobe.exe. Leave it alone and go to the next step.
2. Set environment variables
Click "System Properties->Advanced System Settings->Environment Variables->User Variables", select the "Path" entry , click "Edit->New", copy and paste the bin folder path in the first step , and then click OK Can.
We open the cmd command line window and enter the command " ffmpeg --version ". The window returns the version information of ffmpeg, indicating that the installation is successful. Next, you can directly use the command line to execute the ffmpeg command to convert various media formats.
3. The use of ffmpeg
The first thing to do is to calculate the total number of frames in the video:
Total frames = duration * fps .
duration is the length of the video we set, and fps is the number of frames per second of the video.
The second step is to put all the image files in a temporary directory, and formulate a naming rule (regular):
for example, the material of the image is image0.jpg image1.jpg image2.jpg
Then you can execute the command to synthesize the video: (simple version)
ffmpeg -threads 2 -y -r 24 -i %05d.jpg output.mp4
With audio:
ffmpeg -threads 2 -y -r 10 -i /tmpdir/image%04d.jpg -i audio.mp3 -absf aac_adtstoasc output.mp4
Explanation of parameters:
- -threads 2 Runs in two threads to speed up processing.
- -y overwrite the output file
- -r 10 fps is set to 10 frames per second (different positions have different meanings, which will be explained later)
- -i /tmpdir/image%04d.jpg input image file, the image file is saved as image0001.jpg image0002.jpg ….
- -i audio.mp3 input audio file
- -absf aac_adtstoasc This option is required to convert the resulting audio format to faac format. Converting the audio format to faac is because some audio format videos cannot be played on the iphone, such as mp3. But the faac format audio video can be played on the iphone. -absf means to set a bitstream filter to do some conversion. You can view all supported bitstream filters with ffmpeg -bsfs. I can't tell the specific meaning of bitstream filter and aac_adtstoasc. However, if this option is not used, the conversion will fail.
Without audio:
ffmpeg -loop 1 -f image2 -i /tmpdir/image%04d.jpg -vcodec libx264 -r 10 -t 10 test.mp4
- -loop 1 loop read input 0 and don't read it after reading
- -vcode encoding format libx264
- -b specifies 200k bit rate
- -t Output total video duration:
In this way, you can generate a video by running the command;
ffmpeg detailed installation tutorial, pro test is effective! - Know almost