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] image2 decoder: Add support for -skip_initial_bytes
@ 2022-05-20 20:54 Thomas Newton
  0 siblings, 0 replies; only message in thread
From: Thomas Newton @ 2022-05-20 20:54 UTC (permalink / raw)
  To: ffmpeg-devel

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

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

only message in thread, other threads:[~2022-05-20 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20 20:54 [FFmpeg-devel] [PATCH] image2 decoder: Add support for -skip_initial_bytes Thomas Newton

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