Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use FFmpeg for video format conversion

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to use FFmpeg for video format conversion, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!

Fmpeg is the leading multimedia framework that can decode, encode, transcode, mix, decrypt, stream, filter and play almost everything created by humans and machines. It supports the most obscure ancient formats, up to the most cutting-edge formats.

Example

Flac format to mp3

Audio format conversion is very simple:

Ffmpeg-I input.flac-acodec libmp3lame output.mp3

Ffmpeg will use the libmp3lame decoder to convert the input.flac file to an output.mp3 file in mp3 format.

Batch format conversion

It is also a common requirement to convert flac files in batches, which can be done with the bash command:

Find. -name "* .flac"-exec bash-c 'ffmpeg-I "{}"-y "${0/.flac} .wav"' {}\

Webm to gif format

Webm is a multimedia file format proposed by Google, which includes VP8 movie tracks and Ogg Vorbis audio tracks, and is open source according to BSD format. Webm can provide higher quality online video, but its support is not as good as the long-standing mp4 and dynamic picture format gif, so there is sometimes a need to convert it to gif format. The orders we use are:

Ffmpeg-I input.webm-vf "scale=400:-1,fps=10" output.gif

Its function is to convert the video in input.webm format into an output.gif picture with a horizontal width of 400px and a vertical width of 10 frames per second.

Of course, you can also convert gif to webm format:

Ffmpeg-I output.gif-CVR v libvpx-auto-alt-ref 0 input.webm

If there is a "Unknown encoder libvpx" problem, you need to recompile and install ffmpeg to support the libvpx encoder:

Brew reinstall ffmpeg-with-libvpx

Convert to mp4 format:

Ffmpeg-I input.webm-vf "scale=trunc (iw/2) * 2:trunc (ih/2) * 2" output.mp4

The meaning of the vf parameter here is to convert the length and width of the video to an even number, otherwise you may encounter the problem of "width not divisible by 2".

Generate video thumbnails

Generate a cover

Use the first frame of the video as the cover:

Ffmpeg-I your-video.mp4-ss 00:00:00-vframes 1 thumb.png

Generate a thumbnail every xx second

One per minute:

Ffmpeg-I your-video.mp4-vf fps=1/60 your-video-d.png

Then merge it:

Ffmpeg-I your-video-d.png-filter_complex scale=-1:-1,tile=99x1:margin=10:padding=4 output.png

The tile length here is set to 99, which should be changed to the total number of thumbnails.

One step at a time:

Ffmpeg-ss 00:00:00-I your-video.mp4-vf 'select=not (mod (n\, 24)), scale=-1:-1,tile=99*1' out.png

It means that starting from 00:00:00 in the video, every 24 frames (usually 24 frames), a picture is taken, the length and width are not compressed, and finally combined in the box 99: 1.

The above is all the contents of the article "how to use FFmpeg for video format conversion". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report