[FFmpeg-devel] [PATCH] ffmpeg: Carry streamid as metadata key 'id'

Michael Niedermayer michael at niedermayer.cc
Sat Apr 13 02:25:09 EEST 2024


On Fri, Apr 12, 2024 at 11:40:47AM +0200, Tomas Härdin wrote:
> This idea could be extended to other fields not presently considered to
> be metadata, that would be handy to treat as such.
> 
> I use the key "id" because ffprobe outputs id= for streamid. Another
> option could be to collect these types of metadata that go into
> AVStream fields under a namespace like FFMPEG: or AVSTREAM: or
> something, then delete all of them using AV_DICT_IGNORE_SUFFIX near the
> end of of_open() since they're for internal ffmpeg use.
> 
> The FATE change is just because av_dict() changes the order of things
> when elements are deleted.
> 
> /Tomas

>  fftools/ffmpeg_demux.c              |    5 +++
>  fftools/ffmpeg_mux_init.c           |   56 ++++++++++++++++++++++++++----------
>  tests/ref/fate/matroska-stereo_mode |    6 +--
>  3 files changed, 49 insertions(+), 18 deletions(-)
> cd526b2292b6d7e3fb5739a04cf17fbe5f207f16  0001-ffmpeg-Carry-streamid-as-metadata-key-id.patch
> From 7799f1b2eb8ab02e58118565f3e889fbe0d568a7 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git at haerdin.se>
> Date: Fri, 12 Apr 2024 10:34:12 +0200
> Subject: [PATCH] ffmpeg: Carry streamid as metadata key 'id'
> 
> This allows using -map_metadata and -metadata to copy/set streamids (PIDs).
> ---
>  fftools/ffmpeg_demux.c              |  5 +++
>  fftools/ffmpeg_mux_init.c           | 56 +++++++++++++++++++++--------
>  tests/ref/fate/matroska-stereo_mode |  6 ++--
>  3 files changed, 49 insertions(+), 18 deletions(-)

breaks:

./ffmpeg -i ~/videos/mm-short.mpg -vstats_file /tmp/vstats -bitexact -map 0:1 -map 0:1 -map 0:2 -threads 6 -vcodec libx264 -vcodec libx264 -pass 1 -b:v:0 300k -b:v:1 900k -passlogfile:v:1 /tmp/video2 -passlogfile:v:0 /tmp/video1 -t 1 -y -ab 128k  /tmp/x.ts

[mpegts @ 0x558d5e3b2140] Duplicate stream id 480
[out#0/mpegts @ 0x558d5e3b2000] Could not write header (incorrect codec parameters ?): Invalid argument
[vf#0:0 @ 0x558d5e400400] Error sending frames to consumers: Invalid argument
[vf#0:0 @ 0x558d5e400400] Task finished with error code: -22 (Invalid argument)
[vf#0:0 @ 0x558d5e400400] Terminating thread with return code -22 (Invalid argument)
[out#0/mpegts @ 0x558d5e3b2000] Nothing was written into output file, because at least one of its streams received no packets.

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The misfortune of the wise is better than the prosperity of the fool.
-- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240413/8a1f48d9/attachment.sig>


More information about the ffmpeg-devel mailing list