Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat/demux: Fixed the incorrect id3 tag checking logic,
@ 2025-02-21  4:17 wangyaqiang via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: wangyaqiang via ffmpeg-devel @ 2025-02-21  4:17 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: 1035567130, 汪亚强

From: 汪亚强 <wangyaqiang03@kuaishou.com>

detect only audio formats where the tag might exist.

For example, if an rgb rawvideo data starts with ID3,

 it will cause the packet data to be missing by 10 bytes,

causing a transcoding error.

Signed-off-by: 汪亚强 <wangyaqiang03@kuaishou.com>
---
 libavformat/demux.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 0e39346f62..d9c9766d51 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -299,9 +299,10 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
                 goto fail;
         }
     }
-
+    int id3v2_check = (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
+                       !strcmp(s->iformat->name, "tta") || !strcmp(s->iformat->name, "wav"));
     /* e.g. AVFMT_NOFILE formats will not have an AVIOContext */
-    if (s->pb)
+    if (s->pb && id3v2_check)
         ff_id3v2_read_dict(s->pb, &si->id3v2_meta, ID3v2_DEFAULT_MAGIC, &id3v2_extra_meta);
 
     if (ffifmt(s->iformat)->read_header)
@@ -320,8 +321,7 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
     }
 
     if (id3v2_extra_meta) {
-        if (!strcmp(s->iformat->name, "mp3") || !strcmp(s->iformat->name, "aac") ||
-            !strcmp(s->iformat->name, "tta") || !strcmp(s->iformat->name, "wav")) {
+        if (id3v2_check) {
             if ((ret = ff_id3v2_parse_apic(s, id3v2_extra_meta)) < 0)
                 goto close;
             if ((ret = ff_id3v2_parse_chapters(s, id3v2_extra_meta)) < 0)
-- 
2.39.3 (Apple Git-146)

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-02-21  4:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-21  4:17 [FFmpeg-devel] [PATCH] avformat/demux: Fixed the incorrect id3 tag checking logic, wangyaqiang via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git