From: Marton Balint <cus@passwd.hu>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] libavformat/mpegtsenc.c -- correctly re-emit extradata ahead of IDR pictures
Date: Mon, 30 Jan 2023 22:12:05 +0100 (CET)
Message-ID: <d194d3d-3f79-f365-6344-f49359ea5dc@passwd.hu> (raw)
In-Reply-To: <CAEP=B=E2bgrVixcpAo1B6aTv8u5eGmjxYyrjwbGCG_ownvZC6w@mail.gmail.com>
On Mon, 30 Jan 2023, John Coiner wrote:
> Marton Balint wrote:
>> This does not look right, because AFAIK you always want to insert an AUD
>> unless it is already there. I guess that is why current code works as it
>> is, it assumes if an AUD is already present, then IDR-s are already
>> prefixed with SPS/PPS, and no magic is needed.
>
> I'm not sure if it should be valid to assume that an AUD implies that
> an SPS/PPS will follow,
Well, most likely not, but worked mostly in the past...
> but this is how the above command makes that
> assumption go wrong:
>
> * The HLS muxer requests global headers as input:
> https://github.com/FFmpeg/FFmpeg/blob/2d202985b79630cd5056c4e32f8f77f22bf1067c/libavformat/hlsenc.c#L3194
> * This sets the AV_CODEC_FLAG_GLOBAL_HEADER option for the codec:
> https://github.com/FFmpeg/FFmpeg/blob/2d202985b79630cd5056c4e32f8f77f22bf1067c/fftools/ffmpeg_mux_init.c#L599
> * The libx264.c codec responds to this option by producing
> extradata, and also by configuring x264 not to repeat SPS and PPS
> in-band: https://github.com/FFmpeg/FFmpeg/blob/2d202985b79630cd5056c4e32f8f77f22bf1067c/libavcodec/libx264.c#L1044
> * When x264 runs with its "aud" option, it emits AUDs.
> * The AUDs inhibit mpegtsenc.c from emitting the extradata,
> producing the buggy behavior.
>
> An alternative to changing the extradata "magic" in mpegtsenc would be
> for the HLS muxer to re-emit the extradata on its own. The HLS muxer
> has good context for this: it knows when new HLS media segments begin,
> and it knows that each one must begin with SPS and PPS if the encoder
> didn't already include them. It knows it's producing HLS. The
> mpegtsenc muxer doesn't know any of this.
>
> Would it be safer to fix in hlsenc.c and leave mpegtsenc alone? It's
> not clear to me that the mpegtsenc logic is verifiable or falsifiable
> to stronger than a "happens to work" standard; a fix in hlsenc.c could
> be.
For normal mpegts it also makes sense to include SPS/PPS before IDR-s, so
I'd say it is better if it is fixed in mpegtsenc.
But it is mandatory to insert AUD NAL-s for every frame, and your patch
breaks that, because it only inserts it if SPS/PPS is also inserted,
because you changed
if ((state & 0x1f) != 9) { // AUD NAL
to
if (extradd > 0) {
So you need to rework your patch to keep the AUD insertion (but you don't
want to duplicate it of course).
Regards,
Marton
_______________________________________________
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".
next prev parent reply other threads:[~2023-01-30 21:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 15:13 John Coiner
2023-01-30 17:36 ` John Coiner
2023-01-30 21:12 ` Marton Balint [this message]
2023-02-02 17:43 ` John Coiner
-- strict thread matches above, loose matches on Subject: below --
2023-01-31 12:45 John Coiner
2023-02-05 23:33 ` Marton Balint
2023-02-11 16:38 ` John Coiner
2023-01-27 21:18 John Coiner
2023-01-29 12:30 ` Marton Balint
2023-01-26 19:16 John Coiner
2023-01-26 18:43 John Coiner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d194d3d-3f79-f365-6344-f49359ea5dc@passwd.hu \
--to=cus@passwd.hu \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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