Discussion:
[Libav-user] AVPacket::duration from H.264 encoder is zero
Gavin Smith
2018-01-13 22:11:07 UTC
Permalink
I am encoding H.264 and then wrapping it with HLS (ts files) - video only, no audio. To be clear, I'm using the 'avcodec_send_frame'/'avcodec_receive_packet' variation of the API. 
What I have noticed is that the HLSenc  is flooding the log with the warning message ""pkt->duration = 0, maybe the hls segment duration will not precise"'. I've confirmed that the AVPacket received from the encoder has a duration of zero. Even though this is only a warning, I'd like to heed the warning.
The AVCodecContext has a time_base of 1/25 and the AVStream video index has a time_base of 1/90,000. If I set the AVPacket duration to 3,600, the warning disappears; however, I have concerns explicitly setting the duration of each AVPacket explicitly (especially if my life can be made easier by FFmpeg setting it).
1. Should the duration of AVPacket be populated automatically? (Note: The duration is currently _always_ zero). 2. Am I expected to populate the duration myself?3. Is the fact that the duration is being set to zero a symptom of incorrect values in the original AVFrame as passed to the encoder?
Gavin.
asticode
2018-10-19 13:24:05 UTC
Permalink
Hello,

I'm having the same issue using the "libx264" encoder.

Although the frame sent in "avcodec_send_frame" contains a proper duration,
the packets received from "avcodec_receive_packet" is always 0.

Does anybody have an idea?

Should I post this problem elsewhere as well?

Let me know.

Cheers



--
Sent from: http://libav-users.943685.n4.nabble.com/
Yurii Monakov
2018-10-19 17:38:35 UTC
Permalink
Encoders do not use AVFrame duration. Only AVFrame::pts has to be filled.

Yurii
Post by asticode
Hello,
I'm having the same issue using the "libx264" encoder.
Although the frame sent in "avcodec_send_frame" contains a proper duration,
the packets received from "avcodec_receive_packet" is always 0.
Does anybody have an idea?
Should I post this problem elsewhere as well?
Let me know.
Cheers
--
Sent from: http://libav-users.943685.n4.nabble.com/
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
asticode
2018-10-20 08:20:44 UTC
Permalink
Thanks for the reply.

Problem is, how can I know the duration of the last encoded frame then?



--
Sent from: http://libav-users.943685.n4.nabble.com/
Yurii Monakov
2018-10-22 16:43:24 UTC
Permalink
Duration can only be definded as difference in time between two frames. It
is not relevant for single frame.

But if you need some approximation, you can take codec time base.

Yurii
Post by asticode
Thanks for the reply.
Problem is, how can I know the duration of the last encoded frame then?
--
Sent from: http://libav-users.943685.n4.nabble.com/
_______________________________________________
Libav-user mailing list
http://ffmpeg.org/mailman/listinfo/libav-user
Loading...