Opened 3 years ago

Last modified 3 years ago

#8993 new defect

vaapi_encode.c example makes the invalid stream

Reported by: Wohlstand Owned by:
Priority: minor Component: documentation
Version: git-master Keywords: vaapi
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hello!
Some time ago I made use of VAAPI encoder through latest FFMPEG (for the use with RTSP server to stream the video) and using Intel GPU. That worked, however, after some time my boss was found that the result is messy: dozen frames got lost, the VLC player reports a missings of frames.

What the reason of such mess? I had to use the code of vaapi_encode.c example. Then, I did a test, and the example itself makes the same messy result as in my code. I will include the set of files.

The processor I have at me is "Intel(R) Core(TM) i3-8109U CPU @ 3.00GHz". This mess appears on any other processors also.

Is this a bug of software, or it's the VAAPI itself is messy? I use Ubuntu 20.04 with all libraries from the repository. The FFMPEG and libraries I built from the sources by myself.

Change History (5)

comment:1 by Wohlstand, 3 years ago

I share the set of files:

https://yadi.sk/d/9igsI_2lnwAL2Q

  • 03082013354.mp4 - original video
  • 03082013354.yuv.lzma - complressed raw uncompressed NV12 YUV stream
  • 03082013354.h264 - the result of encoding

The original video has 27 fps. The encode was done with 25 fps, but, that does't matter, because I have the literal loss of frames while playing the video, the VLC tells that I lost the almost half of frames while playing.

I used the original doc/examples/vaapi_encode.c example to process the video. the YUV stream I made with the console ffmpeg.

comment:2 by Wohlstand, 3 years ago

At me the libva 1.7. I will try how it will work with the latest libva.

comment:3 by Carl Eugen Hoyos, 3 years ago

Component: avcodecdocumentation
Keywords: encode removed
Priority: importantminor

comment:4 by Wohlstand, 3 years ago

Okay, I did the investigation (I spent a week), and I found the true reason: to fix the problem, it's need to always add the pts counter and iterate it by self:

`
static int64_t pts_counter = 0;
...

frame->pts = pts_counter++;
...
`
So, it's need to fix the example until close this issue.

Another my mistake that I had to unite two packets, sometimes given by the encoder from the one frame, and sent it into RTSP server (that worked at the separated application and had to receive video through the FIFO pipe). I must to send every packet independently.

comment:5 by wenbin,chen, 3 years ago

Hi Wohlstand:

The vaapi_encode.c encode raw video so it doesn't know the origin video's parameter. Developer should set them manually.
For fps 27 -> fps 25 question, you can edit vaapi_encode.c here:
https://github.com/FFmpeg/FFmpeg/blob/a52b9464e4238b41484daecd60c6dc77115e2676/doc/examples/vaapi_encode.c#L150

For pts problem: you should set pts on the base of timebase. pts can be set even or uneven, and lack of pts should be treated as being played even according to fps.

By the way, vaapi_encode.c is an example to show how to use vaapi, so it is hard for it to be compatible with different situation.

Any question is welcome
thanks

Note: See TracTickets for help on using tickets.