[FFmpeg-devel] Data stream causes FPE on av_write_trailer()

Trammell Hudson hudson
Wed Sep 19 17:38:55 CEST 2007


I'm trying to add a telemetry data stream to an MPEG4 similar to
what Michel Bardiaux was doing in 2006, but am getting a floating
point exception when my code calls av_write_trailer().  It appears
that mov_write_trailer calls av_rescale_rnd with a timescale of 0:

	av_rescale_rnd(
		mov->tracks[i].trackDuration,
		globalTimescale,
		mov->tracks[i].timescale,
		AV_ROUND_UP
	);

Looking at the mov structure I see that my MPEG stream has
a timescale of 12, while my data stream has a timescale of 0.

I created the data stream with:

        this->av_odata = av_new_stream( this->av_oc, 0 );
        AVCodecContext * odc = this->av_odata->codec;
        odc->codec_type                 = CODEC_TYPE_DATA;
        odc->codec_id                   = CODEC_ID_NONE;
	odc->codec_tag			= MKTAG( 'r', 'o', 't', 'o' );
        odc->bit_rate                   = 9600;
        odc->time_base.num              = 1;
        odc->time_base.den              = 4;

Since there is no codec, I do not call avcodec_open().

The data packets are written to the AVFormatContext * this->av_oc
with this code:

	AVPacket pkt;
        av_init_packet( &pkt );

        pkt.pts = av_rescale_q(
                ++this->last_pts,
                this->av_odata->codec->time_base,
                this->av_odata->time_base
        );

        pkt.stream_index = this->av_odata->index;
        pkt.data = buf;
        pkt.size = len;

        av_write_frame( this->av_oc, &pkt );

dump_format on the output reports:

Output #0, mp4, to '/tmp/test.035.mp4':
  Stream #0.0, 1/90000: Data: roto / 0x6F746F72, 9 kb/s
  Stream #0.1, 1/90000: Video: mpeg4, yuv420p, 352x240, 1/12, q=2-31, 1200 kb/s, 12.00 fps(c)

If I do not write any data packets, only MPEG packets, the file
is closed successfully and the resulting mp4 file plays without
any problems.  Do I need to do something to set the timebase for
the stream or write the data packets in a different way?

Thanks for any suggestions!
-- Trammell




More information about the ffmpeg-devel mailing list