[Ffmpeg-devel] [BUG] no video transcoding
Wolfram Gloger
wmglo
Sun Apr 15 10:13:37 CEST 2007
Hi,
> On Sat, Apr 14, 2007 at 03:29:52PM +0200, Baptiste Coudurier wrote:
> > Hi
> >=20
> > ffmpeg -v 3 -i no_video_transcoding.m2t test.mov
> >=20
> >=20
> > FFmpeg version SVN-r8731, Copyright (c) 2000-2007 Fabrice Bellard, et al.
> > configuration: --cc=3Dgcc-4.2 --enable-libfaad --enable-libfaac
> > --enable-gpl --enable-pthreads --enable-libmp3lame --enable-liba52
> > --enable-x264 --enable-pp --disable-vhook
> > libavutil version: 49.4.0
> > libavcodec version: 51.40.3
> > libavformat version: 51.12.1
> > built on Apr 14 2007 15:14:53, gcc: 4.2.0 20070105 (prerelease)
> > (Debian 4.2-20070105-1)
> > Input #0, mpegts, from 'no_video_transcoding.m2t':
> > Duration: 00:00:05.8, start: 3494.827200, bitrate: 16775 kb/s
> > Stream #0.0[0x31], 1/90000: Video: mpeg2video, yuv420p, 1920x1080,
> > 1001/30000, 18000 kb/s, 29.97 fps(r)
> > Stream #0.1[0x34](eng), 1/90000: Audio: ac3, 48000 Hz, 5:1, 384 kb/s
> > File 'test.mov' already exists. Overwrite ? [y/N] y
> > Output #0, mov, to 'test.mov':
> > Stream #0.0, 1/90000: Video: mpeg4, yuv420p, 1920x1080, 1001/30000,
> > q=3D2-31, 200 kb/s, 29.97 fps(c)
> > Stream #0.1, 1/90000: Audio: aac, 48000 Hz, 5:1, 64 kb/s
> > Stream mapping:
> > Stream #0.0 -> #0.0
> > Stream #0.1 -> #0.1
> > No accelerated IMDCT transform found
> > Press [q] to stop encoding
> > timestamp discontinuity 3495197367, new offset=3D -6990024567
> > timestamp discontinuity 9223372033359578441, new offset=3D 92233720333599=
> 48608
> > timestamp discontinuity 3494859200, new offset=3D 9223372029865089408
> > timestamp discontinuity -9223372036854404274, new offset=3D -6990057934
> > timestamp discontinuity 9223372036854404274, new offset=3D 92233720298650=
> 89408
>
> this is caused by the 8464->8465 change in libavformat/utils.c
> ---------
> av_estimate_timings_from_pts() flushes the packet queue but doesn't
> reset the streams' cur_dts values. This can lead to a fatal "error,
> non monotone timestamps ..." message later, because the out-of-date
> cur_dts values are used to compute some packet's dts.
>
> Fix this by calling av_read_frame_flush() and eliminate code
> duplication in the process.
>
> The additional hunk gives more detailed error messages.
>
> patch by Wolfram Gloger, wmglo dent.med.uni-muenchen de
> ---------
>
> ill leave this to wolfram to debug as it is his patch which seems to
> cause it ...
Ok that's probably true -- although I maintain the patch is correct,
and the problem is just as well "caused" by your own change to
libavformat/utils.c:
========================================================================
r8452 | michael | 2007-03-20 14:01:39 +0100 (Tue, 20 Mar 2007) | 2 lines
i think this is more correct
========================================================================
With both patches (i.e. in current svn) we lose all the cur_dts values
after av_find_stream_info(), so if the first packets don't contain
timestamps, we are in trouble generating any.
Baptiste, does the appended patch fix your case?
It just remebers the first valid dts encountered
and restores them after av_find_stream_info().
(I have posted it before but only now regression-tested it..)
Regards,
Wolfram.
diff -Naur trunk/libavformat/utils.c ffmpeg-wg/libavformat/utils.c
--- trunk/libavformat/utils.c Sat Apr 14 16:32:28 2007
+++ ffmpeg-wg/libavformat/utils.c Sat Apr 14 23:20:41 2007
@@ -1468,7 +1468,7 @@
#define DURATION_MAX_READ_SIZE 250000
/* only usable for MPEG-PS streams */
-static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings_from_pts(AVFormatContext *ic, offset_t old_offset, const int64_t old_dts[])
{
AVPacket pkt1, *pkt = &pkt1;
AVStream *st;
@@ -1547,9 +1547,11 @@
fill_all_stream_timings(ic);
url_fseek(&ic->pb, old_offset, SEEK_SET);
+ for(i=0; i<ic->nb_streams; i++)
+ ic->streams[i]->cur_dts = old_dts[i];
}
-static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset)
+static void av_estimate_timings(AVFormatContext *ic, offset_t old_offset, const int64_t old_dts[])
{
int64_t file_size;
@@ -1567,7 +1569,7 @@
!strcmp(ic->iformat->name, "mpegts")) &&
file_size && !ic->pb.is_streamed) {
/* get accurate estimate from the PTSes */
- av_estimate_timings_from_pts(ic, old_offset);
+ av_estimate_timings_from_pts(ic, old_offset, old_dts);
} else if (av_has_timings(ic)) {
/* at least one components has timings - we use them for all
the components */
@@ -1682,6 +1684,7 @@
AVPacket pkt1, *pkt;
AVPacketList *pktl=NULL, **ppktl;
int64_t last_dts[MAX_STREAMS];
+ int64_t first_dts[MAX_STREAMS];
int duration_count[MAX_STREAMS]={0};
double (*duration_error)[MAX_STD_TIMEBASES];
offset_t old_offset = url_ftell(&ic->pb);
@@ -1711,7 +1714,7 @@
}
for(i=0;i<MAX_STREAMS;i++){
- last_dts[i]= AV_NOPTS_VALUE;
+ first_dts[i]= last_dts[i]= AV_NOPTS_VALUE;
}
memset(probe_data, 0, sizeof(probe_data));
@@ -1817,8 +1820,9 @@
duration_count[index]++;
}
if(last == AV_NOPTS_VALUE || duration_count[index]<=1)
- last_dts[pkt->stream_index]= pkt->dts;
-
+ last_dts[index]= pkt->dts;
+ if(first_dts[index] == AV_NOPTS_VALUE)
+ first_dts[index]= pkt->dts;
if (st->codec->codec_id == CODEC_ID_NONE) {
AVProbeData *pd = &(probe_data[st->index]);
pd->buf = av_realloc(pd->buf, pd->buf_size+pkt->size);
@@ -1915,7 +1919,7 @@
}
}
- av_estimate_timings(ic, old_offset);
+ av_estimate_timings(ic, old_offset, first_dts);
for(i=0;i<ic->nb_streams;i++) {
st = ic->streams[i];
More information about the ffmpeg-devel
mailing list