[FFmpeg-devel] [PATCHv2] avformat/mxfdec: fix last packet timestamps
Marton Balint
cus at passwd.hu
Sat Dec 2 12:00:11 EET 2017
On Fri, 24 Nov 2017, Marton Balint wrote:
> The current edit unit cannot be reliably determined for the last packet of a
> video stream, because we can't query the start offset of the next edit unit
> from the index. This caused missing timestamps for the last video packet.
>
> Therefore from now on, we allow setting the PTS even if we are not sure of the
> current edit unit if mxf_set_current_edit_unit returned a specific failure, and
> the assumed current edit unit is the last.
>
> Fixes last packet timestamp of:
> ffprobe -fflags nofillin -show_packets tests/data/lavf/lavf.mxf -select_streams v
>
Ping, will apply soon.
Regards,
Marton
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavformat/mxfdec.c | 4 ++--
> tests/ref/seek/lavf-mxf_d10 | 12 ++++++------
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
> index 118e3e40b4..3b8d423906 100644
> --- a/libavformat/mxfdec.c
> +++ b/libavformat/mxfdec.c
> @@ -2976,7 +2976,7 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset
> /* find mxf->current_edit_unit so that the next edit unit starts ahead of current_offset */
> while (mxf->current_edit_unit >= 0) {
> if (mxf_edit_unit_absolute_offset(mxf, t, mxf->current_edit_unit + 1, NULL, &next_ofs, 0) < 0)
> - return -1;
> + return -2;
>
> if (next_ofs <= last_ofs) {
> /* large next_ofs didn't change or current_edit_unit wrapped
> @@ -3065,7 +3065,7 @@ static int mxf_set_pts(MXFContext *mxf, AVStream *st, AVPacket *pkt, int64_t nex
> AVCodecParameters *par = st->codecpar;
> MXFTrack *track = st->priv_data;
>
> - if (par->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
> + if (par->codec_type == AVMEDIA_TYPE_VIDEO && (next_ofs >= 0 || next_ofs == -2 && st->duration == mxf->current_edit_unit + 1)) {
> /* mxf->current_edit_unit good - see if we have an
> * index table to derive timestamps from */
> MXFIndexTable *t = &mxf->index_tables[0];
> diff --git a/tests/ref/seek/lavf-mxf_d10 b/tests/ref/seek/lavf-mxf_d10
> index 17cca29c03..5a682f0927 100644
> --- a/tests/ref/seek/lavf-mxf_d10
> +++ b/tests/ref/seek/lavf-mxf_d10
> @@ -8,9 +8,9 @@ ret: 0 st: 0 flags:1 dts: 0.800000 pts: 0.800000 pos:4265984 size:150000
> ret: 0 st: 0 flags:1 ts:-0.320000
> ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 6144 size:150000
> ret: 0 st: 1 flags:0 ts: 2.576667
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st: 1 flags:1 ts: 1.470833
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st:-1 flags:0 ts: 0.365002
> ret: 0 st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos:1923072 size:150000
> ret: 0 st:-1 flags:1 ts:-0.740831
> @@ -22,7 +22,7 @@ ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st: 1 flags:0 ts:-0.058333
> ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 6144 size:150000
> ret: 0 st: 1 flags:1 ts: 2.835833
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st:-1 flags:0 ts: 1.730004
> ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st:-1 flags:1 ts: 0.624171
> @@ -32,7 +32,7 @@ ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 6144 size:150000
> ret: 0 st: 0 flags:1 ts: 2.400000
> ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st: 1 flags:0 ts: 1.306667
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st: 1 flags:1 ts: 0.200833
> ret: 0 st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos:1071104 size:150000
> ret: 0 st:-1 flags:0 ts:-0.904994
> @@ -44,9 +44,9 @@ ret: 0 st: 0 flags:1 dts: 0.880000 pts: 0.880000 pos:4691968 size:150000
> ret: 0 st: 0 flags:1 ts:-0.240000
> ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 6144 size:150000
> ret: 0 st: 1 flags:0 ts: 2.671667
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st: 1 flags:1 ts: 1.565833
> -ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
> +ret: 0 st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
> ret: 0 st:-1 flags:0 ts: 0.460008
> ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos:2562048 size:150000
> ret: 0 st:-1 flags:1 ts:-0.645825
> --
> 2.13.6
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
More information about the ffmpeg-devel
mailing list