Hello,
I am working on an assignment (using C++) to decode all the subtitle
streams present in a m2ts file using libav.
I have a m2ts file with one video stream (video stream index = 0), one
audio stream (audio stream index = 1) and 4 subtitle streams ( stream
indices = 2, 3, 4, 5). frame rate = 23.97.
I would like to know how to interpret the pts to obtain the frame number.
Help to get the start & end frame number of a decoded subtitle from pts.
I am decoding the subtitle stream as follows:
AVPacket packet;
//looping till end of file
{
av_init_packet(&packet);
av_read_frame(pFormatContext, &packet);
if((packet.stream_index == m_subtitleStreamIndex[0]) ||
(packet.stream_index == m_subtitleStreamIndex[1]) || (packet.stream_index
== m_subtitleStreamIndex[2]) || (packet.stream_index ==
m_subtitleStreamIndex[3]))
{
int has_subtitle = 0;
AVSubtitle* subtitle = new AVSubtitle;
avcodec_decode_subtitle2(pSubtitleCodecContext, subtitle,
&has_subtitle, &packet);
if (has_subtitle != 0 && subtitle->rects)
{
//code to generate png for subtitle
// also update the subtitle start and end frame number
}
}
}
avsubtitle_free(subtitle);
}
}
As per the documentation :
http://ffmpeg.org/doxygen/trunk/structAVSubtitle.html
CODE: SELECT ALL<http://ffmpeg.zeranoe.com/forum/viewtopic.php?f=15&t=1037#>
typedef
struct AVSubtitle {
uint16_t format; /* 0 = graphics */
uint32_t start_display_time; /* relative to packet pts, in ms */
uint32_t end_display_time; /* relative to packet pts, in ms */
unsigned num_rects;
AVSubtitleRect **rects;
int64_t pts; ///< Same as packet pts, in AV_TIME_BASE
} AVSubtitle;
*When I debug this code these are the values I get for the first two
subtitles decoded.
1.) packet.pts = 56865976, subtitle->start_display_time = 0,
subtitle->end_display_time = 20000
2.) packet.pts = 56866029, subtitle->start_display_time = 0,
subtitle->end_display_time = 20000.
Could anyone please tell me how to convert these values into the frame
number? Basically I want the start_frame_number and the end_frame_number
for the subtitle. I am expecting your priceless guidance and help.*
_______________________________________________
libav-api mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-api