Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Thomas Newton <thomas.w.newton@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH] image2 decoder: Add support for -skip_initial_bytes
Date: Fri, 20 May 2022 21:54:43 +0100
Message-ID: <CACA=nmhXJ-GuQt5d3y1HNWZm11o56k1RqXqoSdahEP8u3+6QgA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1837 bytes --]

Relevant questions from the patch submission checklist:
Explanation why it changes things like it does:
Sometimes input data may have custom headers that ffmpeg is not expected to
understand. It seems to me, this is why `-skip_initial_bytes` exists. From
the documentation it sounds like this option should be supported on all
muxers and demuxers but it doesn't seem to work with image2.

Summary of user visible advantages:
Users wanting to use the image2 format for files with custom headers can
now do just that.

Example using this change:
`ffmpeg -y -skip_initial_bytes 32 -f image2 -c:v rawvideo -pix_fmt rgb24
-s:v 64x64 -ts_from_file 2 -pattern_type glob -i "*.RGB8" output.mp4`
From within the example.zip I've attached. This zip file also
includes `expected_output.mp4` for what the output should look like and
`corrupt_output.mp4` for what I get without this patch.

The patch contect itself:
---
Add support for -skip_initial_bytes when using the image2 decoder.
skip_initial_bytes is useful when the input data contains a custom header.
Previously this was not supported when using the image2 format.

Signed-off-by: Thomas Newton <thomas.w.newton@gmail.com>
---
 libavformat/img2dec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index 5f9d1f094f..19461aa200 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -474,6 +474,8 @@ int ff_img_read_packet(AVFormatContext *s1, AVPacket
*pkt)
             ifmt = av_probe_input_format3(&pd, 1, &score);
             if (ifmt && ifmt->read_packet == ff_img_read_packet &&
ifmt->raw_codec_id)
                 par->codec_id = ifmt->raw_codec_id;
+        } else {
+            avio_skip(f[i], s1->skip_initial_bytes);
         }

         if (par->codec_id == AV_CODEC_ID_RAWVIDEO && !par->width)
-- 
2.36.1
---

[-- Attachment #2: example.zip --]
[-- Type: application/x-zip-compressed, Size: 4393 bytes --]

[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

                 reply	other threads:[~2022-05-20 20:55 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACA=nmhXJ-GuQt5d3y1HNWZm11o56k1RqXqoSdahEP8u3+6QgA@mail.gmail.com' \
    --to=thomas.w.newton@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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