[Libav-user] examples/demuxing.c not working properly

Chandranath Bhattacharyya cbhattac at adobe.com
Mon Oct 15 11:26:49 CEST 2012

Hi All,

I downloaded windows ffmpeg build from http://ffmpeg.zeranoe.com/builds/. The build downloaded is ffmpeg-20121009-git-f3f35f7-win32-shared.7z & ffmpeg-20121009-git-f3f35f7-win32-dev.7z.

I built "examples/demuxing.c" using Visual Studio 10 on windows. However, it's not working. When invoked with command line: <exename> output.mp4, it's exiting with the following errors:

[mp4 @ 00582ea0] Encoder did not produce proper pts, making some up.
[mp4 @ 00582ea0] pts (0) < dts (1) in stream 0
Error while writing video frame

I figured out that av_interleaved_write_frame is failing because a call to avcodec_encode_video2 is not changing AVCodecContext::coded_frames->pts. It's always 0, and hence AVPacket.pts is 0. However the call to avcodec_encode_video2 is increasing the AVPacket.dts value from -2, -1, 0, 1. So in 4th call to av_interleaved_write_frame, AVPacket.pts < AVPacket.dts causing the issue.

I made some code changes to ensure that pts > dts, and then the file was written. However when opened in Windows Media Player Classic, the file is showing a frame rate of 12800.

I was using following. Modified STREAM_DURATION to 10.0 from 200.0.
#define STREAM_DURATION   10.0
#define STREAM_FRAME_RATE 25 /* 25 images/s */

With these parameters, AVStream::codec->time_base = { num: 1, den: 25}, but just after call to avformat_write_header, the AVStream::time_base = { num: 1, den: 12800 }.

What's going wrong? AVStream::time_base.den = 12800; seems to be wrong data. Other than fixing some compilation errors, I did not modify anything else in examples/demuxing.c.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20121015/6e35c9d1/attachment.html>

More information about the Libav-user mailing list