* [FFmpeg-devel] [PATCH] tools/pktdumper: dump extradata buffers
@ 2025-06-23 8:09 Peter Ross
0 siblings, 0 replies; only message in thread
From: Peter Ross @ 2025-06-23 8:09 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1.1: Type: text/plain, Size: 2297 bytes --]
---
useful for re'ing files with extradata
tools/pktdumper.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/tools/pktdumper.c b/tools/pktdumper.c
index c51f5c8922..d7d3147b22 100644
--- a/tools/pktdumper.c
+++ b/tools/pktdumper.c
@@ -37,6 +37,7 @@
#define FILENAME_BUF_SIZE 4096
#define PKTFILESUFF "_%08" PRId64 "_%02d_%010" PRId64 "_%06d_%c.bin"
+#define EXTRADATAFILESUFF "_extradata_%02d_%06d.bin"
static int usage(int ret)
{
@@ -52,6 +53,7 @@ static int usage(int ret)
int main(int argc, char **argv)
{
char fntemplate[FILENAME_BUF_SIZE];
+ char fntemplate2[FILENAME_BUF_SIZE];
char pktfilename[FILENAME_BUF_SIZE];
AVFormatContext *fctx = NULL;
AVPacket *pkt;
@@ -86,8 +88,6 @@ int main(int argc, char **argv)
fprintf(stderr, "filename too long\n");
return usage(1);
}
- strcat(fntemplate, PKTFILESUFF);
- printf("FNTEMPLATE: '%s'\n", fntemplate);
err = avformat_open_input(&fctx, argv[1], NULL, NULL);
if (err < 0) {
@@ -107,6 +107,30 @@ int main(int argc, char **argv)
return 1;
}
+ strcpy(fntemplate2, fntemplate);
+ strcat(fntemplate2, EXTRADATAFILESUFF);
+
+ for (int i = 0; i < fctx->nb_streams; i++) {
+ AVCodecParameters * par = fctx->streams[i]->codecpar;
+ int fd;
+ if (par->extradata_size) {
+ snprintf(pktfilename, sizeof(pktfilename), fntemplate2, i, par->extradata_size);
+ printf(EXTRADATAFILESUFF "\n", i, par->extradata_size);
+ if (!nowrite) {
+ fd = open(pktfilename, O_WRONLY | O_CREAT, 0644);
+ err = write(fd, par->extradata, par->extradata_size);
+ if (err < 0) {
+ fprintf(stderr, "write: error %d\n", err);
+ return 1;
+ }
+ close(fd);
+ }
+ }
+ }
+
+ strcat(fntemplate, PKTFILESUFF);
+ printf("FNTEMPLATE: '%s'\n", fntemplate);
+
while ((err = av_read_frame(fctx, pkt)) >= 0) {
int fd;
snprintf(pktfilename, sizeof(pktfilename), fntemplate, pktnum,
--
2.47.2
-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: 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:[~2025-06-23 8:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-23 8:09 [FFmpeg-devel] [PATCH] tools/pktdumper: dump extradata buffers Peter Ross
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