From: Peter Ross <pross@xvid.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] tools/pktdumper: dump extradata buffers Date: Mon, 23 Jun 2025 18:09:37 +1000 Message-ID: <d80edde69030b84fc47828192002578f6675c9e6.1750666089.git.pross@xvid.org> (raw) [-- 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".
reply other threads:[~2025-06-23 8:09 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=d80edde69030b84fc47828192002578f6675c9e6.1750666089.git.pross@xvid.org \ --to=pross@xvid.org \ --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