Libav (FFMPEG) Concise tutorial (2)

Source: Internet
Author: User

More than a month has passed since the last tutorial. I believe everyone has completely digested what I mentioned in the previous lesson.

In this lesson, let's talk about how to use libav commands.

Note: If you do not understand or do not mention this article, you can use the command plus -- help full or man command (man avconv) to view all the parameter details, or go to the libav.org site to query: https://libav.org/avconv.html

Killer command: avconv:

I personally think that his most powerful function is to provide a wide range of support for various formats. If you have it, you can discard software such as a format factory on Windows, it supports all your popular media files on the market.

The simplest conversion format command example (convert src.avifile to dst.mp4 in mp4format): avconv-I SRC. Avi dst.mp4

If you want to output each frame of the video as an image sequence and save it to the disk, enter avconv-I SRC. Avi dst_mongod.jpg.

Otherwise, if you have an image sequence (such as src_0.jpg, src_1.jpg, src_2.jpg...) that is properly specified, you can also input and export it to the final video: avconv-I src_1_d.jpg dst_mp4.

In addition to the video and image sequence in the file, you can also use the RTSP network video as the parameter avconv-I RTSP.: // Hostname [: Port]/path dst.mp4

If you want to scale down the video size (convert the video to dst.mp4 and reset the resolution to 320x240), the length and width pixel numbers must be an even number and greater than 100 at the same time, and you can also enter characters such as 720 p and P: avconv-I SRC. avi-s 320x240 dst.mp4

If you want to convert the original video from the first 6 seconds, enter avconv-SS 00:00:00-T 00:00:06-I SRC. Avi dst.mp4.

To modify the bite rate of the original video, use the-R parameter avconv-I SRC. Avi-r 2397600 dst.mp4.

Similarly, the audio in the original video also needs to change the sample rate. Use avconv-I SRC. Avi-F-sample_rates 128000 dst.mp4.

To redefine pixel formats, use the-pix_fmt parameter (Note: it must be the pix_fmts supported by this file format): avconv-I SRC. Avi-pix_fmts av_pix_fmt_yuv420p dst.mp4

Similarly, if the audio needs to be reset by sample_fmts, use the-sample_fmts parameter and the format supported by the output file format to succeed: avconv-I SRC. Avi-sample_fmts av_sample_fmt_fltp dst.mp4.

Careful people will find that the above command modifies the sample rate to include more-F. In fact,-F indicates filter, which is another very powerful tool of libav, each time you open the libav source file or the official website, you will find many novel filter-related parts.

The following is a simple example:

Avconv-I SRC. Avi-F clock dst.mp4 rotating video 90 degrees clockwise is so easy! More detail

Libav also implements and supports SAP (Session announcement Protocol),

You can run the following command: avconv-re I SRC. avi SAP: // 0.0.0.0. When playing a video, use the avplay command to directly bring SAP: // localhost to play the video, or use VLC player to directly open the network address to play the video. Is it powerful?

Libav also references another powerful library, frei0r, which is a library for video special effect processing written in C, you only need to specify a few simple parameters to achieve the powerful effect. Although I have not really tested it yet, if you are interested, you can play it and check the reply below.

In addition, as a mature video library, how does it lack support for the RTSP protocol?

Create an RTSP server and run the command avserver-F avserver. conf.

Avserver. conf is a text file. You must write the content as follows:

Port 8848RTSPPort 8840BindAddress 0.0.0.0MaxClients 100MaxBandwidth 1000000CustomLog connlogs.txt<Stream test.html>File "fsbk.flv"Format flv</Stream><Stream status.html>Format status</Stream>

Is it quite simple? If you find the port is occupied, enter sudo Fuser-K 8848/TCP and sudo Fuser-K 8840/tcp to kill the corresponding process. Then execute avplay http: // localhost: 8848/test.html and the video will be transmitted over the network, right? That's easy, right ~

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.