!227 支持vtt字幕轨解析

Merge pull request !227 from Atrotro/master
This commit is contained in:
openharmony_ci 2024-07-20 14:34:14 +00:00 committed by Gitee
commit 73a5eb9dc5
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 41 additions and 7 deletions

View File

@ -1544,8 +1544,9 @@ ohos_source_set("ffmpeg_dynamic") {
# "//third_party/ffmpeg/libavformat/webm_chunk.c",
# "//third_party/ffmpeg/libavformat/webmdashenc.c",
# "//third_party/ffmpeg/libavformat/webpenc.c",
# "//third_party/ffmpeg/libavformat/webvttdec.c",
# "//third_party/ffmpeg/libavformat/webvttenc.c",
"//third_party/ffmpeg/libavformat/webvttdec.c",
"//third_party/ffmpeg/libavformat/webvttenc.c",
# "//third_party/ffmpeg/libavformat/westwood_aud.c",
# "//third_party/ffmpeg/libavformat/westwood_vqa.c",
# "//third_party/ffmpeg/libavformat/wsddec.c",

View File

@ -79,6 +79,7 @@ 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') },
{ AV_CODEC_ID_WEBVTT, MKTAG('w', 'v', 't', 't') },
{ AV_CODEC_ID_NONE, 0 },
};
@ -451,4 +452,4 @@ static const struct MP4TrackKindValueMapping dash_role_map[] = {
const struct MP4TrackKindMapping ff_mov_track_kind_table[] = {
{ "urn:mpeg:dash:role:2011", dash_role_map },
{ 0, NULL }
};
};

View File

@ -801,7 +801,7 @@ 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;
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')))
else if ((type == MKTAG('s','u','b','p')) || (type == MKTAG('c','l','c','p')) || (type == MKTAG('t','e','x','t')))
st->codecpar->codec_type = AVMEDIA_TYPE_SUBTITLE;
#ifdef OHOS_TIMED_META_TRACK
else if (type == MKTAG('m', 'e', 't', 'a'))
@ -9021,6 +9021,38 @@ static int mov_read_packet(AVFormatContext *s, AVPacket *pkt)
}
return ret;
}
if (st->codecpar->codec_id == AV_CODEC_ID_WEBVTT) {
if (pkt->size >= 8) {
uint32_t type = AV_RL32(pkt->data + 4);
int payload_size = pkt->size - 8;
if (type == MKTAG('v', 't', 't', 'e')) {
pkt->size = 0;
} else if (type == MKTAG('v', 't', 't', 'c')) {
uint8_t *payload_data = pkt->data + 8;
while (payload_size >= 8) {
int64_t temp_size = AV_RB32(payload_data);
uint32_t temp_type = AV_RL32(payload_data + 4);
if (temp_type == MKTAG('p', 'a', 'y', 'l')) {
payload_data += 8;
payload_size -= 8;
int move_size = payload_size;
if (pkt->size < move_size) {
move_size = pkt->size;
}
memmove(pkt->data, payload_data, move_size);
pkt->size = payload_size;
break;
} else {
if (temp_size > payload_size) {
break;
}
payload_data += temp_size;
payload_size -= temp_size;
}
}
}
}
}
#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);
@ -9382,4 +9414,4 @@ const AVInputFormat ff_mov_demuxer = {
.read_close = mov_read_close,
.read_seek = mov_read_seek,
.flags = AVFMT_NO_BYTE_SEEK | AVFMT_SEEK_TO_PTS | AVFMT_SHOW_IDS,
};
};

View File

@ -50,7 +50,7 @@ FF_CONFIG_OPTIONS="
--disable-bzlib
--disable-lzma
--disable-vulkan
--enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,h264
--enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,h264,webvtt
--enable-muxer=mp4,h264,ipod,amr,mpegts,mp3,wav
--enable-parser=h263,h264,mpeg4video,vp8,vp9,mpegvideo
--enable-parser=mpegaudio,aac,aac_latm,av3a,amr,opus
@ -144,7 +144,7 @@ FF_CONFIG_OPTIONS="
--disable-sdl2
--disable-bzlib
--disable-lzma
--enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,h264
--enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,h264,webvtt
--enable-muxer=mp4,h264,ipod,amr,mpegts,mp3,wav
--enable-parser=h263,h264,mpeg4video,vp8,vp9,mpegvideo
--enable-parser=mpegaudio,aac,aac_latm,av3a,amr,opus