[Libav-user] Decoding an MPEGTS - can't keep up in realtime

Elijah Brown elijah at ad7zj.net
Fri Mar 13 08:15:37 CET 2015

When I try to open an mpegts stream with av_read_frame on a slow machine,
it runs for a few seconds and then quits:

[mpeg2video @ 0x1b040] mpeg_decode_postinit() failure
[mpegts @ 0x16ea0] Estimating duration from bitrate, this may be inaccurate
Input #0, mpegts, from '/dev/dvb/adapter0/dvr0':
  Duration: N/A, start: 51883.234978, bitrate: 65384 kb/s
    Stream #0.0[0x31]: Video: mpeg2video (Main), yuv420p, 1920x1080 [PAR
1:1 DAR 16:9], 65000 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0.1[0x34]: Audio: ac3, 48000 Hz, 5.1, fltp, 384 kb/s
[mpegts @ 0x16ea0] PES packet size mismatch
[mpeg2video @ 0x1b040] 00 motion_type at 2 3
[mpeg2video @ 0x1b040] Warning MVs not available
[mpeg2video @ 0x1b040] concealing 7800 DC, 7800 AC, 7800 MV errors

The numbers being printed out after the av stream info are approximate
frames/sec I calculate every 10 frames.  My code is based on the dranger
tutorials like this http://dranger.com/ffmpeg/tutorial01.c

On a fast machine this works fine, but on the slower machine it fails like
this after a few seconds.  I'm guessing that's because the device file only
buffers so much and when av_read_frame doesn't keep up with the hardware,
it eventually gets mangled packets and returns < 0.

av_read_frame() can run all day long if I don't try and run the CODECs. The
trick is how to pick and choose when to run avcodec_decode_video2() which
is what consumes CPU.  Is there any way to see when av_read_frame() is
getting behind in reading the device file?   Thanks for any suggestions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20150313/9440e4a1/attachment.html>

More information about the Libav-user mailing list