From bc1645315da24537d1cda09879bc529441474711 Mon Sep 17 00:00:00 2001 From: Atrotro Date: Wed, 3 Jul 2024 17:33:42 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E3=80=91=EF=BC=9A=E6=94=AF=E6=8C=81vtt=E5=AD=97?= =?UTF-8?q?=E5=B9=95=E8=BD=A8=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atrotro --- BUILD.gn | 4 ++-- ohos_config.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 18b6277ea0..38b2b62636 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1541,8 +1541,8 @@ 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", diff --git a/ohos_config.sh b/ohos_config.sh index 4ee5651f39..69842b4912 100755 --- a/ohos_config.sh +++ b/ohos_config.sh @@ -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 + --enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,webvtt --enable-muxer=mp4,h264,ipod,amr,mpegts,mp3 --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 + --enable-demuxer=mp3,aac,ape,flac,ogg,wav,mov,mpegts,amr,amrnb,amrwb,matroska,flv,mpegps,asf,asf_o,srt,webvtt --enable-muxer=mp4,h264,ipod,amr,mpegts,mp3 --enable-parser=h263,h264,mpeg4video,vp8,vp9,mpegvideo --enable-parser=mpegaudio,aac,aac_latm,av3a,amr,opus From 8f979e35c1aaaeeb9fe8e5786429470a59cec66b Mon Sep 17 00:00:00 2001 From: Atrotro Date: Fri, 5 Jul 2024 14:09:38 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E3=80=91=EF=BC=9Aformat=5Fcheck=20LF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atrotro --- BUILD.gn | 1 + 1 file changed, 1 insertion(+) diff --git a/BUILD.gn b/BUILD.gn index 38b2b62636..9ad141fe12 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1543,6 +1543,7 @@ ohos_source_set("ffmpeg_dynamic") { # "//third_party/ffmpeg/libavformat/webpenc.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", From da3ef3dcce50f49d643d4502d98f025a0c375cfa Mon Sep 17 00:00:00 2001 From: Atrotro Date: Sat, 20 Jul 2024 11:07:45 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E3=80=91=EF=BC=9A=E6=8F=90=E4=BE=9B=E5=86=85=E7=BD=AE?= =?UTF-8?q?vtt=E8=A7=A3=E6=9E=90=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Atrotro --- libavformat/isom.c | 3 ++- libavformat/mov.c | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/libavformat/isom.c b/libavformat/isom.c index 528ddb192b..de48eb3745 100644 --- a/libavformat/isom.c +++ b/libavformat/isom.c @@ -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 } -}; +}; \ No newline at end of file diff --git a/libavformat/mov.c b/libavformat/mov.c index 69a1166d18..69b5cab7b1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -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, -}; +}; \ No newline at end of file