[FFmpeg-devel] [PATCH] avformat: add mpegtsraw muxer

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue Dec 22 02:58:22 EET 2020


Aman Karmani:
> From: Aman Karmani <aman at tmm1.net>
> 
> Allows easier writing of a AV_CODEC_ID_MPEG2TS stream out to disk.
> 
> Signed-off-by: Aman Karmani <aman at tmm1.net>
> ---
>  libavformat/Makefile     |  1 +
>  libavformat/allformats.c |  1 +
>  libavformat/rawenc.c     | 14 ++++++++++++++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 97d868081b..ad528de589 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -350,6 +350,7 @@ OBJS-$(CONFIG_MPEG2VOB_MUXER)            += mpegenc.o
>  OBJS-$(CONFIG_MPEGPS_DEMUXER)            += mpeg.o
>  OBJS-$(CONFIG_MPEGTS_DEMUXER)            += mpegts.o
>  OBJS-$(CONFIG_MPEGTS_MUXER)              += mpegtsenc.o
> +OBJS-$(CONFIG_MPEGTSRAW_MUXER)           += rawenc.o
>  OBJS-$(CONFIG_MPEGVIDEO_DEMUXER)         += mpegvideodec.o rawdec.o
>  OBJS-$(CONFIG_MPJPEG_DEMUXER)            += mpjpegdec.o
>  OBJS-$(CONFIG_MPJPEG_MUXER)              += mpjpeg.o
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 0e0caaad39..6106344ba0 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -279,6 +279,7 @@ extern AVInputFormat  ff_mpegps_demuxer;
>  extern AVInputFormat  ff_mpegts_demuxer;
>  extern AVOutputFormat ff_mpegts_muxer;
>  extern AVInputFormat  ff_mpegtsraw_demuxer;
> +extern AVOutputFormat ff_mpegtsraw_muxer;
>  extern AVInputFormat  ff_mpegvideo_demuxer;
>  extern AVInputFormat  ff_mpjpeg_demuxer;
>  extern AVOutputFormat ff_mpjpeg_muxer;
> diff --git a/libavformat/rawenc.c b/libavformat/rawenc.c
> index 32704f9bfd..38def493cf 100644
> --- a/libavformat/rawenc.c
> +++ b/libavformat/rawenc.c
> @@ -465,6 +465,20 @@ AVOutputFormat ff_mpeg2video_muxer = {
>  };
>  #endif
>  
> +#if CONFIG_MPEGTSRAW_MUXER
> +AVOutputFormat ff_mpegtsraw_muxer = {
> +    .name           = "mpegtsraw",
> +    .long_name      = NULL_IF_CONFIG_SMALL("raw MPEG-TS"),
> +    .mime_type      = "video/MP2T",
> +    .extensions     = "ts,m2t,m2ts,mts",
> +    .audio_codec    = AV_CODEC_ID_NONE,
> +    .video_codec    = AV_CODEC_ID_NONE,
> +    .data_codec     = AV_CODEC_ID_MPEG2TS,
> +    .write_packet   = ff_raw_write_packet,
> +    .flags          = AVFMT_NOTIMESTAMPS,
> +};
> +#endif
> +
>  #if CONFIG_RAWVIDEO_MUXER
>  AVOutputFormat ff_rawvideo_muxer = {
>      .name              = "rawvideo",
> 
Why don't you just use the data muxer instead of adding a new muxer with
the same extensions and mime type as an existing (and preferable) muxer?

- Andreas


More information about the ffmpeg-devel mailing list