diff options
author | Clément Bœsch <ubitux@gmail.com> | 2013-02-20 23:43:25 +0100 |
---|---|---|
committer | Clément Bœsch <ubitux@gmail.com> | 2013-02-21 00:59:32 +0100 |
commit | 7346354b5597cc2739af1d911b3e47e0eeba16a2 (patch) | |
tree | 7b4dbbc52f590312421b769392bd130e53686bab /libavformat/microdvdenc.c | |
parent | 580e2285577ccc5b0a70951b9f0ad963844a912a (diff) | |
download | ffmpeg-7346354b5597cc2739af1d911b3e47e0eeba16a2.tar.gz |
lavf/microdvd: fix muxing.
This was broken since 1f265f52.
Diffstat (limited to 'libavformat/microdvdenc.c')
-rw-r--r-- | libavformat/microdvdenc.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/libavformat/microdvdenc.c b/libavformat/microdvdenc.c index ba97444044..30fd0ea3a6 100644 --- a/libavformat/microdvdenc.c +++ b/libavformat/microdvdenc.c @@ -19,12 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <inttypes.h> #include "avformat.h" -#include "rawenc.h" +#include "internal.h" static int microdvd_write_header(struct AVFormatContext *s) { AVCodecContext *avctx = s->streams[0]->codec; + AVRational tb = avctx->time_base; if (s->nb_streams != 1 || avctx->codec_id != AV_CODEC_ID_MICRODVD) { av_log(s, AV_LOG_ERROR, "Exactly one MicroDVD stream is needed.\n"); @@ -36,6 +38,21 @@ static int microdvd_write_header(struct AVFormatContext *s) avio_write(s->pb, avctx->extradata, avctx->extradata_size); avio_flush(s->pb); } + + avpriv_set_pts_info(s->streams[0], 64, tb.num, tb.den); + return 0; +} + +static int microdvd_write_packet(AVFormatContext *avf, AVPacket *pkt) +{ + avio_printf(avf->pb, "{%"PRId64"}", pkt->pts); + if (pkt->duration < 0) + avio_write(avf->pb, "{}", 2); + else + avio_printf(avf->pb, "{%"PRId64"}", pkt->pts + pkt->duration); + avio_write(avf->pb, pkt->data, pkt->size); + avio_write(avf->pb, "\n", 1); + avio_flush(avf->pb); return 0; } @@ -45,7 +62,7 @@ AVOutputFormat ff_microdvd_muxer = { .mime_type = "text/x-microdvd", .extensions = "sub", .write_header = microdvd_write_header, - .write_packet = ff_raw_write_packet, + .write_packet = microdvd_write_packet, .flags = AVFMT_NOTIMESTAMPS, .subtitle_codec = AV_CODEC_ID_MICRODVD, }; |