[Ffmpeg-devel] timestamps in video

Tomas Carnecky tom
Sun Apr 30 02:00:41 CEST 2006

I have an application that captures frames at any rate, it saves the
encoded frame along with a timestamp (as provided by gettimeofday) in my
own file format. I have a second application that converts the stream
into and AVI file and another application that decodes the frames
directly from my file.
My timestamp resolution is microseconds (1/1000000 second), and I've tried:

AVCodecContext *c;
c->time_base.den = 1000000;
c->time_base.num = 1;

but that doesn't work always. For example when I use the xvid codec, I
have to multiply the timestamps in the frame packets by 100 (not sure
anymore), otherwise the video will play too fast in mplayer. But it
works fine when I use:

c->time_base.den = 100;
c->time_base.num = 1;

Is the framerate limited somehow?

Also when I use a high enough value for '.den', the application that
converts the stream into AVI hangs somewhere.. it just doesn't finish,
here is the stream info and a trace:

Output #0, avi, to '/home/tomc/yukonOutput/2006-04-30--01:51:17.avi':
  Stream #0.0, 1000000.00 fps(c): Video: ffv1, yuv420p, 640x512, q=2-31,
400 kb/s

Program received signal SIGINT, Interrupt.
0x00002ba267dcca10 in __write_nocancel () from /lib/libpthread.so.0
(gdb) bt
#0  0x00002ba267dcca10 in __write_nocancel () from /lib/libpthread.so.0
#1  0x00002ba2682f81f0 in url_fopen () from /usr/lib/libavformat.so.50
#2  0x00002ba2682f6fd2 in init_put_byte () from /usr/lib/libavformat.so.50
#3  0x00002ba2682f7019 in put_flush_packet () from
#4  0x00002ba2682d13b4 in codec_get_bmp_id () from
#5  0x00002ba2682d124a in codec_get_bmp_id () from
#6  0x00002ba2682c0b82 in av_write_frame () from /usr/lib/libavformat.so.50
#7  0x0000000000401a63 in main ()

any idea what may cause this?

oh.. and because libavcodec's imgconvert and imgresample seemed too slow
for me, I've written my own mmx-optimized functions for scaling
(simplest case, scale to 50%) and conversion from ARGB to YUV420P (only
pot images), these functions are 20-40% faster than those from
libavcodec. If anyone is interested I can share the code with you.


More information about the ffmpeg-devel mailing list