简体   繁体   中英

ffmpeg - mpeg4 (H.264) timestamps and picture quality

I have major problems with ffmpeg library.
First, timestamps are arriving in some sort of random order.
For example, when decompressing, timestamp 8000 is before 4000 and so on. If I ignore these time stamps and just play the video, I can see that frames are really arriving in random order. So, the first question would be how to handle that? Is that normal? I don't really understand how is that possible at all.

Question nubmer two..
Picture quality is so bad. It looks like it requires anti-aliasing. VLC plays the same clip with proper frame order and much better picture quality.

Color format in my application is standard YV12 (I didn't convert it after decompressing) and it's being rendered by Video Mixing Renderer 9 filter.

(Is ffmpeg so bad, or do I have to develop some extra skills just to get the frame with it?)

I believe the problem with the timestamps is that when the video contains B-frames (bidirectionally predicted), the frames occur in the bitstream out of their display order. Because of this, you have to take special care when determining the PTS of a decoded frame. Take a look at this page of a good ffmpeg tutorial and see how they handle this problem.

Basically, you need to store the PTS value of the first packet for each decoded frame. The PTS value in the AVFrame structure after decoding is not valid.

As for the quality issues, this may or may not be related to the timestamp issues, but I can assure you that the problem is almost definitely not with the ffmpeg libraries themselves as they are widely used and may even be used as a backend by VLC when decoding your video.

I would look at the tutorial and implement things exactly like it just to see if you can get it to work, then modify the tutorial code to fit your needs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM