[Libav-user] hardware encoding on Raspberry Pi using Openmax has issue of time stamp

Mark Thompson sw at jkqxz.net
Mon Nov 19 21:59:09 EET 2018


On 19/11/18 18:14, Jinbo Li wrote:
> Hello,
> 
> Hello, I have an issue on implementing hardware encoding on raspberry pi by using openmax. The problem is that I always get wrong time stamp in my AVpacket even right after it gets initialized, the time stamp was always assigned to be 634 (seems to be the numerator of time base) and it does not change overtime. I have run this code on my another Ubuntu laptop, it doesn't have this issue for the printf.
> 
> code:
> 
> AVPacket pkt;
> printf("0-time stamp = %ld, enc = %d/%d st = %d/%d\n", pkt.pts,
>             encoder_ctx->time_base.num,encoder_ctx->time_base.den,
>             fmt_encoder_ctx->streams[video_stream]->time_base.num,
>             fmt_encoder_ctx->streams[video_stream]->time_base.den);
> printf("avframe time stamp = %ld\n", sw_frame->pts);
> av_init_packet(&pkt);
> printf("1-time stamp = %ld, enc = %d/%d st = %d/%d\n", pkt.pts,
>             encoder_ctx->time_base.num,encoder_ctx->time_base.den,
>             fmt_encoder_ctx->streams[video_stream]->time_base.num,
>             fmt_encoder_ctx->streams[video_stream]->time_base.den);
> 
> result:
> 
> 0-time stamp = 634, enc = 1907363872/0 st = 634/19001
> 1-time stamp = 634, enc = 0/-2147483648 st = 634/19001
> ...(the printed time stamp is always 634 below)

The timestamp is not a long, so you're invoking undefined behaviour and the printed numbers are meaningless.  You want PRId64 for printing timestamps.

- Mark


More information about the Libav-user mailing list