[vlc-devel] commit: Workaround buggy flv files (#2590). (Laurent Aimar )
git version control
git at videolan.org
Fri Jun 19 15:33:27 CEST 2009
vlc | branch: 1.0-bugfix | Laurent Aimar <fenrir at videolan.org> | Fri Jun 19 01:02:04 2009 +0200| [10f95fc58964afb8806ed1c2e2764b802b4bc356] | committer: Derk-Jan Hartman
Workaround buggy flv files (#2590).
It seems that (a lot of?) flv files does not correctly set PTS,
so ignore them, with luck the decoder (avcodec) will recreate
them.
It might break some valid files, so report any regression.
(It needs the AVCodecContext::ticks_per_frame change).
(cherry picked from commit d1bf1bcfba6af6ac76250d7953afc1e1b894b5f7)
Signed-off-by: Derk-Jan Hartman <hartman at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=10f95fc58964afb8806ed1c2e2764b802b4bc356
---
modules/demux/avformat/demux.c | 21 +++++++++++++++------
1 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/modules/demux/avformat/demux.c b/modules/demux/avformat/demux.c
index dd0f7c9..11cce6c 100644
--- a/modules/demux/avformat/demux.c
+++ b/modules/demux/avformat/demux.c
@@ -395,6 +395,8 @@ static int Demux( demux_t *p_demux )
av_free_packet( &pkt );
return 1;
}
+ const AVStream *p_stream = p_sys->ic->streams[pkt.stream_index];
+
if( ( p_frame = block_New( p_demux, pkt.size ) ) == NULL )
{
return 0;
@@ -410,17 +412,24 @@ static int Demux( demux_t *p_demux )
p_frame->i_dts = ( pkt.dts == (int64_t)AV_NOPTS_VALUE ) ?
0 : (pkt.dts) * 1000000 *
- p_sys->ic->streams[pkt.stream_index]->time_base.num /
- p_sys->ic->streams[pkt.stream_index]->time_base.den - i_start_time;
+ p_stream->time_base.num /
+ p_stream->time_base.den - i_start_time;
p_frame->i_pts = ( pkt.pts == (int64_t)AV_NOPTS_VALUE ) ?
0 : (pkt.pts) * 1000000 *
- p_sys->ic->streams[pkt.stream_index]->time_base.num /
- p_sys->ic->streams[pkt.stream_index]->time_base.den - i_start_time;
+ p_stream->time_base.num /
+ p_stream->time_base.den - i_start_time;
if( pkt.duration > 0 )
p_frame->i_length = pkt.duration * 1000000 *
- p_sys->ic->streams[pkt.stream_index]->time_base.num /
- p_sys->ic->streams[pkt.stream_index]->time_base.den - i_start_time;
+ p_stream->time_base.num /
+ p_stream->time_base.den - i_start_time;
+ if( pkt.dts != AV_NOPTS_VALUE && pkt.dts == pkt.pts &&
+ p_stream->codec->codec_type == CODEC_TYPE_VIDEO )
+ {
+ /* Add here notoriously bugged file formats/samples regarding PTS */
+ if( !strcmp( p_sys->fmt->name, "flv" ) )
+ p_frame->i_pts = 0;
+ }
#ifdef AVFORMAT_DEBUG
msg_Dbg( p_demux, "tk[%d] dts=%"PRId64" pts=%"PRId64,
pkt.stream_index, p_frame->i_dts, p_frame->i_pts );
More information about the vlc-devel
mailing list