* [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid
@ 2024-04-11 15:41 Tomas Härdin
2024-04-11 18:28 ` Tomas Härdin
2024-04-11 22:32 ` Michael Niedermayer
0 siblings, 2 replies; 4+ messages in thread
From: Tomas Härdin @ 2024-04-11 15:41 UTC (permalink / raw)
To: ffmpeg-devel
[-- Attachment #1: Type: text/plain, Size: 289 bytes --]
Hi
Patch attached allows preserving PIDs when remuxing MPEG-TS. James
suggested we could generalize this to allow copying from specific
streams, but I think if we want to handle a more general case then it
would be better to handle streamid via metadata.
Passes FATE.
/Tomas
[-- Attachment #2: 0001-ffmpeg-Add-copystreamid.patch --]
[-- Type: text/x-patch, Size: 3068 bytes --]
From 63b10983876077fd0e2b41c21a3c188b8557c602 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
Date: Thu, 11 Apr 2024 16:52:33 +0200
Subject: [PATCH] ffmpeg: Add -copystreamid
This causes streamid's to be copied from all input streams to all output streams.
Individual streams' streamid can still be set explicitly with -streamid.
---
doc/ffmpeg.texi | 10 ++++++++++
fftools/ffmpeg.h | 1 +
fftools/ffmpeg_mux_init.c | 4 ++++
fftools/ffmpeg_opt.c | 5 +++++
4 files changed, 20 insertions(+)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index e996ab945f..ef61b7118d 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -2096,6 +2096,16 @@ an output mpegts file:
ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
@end example
+@item -copystreamid
+Copy streamid's (PIDs) from input streams to output streams for all streams in all output files.
+Can be overridden with -streamid on a per-stream basis.
+
+For example, to remux an input MPEG-TS file, copying all PIDs except the PID of stream 3,
+and setting the PID of stream 3 to 0x123:
+@example
+ffmpeg -i in.ts -map 0 -c copy -copystreamid -streamid 3:0x123 -y out.ts
+@end
+
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{input/output,per-stream})
Apply bitstream filters to matching streams. The filters are applied to each
packet as it is received from the demuxer (when used as an input option) or
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 885a7c0c10..e0f8e4d87d 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -685,6 +685,7 @@ extern int64_t stats_period;
extern int stdin_interaction;
extern AVIOContext *progress_avio;
extern float max_error_rate;
+extern int copy_streamid;
extern char *filter_nbthreads;
extern int filter_complex_nbthreads;
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6d8bd5bcdf..8268595a18 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1073,6 +1073,10 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
ost = &ms->ost;
+ if (ist && copy_streamid)
+ ost->st->id = ist->st->id;
+
+ // override -copystreamid if -streamid explicitly set
if (o->streamid) {
AVDictionaryEntry *e;
char idx[16], *p;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 6526e8e3e8..5b4b29d259 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -77,6 +77,7 @@ int filter_complex_nbthreads = 0;
int vstats_version = 2;
int auto_conversion_filters = 1;
int64_t stats_period = 500000;
+int copy_streamid = 0;
static int file_overwrite = 0;
@@ -1902,5 +1903,9 @@ const OptionDef options[] = {
"set video sync method globally; deprecated, use -fps_mode", "" },
#endif
+ { "copystreamid", OPT_TYPE_BOOL, OPT_EXPERT,
+ { ©_streamid },
+ "copy input stream's streamid (MPEG-TS PID) to output stream, for all streams where -streamid is not set" },
+
{ NULL, },
};
--
2.39.2
[-- 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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid
2024-04-11 15:41 [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid Tomas Härdin
@ 2024-04-11 18:28 ` Tomas Härdin
2024-04-11 22:32 ` Michael Niedermayer
1 sibling, 0 replies; 4+ messages in thread
From: Tomas Härdin @ 2024-04-11 18:28 UTC (permalink / raw)
To: FFmpeg development discussions and patches
tor 2024-04-11 klockan 17:41 +0200 skrev Tomas Härdin:
> Hi
>
> Patch attached allows preserving PIDs when remuxing MPEG-TS. James
> suggested we could generalize this to allow copying from specific
> streams, but I think if we want to handle a more general case then it
> would be better to handle streamid via metadata.
>
> Passes FATE.
Come to think of it, I may need the ability to copy PID from a specific
stream after all. Or more correctly, to replace the audio in an MPEG-TS
stream but keep all the other streams the same, and keeping the PIDs.
I'll see what I can come up with..
/Tomas
_______________________________________________
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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid
2024-04-11 15:41 [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid Tomas Härdin
2024-04-11 18:28 ` Tomas Härdin
@ 2024-04-11 22:32 ` Michael Niedermayer
2024-04-12 8:54 ` Tomas Härdin
1 sibling, 1 reply; 4+ messages in thread
From: Michael Niedermayer @ 2024-04-11 22:32 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2116 bytes --]
On Thu, Apr 11, 2024 at 05:41:48PM +0200, Tomas Härdin wrote:
> Hi
>
> Patch attached allows preserving PIDs when remuxing MPEG-TS. James
> suggested we could generalize this to allow copying from specific
> streams, but I think if we want to handle a more general case then it
> would be better to handle streamid via metadata.
>
> Passes FATE.
>
> /Tomas
> doc/ffmpeg.texi | 10 ++++++++++
> fftools/ffmpeg.h | 1 +
> fftools/ffmpeg_mux_init.c | 4 ++++
> fftools/ffmpeg_opt.c | 5 +++++
> 4 files changed, 20 insertions(+)
> a926f3ca3c894dfa1dc91d479d32278ab7863bfa 0001-ffmpeg-Add-copystreamid.patch
> From 63b10983876077fd0e2b41c21a3c188b8557c602 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
> Date: Thu, 11 Apr 2024 16:52:33 +0200
> Subject: [PATCH] ffmpeg: Add -copystreamid
>
> This causes streamid's to be copied from all input streams to all output streams.
> Individual streams' streamid can still be set explicitly with -streamid.
> ---
> doc/ffmpeg.texi | 10 ++++++++++
> fftools/ffmpeg.h | 1 +
> fftools/ffmpeg_mux_init.c | 4 ++++
> fftools/ffmpeg_opt.c | 5 +++++
> 4 files changed, 20 insertions(+)
rm doc/ffmpeg.pod doc/ffmpeg-all.1 ; make -j32 doc/ffmpeg-all.1 doc/ffmpeg.pod
rm: cannot remove 'doc/ffmpeg-all.1': No such file or directory
MAN doc/ffmpeg-all.1
POD doc/ffmpeg.pod
@example ended by @end table at line 2502
doc/Makefile:88: recipe for target 'doc/ffmpeg.pod' failed
make: *** [doc/ffmpeg.pod] Error 255
make: *** Waiting for unfinished jobs....
pod2man: unable to format doc/ffmpeg-all.pod
doc/Makefile:98: recipe for target 'doc/ffmpeg-all.1' failed
make: *** [doc/ffmpeg-all.1] Error 1
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 1
"Used only once" - "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."
[-- 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] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid
2024-04-11 22:32 ` Michael Niedermayer
@ 2024-04-12 8:54 ` Tomas Härdin
0 siblings, 0 replies; 4+ messages in thread
From: Tomas Härdin @ 2024-04-12 8:54 UTC (permalink / raw)
To: FFmpeg development discussions and patches
fre 2024-04-12 klockan 00:32 +0200 skrev Michael Niedermayer:
> On Thu, Apr 11, 2024 at 05:41:48PM +0200, Tomas Härdin wrote:
> > Hi
> >
> > Patch attached allows preserving PIDs when remuxing MPEG-TS. James
> > suggested we could generalize this to allow copying from specific
> > streams, but I think if we want to handle a more general case then
> > it
> > would be better to handle streamid via metadata.
> >
> > Passes FATE.
> >
> > /Tomas
>
> > doc/ffmpeg.texi | 10 ++++++++++
> > fftools/ffmpeg.h | 1 +
> > fftools/ffmpeg_mux_init.c | 4 ++++
> > fftools/ffmpeg_opt.c | 5 +++++
> > 4 files changed, 20 insertions(+)
> > a926f3ca3c894dfa1dc91d479d32278ab7863bfa 0001-ffmpeg-Add-
> > copystreamid.patch
> > From 63b10983876077fd0e2b41c21a3c188b8557c602 Mon Sep 17 00:00:00
> > 2001
> > From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git@haerdin.se>
> > Date: Thu, 11 Apr 2024 16:52:33 +0200
> > Subject: [PATCH] ffmpeg: Add -copystreamid
> >
> > This causes streamid's to be copied from all input streams to all
> > output streams.
> > Individual streams' streamid can still be set explicitly with -
> > streamid.
> > ---
> > doc/ffmpeg.texi | 10 ++++++++++
> > fftools/ffmpeg.h | 1 +
> > fftools/ffmpeg_mux_init.c | 4 ++++
> > fftools/ffmpeg_opt.c | 5 +++++
> > 4 files changed, 20 insertions(+)
>
> rm doc/ffmpeg.pod doc/ffmpeg-all.1 ; make -j32 doc/ffmpeg-all.1
> doc/ffmpeg.pod
> rm: cannot remove 'doc/ffmpeg-all.1': No such file or directory
> MAN doc/ffmpeg-all.1
> POD doc/ffmpeg.pod
> @example ended by @end table at line 2502
Right, should be @end example. Wrote the doc after running FATE. No
matter, I have another solution in the works.
/Tomas
_______________________________________________
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] 4+ messages in thread
end of thread, other threads:[~2024-04-12 8:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-11 15:41 [FFmpeg-devel] [PATCH] ffmpeg: Add -copystreamid Tomas Härdin
2024-04-11 18:28 ` Tomas Härdin
2024-04-11 22:32 ` Michael Niedermayer
2024-04-12 8:54 ` Tomas Härdin
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