mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-23 11:19:55 +00:00
【修改说明】解决字幕轨seek问题
Signed-off-by: Atrotro <wanganzhouhh@163.com>
This commit is contained in:
parent
7df0eac0c1
commit
f80c2d3873
1
BUILD.gn
1
BUILD.gn
@ -144,6 +144,7 @@ config("ffmpeg_config") {
|
||||
"-DOHOS_SDTP_BOX_EXT",
|
||||
"-DOHOS_NONSTANDARD_BOM",
|
||||
"-DOHOS_TIMED_META_TRACK",
|
||||
"-DOHOS_SUBTITLE_DEMUXER",
|
||||
]
|
||||
if (use_musl) {
|
||||
cflags += [ "-Wno-bool-operation" ]
|
||||
|
@ -79,7 +79,9 @@ const AVCodecTag ff_codec_movsubtitle_tags[] = {
|
||||
{ AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'e', 'x', 't') },
|
||||
{ AV_CODEC_ID_MOV_TEXT, MKTAG('t', 'x', '3', 'g') },
|
||||
{ AV_CODEC_ID_EIA_608, MKTAG('c', '6', '0', '8') },
|
||||
#ifdef OHOS_SUBTITLE_DEMUXER
|
||||
{ AV_CODEC_ID_WEBVTT, MKTAG('w', 'v', 't', 't') },
|
||||
#endif
|
||||
{ AV_CODEC_ID_NONE, 0 },
|
||||
};
|
||||
|
||||
|
@ -801,7 +801,11 @@ static int mov_read_hdlr(MOVContext *c, AVIOContext *pb, MOVAtom atom)
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
else if (type == MKTAG('m','1','a',' '))
|
||||
st->codecpar->codec_id = AV_CODEC_ID_MP2;
|
||||
#ifdef OHOS_SUBTITLE_DEMUXER
|
||||
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')) || (type == MKTAG('t','e','x','t')))
|
||||
#else
|
||||
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')))
|
||||
#endif
|
||||
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||
#ifdef OHOS_TIMED_META_TRACK
|
||||
else if (type == MKTAG('m', 'e', 't', 'a'))
|
||||
@ -9021,6 +9025,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
#ifdef OHOS_SUBTITLE_DEMUXER
|
||||
if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) {
|
||||
if (pkt->size >= 8) {
|
||||
uint32_t type = AV_RL32(pkt->data + 4);
|
||||
@ -9041,6 +9046,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
memmove(pkt->data, payload_data, move_size);
|
||||
pkt->size = payload_size;
|
||||
pkt->data[pkt->size] = '\0';
|
||||
break;
|
||||
} else {
|
||||
if (temp_size > payload_size) {
|
||||
@ -9053,6 +9059,7 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if CONFIG_DV_DEMUXER
|
||||
if (mov->dv_demux && sc->dv_audio_container) {
|
||||
ret = avpriv_dv_produce_packet(mov->dv_demux, pkt, pkt->data, pkt->size, pkt->pos);
|
||||
|
@ -288,6 +288,22 @@ int ff_subtitles_queue_seek(FFDemuxSubtitlesQueue *q, AVFormatContext *s, int st
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef OHOS_SUBTITLE_DEMUXER
|
||||
if (q->subs[idx]->pts + q->subs[idx]->duration < ts) {
|
||||
if (idx < 1)
|
||||
idx = 1;
|
||||
for (i = idx - 1; i < q->nb_subs; i++) {
|
||||
int64_t pts = q->subs[i]->pts;
|
||||
if (q->subs[i]->duration <= 0 ||
|
||||
(stream_index != -1 && q->subs[i]->stream_index != stream_index))
|
||||
continue;
|
||||
if (pts + q->subs[i]->duration >= ts) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/* If the queue is used to store multiple subtitles streams (like with
|
||||
* VobSub) and the stream index is not specified, we need to make sure
|
||||
* to focus on the smallest file position offset for a same timestamp;
|
||||
|
Loading…
Reference in New Issue
Block a user