[FFmpeg-devel] Timestamp issues in live RTP->mpegts bridges

Luca Abeni lucabe72
Mon Jan 19 19:34:13 CET 2009

> The ffmpeg program:
> Streaming:
>   ./ffmpeg -i /tmp/video/h263.sdp -vcodec mpeg2video -an -f mpegts 
> udp://localhost:9999\?pkt_size=1316
> (as you can guess the udp pkt_size is here to clip on an integer number 
> of TS packets (188 bytes) is case a PESpacket is larger than MTU).
> To file:
>   ./ffmpeg -i /tmp/video/h263.sdp -vcodec mpeg2video -an -f mpegts out.ts
> The output of ffmpeg is:
> Input #0, sdp, from '/tmp/video/h263.sdp':
>    Duration: N/A, bitrate: N/A
>      Stream #0.0: Video: h263, yuv420p, 176x144 [PAR 12:11 DAR 4:3], 
> 29.97 tb(r)

Looks like for some reason the H.263 stream is detected as 29.97 fps.
Now, I do not know why this is happening: it can be due to the timestamp 
issue you noticed, or to something else... Can you dump the H.263 
bitstream to a file (with vcodec copy) and then do "ffmpeg -i" on that 
file and post the result?

> Also I'm getting lots of repeated errors like this:
>   [mpegts @ 0x93a3c00]dts < pcr, TS is invalid

This is an issue with the TS muxer

>> I think the rtpdec.c code already reads the timestamps in the correct way
>> (and I do not think timestamps need to be handled in a payload-specific way).
>> Just ensure that after your H.263 modifications finalize_packet() is still
>> called.
> Wow !!! It seems that in rtpdec.c, as soon as we have a dynamic 
> depayloader (same for h264), then the ->parse_packet is called but *not* 
> finalize_packet ...
> Am I dreaming ?
>      } else if (s->parse_packet) {
>          rv = s->parse_packet(s->dynamic_protocol_context,
>                               s->st, pkt, &timestamp, buf, len, flags);
>      } else {

Uh... Looks like you found a bug ;-)
Yes, the dynamic payload stuff looks broken...
Try moving finalize_packet() out of the else block and see if it fixes 


More information about the ffmpeg-devel mailing list