[FFmpeg-devel] [PATCH] avformat/mxfenc: add h264_mp4toannexb bitstream filter if needed when muxing h264
Andreas Rheinhardt
andreas.rheinhardt at outlook.com
Fri Feb 23 03:26:26 EET 2024
Marton Balint:
> Partially fixes ticket #10395.
>
> Signed-off-by: Marton Balint <cus at passwd.hu>
> ---
> libavformat/mxfenc.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
> index 61ed6fc3db..adc31c1cf4 100644
> --- a/libavformat/mxfenc.c
> +++ b/libavformat/mxfenc.c
> @@ -3542,6 +3542,16 @@ static int mxf_interleave(AVFormatContext *s, AVPacket *pkt,
> return mxf_interleave_get_packet(s, pkt, flush);
> }
>
> +static int mxf_check_bitstream(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
> +{
> + if (st->codecpar->codec_id == AV_CODEC_ID_H264) {
> + if (pkt->size >= 5 && AV_RB32(pkt->data) != 0x0000001 &&
> + AV_RB24(pkt->data) != 0x000001)
> + return ff_stream_add_bitstream_filter(st, "h264_mp4toannexb", NULL);
> + }
> + return 1;
> +}
> +
> #define MXF_COMMON_OPTIONS \
> { "signal_standard", "Force/set Signal Standard",\
> offsetof(MXFContext, signal_standard), AV_OPT_TYPE_INT, {.i64 = -1}, -1, 7, AV_OPT_FLAG_ENCODING_PARAM, .unit = "signal_standard"},\
> @@ -3623,6 +3633,7 @@ const FFOutputFormat ff_mxf_muxer = {
> .p.flags = AVFMT_NOTIMESTAMPS,
> .interleave_packet = mxf_interleave,
> .p.priv_class = &mxf_muxer_class,
> + .check_bitstream = mxf_check_bitstream,
> };
>
> const FFOutputFormat ff_mxf_d10_muxer = {
> @@ -3656,4 +3667,5 @@ const FFOutputFormat ff_mxf_opatom_muxer = {
> .p.flags = AVFMT_NOTIMESTAMPS,
> .interleave_packet = mxf_interleave,
> .p.priv_class = &mxf_opatom_muxer_class,
> + .check_bitstream = mxf_check_bitstream,
> };
I sent the very same patch long ago [1]. Tomas Härdin opposed it [2],
[3], because he sees stuff like this as hack.
- Andreas
[1]: https://ffmpeg.org/pipermail/ffmpeg-devel/2021-November/287638.html
[2]: https://ffmpeg.org/pipermail/ffmpeg-devel/2021-November/287702.html
[3]: https://ffmpeg.org/pipermail/ffmpeg-devel/2021-November/287703.html
More information about the ffmpeg-devel
mailing list