[FFmpeg-devel] Cannot remux a MXF file to Mpegts
Thierry Foucu
tfoucu at gmail.com
Sat Mar 31 05:38:07 CEST 2012
Hello,
When trying to remux a MXF file to Mpeg2Ts and we found out that the mpegts
muxer require the first frame to have a valid PTS
How ever, the MXF demuxer will set only the DTS for video frame. And so, we
cannot remux a MXF file to M2TS.
You can duplicate the problem by this simple command and using one of your
fate MXF sample file.
./ffmpeg -i fate_sample/mxf/C0023S01.mxf -vcodec copy -acodec copy
/tmp/test.ts
....
[mpegts @ 0x12be140] first pts value must set
av_interleaved_write_frame(): Operation not permitted
I'm not sure if this is the right solution, but by applying this change
(patch at the end of this email) , we can then remux a MXF file to Mpeg2Ts.
Or should we fix the MXF demuxer to set a PTS?
What do you think if the right approach to fix the problem?
Thanks.
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index c3b3d5d..07f3331 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -997,8 +997,12 @@ static int mpegts_write_packet(AVFormatContext *s,
AVPacket *pkt)
dts = pkt->dts + delay;
if (ts_st->first_pts_check && pts == AV_NOPTS_VALUE) {
- av_log(s, AV_LOG_ERROR, "first pts value must set\n");
- return AVERROR_INVALIDDATA;
+ if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && pkt->flags &
AV_PKT_FLAG_KEY) {
+ pts = dts + pkt->duration;
+ } else {
+ av_log(s, AV_LOG_ERROR, "first pts value must set\n");
+ return AVERROR_INVALIDDATA;
+ }
}
ts_st->first_pts_check = 0;
More information about the ffmpeg-devel
mailing list