<div dir="ltr">Hello Community ! (Sorry for my awful English !)<div><br></div><div>We have a mp4 video we stream with ffmpeg API to a TS Stream.</div><div><br></div><div>During this stream we want to add live subtitling in DVDSubtitle format (Or other one if needed)<br></div><div><br></div><div>For that we create an OutputFormat & FormatContext and then we add 2 Streams</div><div>1 For video only</div><div>and the second for subtitling with avformat_new_stream</div><div><br></div><div>We use AV_CODEC_ID_DVD_SUBTITLE for Subtitle codec and AV_CODEC_ID_MPEG2VIDEO for video codec</div><div><br></div><div>i'll try to insert AVSubtitle Struc to an AVPacket and add it to the subtitle stream with<br></div><div><br></div><div>                            AVSubtitle* ASubtitle = null;<br>                            ASubtitle = (AVSubtitle*)ffmpeg.av_realloc(ASubtitle, (ulong)(sizeof(AVSubtitle)));<br>                            byte* buf = null;<br>                            buf = (byte*)ffmpeg.av_realloc(buf, (ulong)(sizeof(byte) * ms.Length));<br>                            ASubtitle->pts = currentTime;<br>                            ASubtitle->start_display_time = (uint)(currentTime * baseRational.num);<br>                            ASubtitle->end_display_time = ASubtitle->start_display_time + (uint)(999 * baseRational.num);<br>                            ASubtitle->pts = ffmpeg.av_rescale_q(ASubtitle->pts, ffmpeg.av_get_time_base_q(), outVideoStream->time_base);<br>                            ASubtitle->pts += ffmpeg.av_rescale_q(ASubtitle->start_display_time, baseRational, ffmpeg.av_get_time_base_q());<br>                            ASubtitle->end_display_time -= ASubtitle->start_display_time;<br><br></div><div>                                ASubtitle->rects = (AVSubtitleRect**)ffmpeg.av_realloc(ASubtitle->rects, (ulong)((ASubtitle->num_rects + 1) * sizeof(AVSubtitleRect)));<br>                                ASubtitle->rects[0]->data = subData;<br>                                ASubtitle->rects[0]->type = AVSubtitleType.SUBTITLE_BITMAP;<br>                                ASubtitle->rects[0]->h = subtitleBitmap.Height;<br>                                ASubtitle->rects[0]->w = subtitleBitmap.Width;<br>                                ASubtitle->rects[0]->x = 50;<br>                                ASubtitle->rects[0]->y = 200;<br>                                ASubtitle->rects[0]->nb_colors = 4;<br>                            }<br></div><div><br></div><div>subData is the data of my bitmap sub's</div><div><br></div><div>If anyone has an idea ...</div><div>Thanks in advance.</div><div><br></div><div><br></div></div>