diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index cb2ae86e48..c0f71136ad 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -830,7 +830,17 @@ static int mxf_parse_structural_metadata(MXFContext *mxf) st->codec->codec_id = container_ul->id; st->codec->channels = descriptor->channels; st->codec->bits_per_coded_sample = descriptor->bits_per_sample; - st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den; + if (descriptor->sample_rate.den > 0) { + st->codec->sample_rate = descriptor->sample_rate.num / descriptor->sample_rate.den; + avpriv_set_pts_info(st, 64, descriptor->sample_rate.den, descriptor->sample_rate.num); + } else { + av_log(mxf->fc, AV_LOG_WARNING, "invalid sample rate (%d/%d) " + "found for stream #%d, time base forced to 1/48000\n", + descriptor->sample_rate.num, descriptor->sample_rate.den, + st->index); + avpriv_set_pts_info(st, 64, 1, 48000); + } + /* TODO: implement CODEC_ID_RAWAUDIO */ if (st->codec->codec_id == CODEC_ID_PCM_S16LE) { if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24) diff --git a/tests/ref/seek/lavf_mxf b/tests/ref/seek/lavf_mxf index 4c1aecc68e..ce0d6ed873 100644 --- a/tests/ref/seek/lavf_mxf +++ b/tests/ref/seek/lavf_mxf @@ -7,9 +7,9 @@ ret: 0 st: 0 flags:0 ts: 0.800000 ret:-1 ret: 0 st: 0 flags:1 ts:-0.320000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 6144 size: 24801 -ret: 0 st: 1 flags:0 ts: 2.560000 +ret: 0 st: 1 flags:0 ts: 2.576667 ret:-1 -ret: 0 st: 1 flags:1 ts: 1.480000 +ret: 0 st: 1 flags:1 ts: 1.470833 ret:-1 ret: 0 st:-1 flags:0 ts: 0.365002 ret: 0 st: 0 flags:1 dts: 0.360000 pts: NOPTS pos: 6144 size: 24801 @@ -19,9 +19,9 @@ ret: 0 st: 0 flags:0 ts: 2.160000 ret:-1 ret: 0 st: 0 flags:1 ts: 1.040000 ret:-1 -ret: 0 st: 1 flags:0 ts:-0.040000 +ret: 0 st: 1 flags:0 ts:-0.058333 ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 6144 size: 24801 -ret: 0 st: 1 flags:1 ts: 2.840000 +ret: 0 st: 1 flags:1 ts: 2.835833 ret:-1 ret: 0 st:-1 flags:0 ts: 1.730004 ret:-1 @@ -31,9 +31,9 @@ ret: 0 st: 0 flags:0 ts:-0.480000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 6144 size: 24801 ret: 0 st: 0 flags:1 ts: 2.400000 ret:-1 -ret: 0 st: 1 flags:0 ts: 1.320000 +ret: 0 st: 1 flags:0 ts: 1.306667 ret:-1 -ret: 0 st: 1 flags:1 ts: 0.200000 +ret: 0 st: 1 flags:1 ts: 0.200833 ret: 0 st: 0 flags:1 dts: 0.200000 pts: NOPTS pos: 6144 size: 24801 ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 6144 size: 24801 @@ -43,9 +43,9 @@ ret: 0 st: 0 flags:0 ts: 0.880000 ret:-1 ret: 0 st: 0 flags:1 ts:-0.240000 ret: 0 st: 0 flags:1 dts: 0.000000 pts: NOPTS pos: 6144 size: 24801 -ret: 0 st: 1 flags:0 ts: 2.680000 +ret: 0 st: 1 flags:0 ts: 2.671667 ret:-1 -ret: 0 st: 1 flags:1 ts: 1.560000 +ret: 0 st: 1 flags:1 ts: 1.565833 ret:-1 ret: 0 st:-1 flags:0 ts: 0.460008 ret: 0 st: 0 flags:1 dts: 0.480000 pts: NOPTS pos: 6144 size: 24801 diff --git a/tests/ref/seek/lavf_mxf_d10 b/tests/ref/seek/lavf_mxf_d10 index c05870f402..dba05ce9cb 100644 --- a/tests/ref/seek/lavf_mxf_d10 +++ b/tests/ref/seek/lavf_mxf_d10 @@ -7,9 +7,9 @@ ret: 0 st: 0 flags:0 ts: 0.800000 ret:-1 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.560000 +ret: 0 st: 1 flags:0 ts: 2.576667 ret:-1 -ret: 0 st: 1 flags:1 ts: 1.480000 +ret: 0 st: 1 flags:1 ts: 1.470833 ret:-1 ret: 0 st:-1 flags:0 ts: 0.365002 ret: 0 st: 0 flags:1 dts: 0.360000 pts: 0.360000 pos: 6144 size:150000 @@ -19,9 +19,9 @@ ret: 0 st: 0 flags:0 ts: 2.160000 ret:-1 ret: 0 st: 0 flags:1 ts: 1.040000 ret:-1 -ret: 0 st: 1 flags:0 ts:-0.040000 +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.840000 +ret: 0 st: 1 flags:1 ts: 2.835833 ret:-1 ret: 0 st:-1 flags:0 ts: 1.730004 ret:-1 @@ -31,9 +31,9 @@ ret: 0 st: 0 flags:0 ts:-0.480000 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:-1 -ret: 0 st: 1 flags:0 ts: 1.320000 +ret: 0 st: 1 flags:0 ts: 1.306667 ret:-1 -ret: 0 st: 1 flags:1 ts: 0.200000 +ret: 0 st: 1 flags:1 ts: 0.200833 ret: 0 st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos: 6144 size:150000 ret: 0 st:-1 flags:0 ts:-0.904994 ret: 0 st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos: 6144 size:150000 @@ -43,9 +43,9 @@ ret: 0 st: 0 flags:0 ts: 0.880000 ret:-1 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.680000 +ret: 0 st: 1 flags:0 ts: 2.671667 ret:-1 -ret: 0 st: 1 flags:1 ts: 1.560000 +ret: 0 st: 1 flags:1 ts: 1.565833 ret:-1 ret: 0 st:-1 flags:0 ts: 0.460008 ret: 0 st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 6144 size:150000