[FFmpeg-devel] PATCH: mpegtsenc.c

Janne Grunau janne-ffmpeg
Thu Jan 20 14:37:59 CET 2011


On Thu, Jan 20, 2011 at 03:28:30PM +0200, Georgi Chorbadzhiyski wrote:
> Around 01/20/11 13:55, M?ns Rullg?rd scribbled:
> >> The metadata key for the muxer and demuxer is different for the
> >> service name though - the demuxer calls it "name" while this patch
> >> would use "service_name" for the muxer. Perhaps the former should be
> >> fixed up after this patch is applied?
> > 
> > Keeping it consistent is certainly a good idea.  As service_name is
> > more accurate, fixing the demuxer is the way to go.  Patches welcome.
> 
> See attached.
> 
> -- 
> Georgi Chorbadzhiyski
> http://georgi.unixsol.org/

> From f1293614dab8b0b673fe5e15f096a6ad7eee5521 Mon Sep 17 00:00:00 2001
> From: Georgi Chorbadzhiyski <gf at unixsol.org>
> Date: Thu, 20 Jan 2011 09:26:40 +0200
> Subject: [PATCH 1/2] Add service_provider and service_name metadata
> 
> This patch adds support in mpegts muxer for using service_provider and
> service_name metadata to set service_provider_name and service_name
> fields in SDT.
> 
> Example usage:
>    ffmpeg -i file.ts -f mpegts -re -acodec copy -vcodec copy -f mpegts \
>        -metadata service_provider="Some provider" \
>        -metadata service_name="Some Channel" \
>        "udp://239.0.70.2:5000?pkt_size=1316&ttl=1"
> ---
>  libavformat/avformat.h  |    2 ++
>  libavformat/mpegtsenc.c |   10 +++++++---
>  2 files changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index b484649..c72c58f 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -161,6 +161,8 @@ struct AVFormatContext;
>   *                 E.g for "Also sprach Zarathustra", artist would be "Richard
>   *                 Strauss" and performer "London Philharmonic Orchestra".
>   * publisher    -- name of the label/publisher.
> + * service_name     -- name of the service in broadcasting (channel name).
> + * service_provider -- name of the service provider in broadcasting.
>   * title        -- name of the work.
>   * track        -- number of this work in the set, can be in form current/total.
>   */
> diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
> index bfd21db..14bbd62 100644
> --- a/libavformat/mpegtsenc.c
> +++ b/libavformat/mpegtsenc.c
> @@ -391,18 +391,22 @@ static int mpegts_write_header(AVFormatContext *s)
>      MpegTSWriteStream *ts_st;
>      MpegTSService *service;
>      AVStream *st, *pcr_st = NULL;
> -    AVMetadataTag *title;
> +    AVMetadataTag *title, *provider;
>      int i, j;
>      const char *service_name;
> +    const char *provider_name;
>      int *pids;
>  
>      ts->tsid = DEFAULT_TSID;
>      ts->onid = DEFAULT_ONID;
>      /* allocate a single DVB service */
>      title = av_metadata_get(s->metadata, "title", NULL, 0);
> +    if (!title)
> +        title = av_metadata_get(s->metadata, "service_name", NULL, 0);

shouldn't we prefer service_name over title since it's more specific?

>      service_name = title ? title->value : DEFAULT_SERVICE_NAME;
> -    service = mpegts_add_service(ts, DEFAULT_SID,
> -                                 DEFAULT_PROVIDER_NAME, service_name);
> +    provider = av_metadata_get(s->metadata, "service_provider", NULL, 0);
> +    provider_name = provider ? provider->value : DEFAULT_PROVIDER_NAME;
> +    service = mpegts_add_service(ts, DEFAULT_SID, provider_name, service_name);
>      service->pmt.write_packet = section_write_packet;
>      service->pmt.opaque = s;
>      service->pmt.cc = 15;

otherwise ok

> From d4d7438670eb1da745951a12bdb7918b8f0d5bb3 Mon Sep 17 00:00:00 2001
> From: Georgi Chorbadzhiyski <gf at unixsol.org>
> Date: Thu, 20 Jan 2011 15:24:53 +0200
> Subject: [PATCH 2/2] Set service_provider and service_name in mpegts demuxer
> 
> Set service_provider and service_name in mpegts demuxer, previously
> name and provider_name were set but since the muxer uses service_provider
> and service_name use them.
> ---
>  libavformat/mpegts.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
> index 01b69a7..d234316 100644
> --- a/libavformat/mpegts.c
> +++ b/libavformat/mpegts.c
> @@ -1211,8 +1211,8 @@ static void sdt_cb(MpegTSFilter *filter, const uint8_t *section, int section_len
>                  if (name) {
>                      AVProgram *program = av_new_program(ts->stream, sid);
>                      if(program) {
> -                        av_metadata_set2(&program->metadata, "name", name, 0);
> -                        av_metadata_set2(&program->metadata, "provider_name", provider_name, 0);
> +                        av_metadata_set2(&program->metadata, "service_name", name, 0);
> +                        av_metadata_set2(&program->metadata, "serivce_provider", provider_name, 0);
>                      }
>                  }
>                  av_free(name);

ok

Janne



More information about the ffmpeg-devel mailing list