Discussion:
[Libav-user] hardware encoding on Raspberry Pi using Openmax has issue of time stamp
Jinbo Li
2018-11-19 18:14:45 UTC
Permalink
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)

Regards,
Jinbo Li
Mark Thompson
2018-11-19 19:59:09 UTC
Permalink
Post by Jinbo Li
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.
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);
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
Jinbo Li
2018-11-19 21:25:44 UTC
Permalink
Hello Mark,

It works. Thanks a lot.

Regards,
Jinbo Li

----- Message original -----
De: "Mark Thompson" <***@jkqxz.net>
À: "libav-user" <libav-***@ffmpeg.org>
Envoyé: Lundi 19 Novembre 2018 14:59:09
Objet: Re: [Libav-user] hardware encoding on Raspberry Pi using Openmax has issue of time stamp
Post by Jinbo Li
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.
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);
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
_______________________________________________
Libav-user mailing list
Libav-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/libav-user

Loading...