I had checked the values about time_base's in AVStream's, and in AVPackets of source and target. Furthermore, the pts, dts in the first two AVPackets, read and write, are both 0 and duration, 999; but I got "00:00:00,000 --> 00:00:00,999" in source packet and "00:02:11,072 --> 00:02:12,071" in target one. > Date: Sat, 5 Jul 2014 17:40:38 +0200 > From: [email protected] > To: [email protected] > Subject: Re: [Libav-user] Add subtitles to MKV file > > On Sat, 5 Jul 2014 16:15:44 +0800 > "ingmar" <[email protected]> wrote: > > > Hello Everyone! > > > > > > > > I am trying to add some text, being a stream, into an MKV file which has > > encoded video and audio data already. Because of some reasons, storing the > > text to an isolated file is not acceptable. > > > > > > > > The problem I encountered was the times of subtitles were incorrect like > > below. > > > > > > > > [Original] > > > > 1 > > > > 00:00:00,000 --> 00:00:00,999 > > > > 2014-07-01 11:59:28 > > > > > > > > 2 > > > > 00:00:01,000 --> 00:00:01,999 > > > > 2014-07-01 11:59:29 > > > > > > > > [Encoded] > > > > 1 > > > > 00:02:11,072 --> 00:02:12,071 > > > > 2014-07-01 11:59:28 > > > > > > > > 2 > > > > 00:02:12,072 --> 00:02:13,071 > > > > 2014-07-01 11:59:29 > > > > > > > > My approach is following. > > > > 1. Create 3 streams: video, audio and subtitle with code AV_CODEC_ID_SUBRIP > > and add to the target MKV file. > > > > 2. Encode all video and audio data. > > > > 3. Create a temporary SRT file and store all text in it. > > > > 4. Read a packet from SRT file (av_read_frame) -> decode > > (avcodec_decode_subtitle2) -> encode (avcodec_encode_subtitle) -> write to > > MKV file (av_interleaved_write_frame). > > > > > > > > I have been sure the time_base fields of the input and output streams were > > the same; and also for the pts, dts and duration ones of the input and > > output packets. > > > > > > > > Any advice would be greatly appreciated. > > > > Maybe wrong timebase in timestamp calculations? Just guessing. > _______________________________________________ > Libav-user mailing list > [email protected] > http://ffmpeg.org/mailman/listinfo/libav-user
_______________________________________________ Libav-user mailing list [email protected] http://ffmpeg.org/mailman/listinfo/libav-user
