Summary of the work in the past few days ffmpeg

Source: Internet
Author: User

Summary of the work over the past few days
BY xiaoxiongli

In the past few days, ffmpeg is primarily used to compress the original audio streams and video streams. The video stream format is gbr24, and the audio stream format is pcm.
It is compressed into the format described in geuss_format ("avi"). Without looking at this function carefully, it is probably because the video data is compressed into mpeg4,
Look at the binary data. The keyword seems to be FMP4. Audio Compression into mp2/mp3? I don't know whether it is 2 or 3. Well, it should be 3.

The video compression was very smooth. After the code was written, it was good to compile and run it directly. However, gbr was converted into rgb, and the color was incorrect. It would be nice to change it.

However, the audio in the avi file is terrible. It's only about 1 second of audio, and it's just as fast as it is. I can't hear it clearly.

Why?
At last, lsosa broke through the xuanjicang: Some of the audio data was lost.

So I used the method of compressing only the video without compressing the audio, which is normal. (You need to increase the output buf size according to your own needs !!!)

Then I am excited to increase the size of the out buf and then ××. The result is not improved.

Then I monitored pts and found it in output examples. In c, the value is always increased until 5, while in my program, the value is always zero. (I still don't know what the problem is up to now ???, Which function controls the increase of pts ???)

The result was changed for half a day, and pts still had no texture.

Accidentally monitored the pkt. The size is only 209 bytes. I thought about it carefully. The compression ratio of mp3 is, but my data is 44100 × 2 × 2. In this case, the compression ratio is more than 800, obviously there is a problem.

Find the cause and start to find a solution:
1: Modify c-> frame_size To Make It 44100. (1152 originally)
Failed

2: Why is it 1152? The FFMPEG system does not seem to allow non-1152 MP3 encoding?
After reading MP3 related information, I got the answer: "The audio data put into MP3 is divided into frames, each frame contains 1152 sample data ,......", I finally understood the concept of audio frames. It was hard to understand this concept for a long time.

How can I modify it?
I thought of two methods:
Add a loop when saving the AVI file. The 38 cycles are exactly 1 s of audio data, 1152 × 38 = 44100.
As a result, I tried this and found that the audio was incorrect during decoding. The audio was blurred and I could only hear the sound. Failed
The storage format is as follows: vvvvvvvvvvvvvvvvvvvvvvvavvvvvvvvvvvvvvvvvvvvvvvvvvvvvav

Directly press 1152 as one frame for storage, that is, avavaav... After a try, everything works normally.

Todo:
Find out why PTS is always 0;
Try to send the compressed AVI file over the network to achieve VOD-like effect.
Use QT to create an interface.
Try to transplant it to the embedded system.

It's time to be busy.

Thanks to admin and lsosa

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.