Skip to content

Recorder upgrades (queue, FLAC, fonts, range sort)#8877

Merged
jeeb merged 5 commits intompv-player:masterfrom
TheAMM:recorder-upgrades
Jul 8, 2021
Merged

Recorder upgrades (queue, FLAC, fonts, range sort)#8877
jeeb merged 5 commits intompv-player:masterfrom
TheAMM:recorder-upgrades

Conversation

@TheAMM
Copy link
Contributor

@TheAMM TheAMM commented May 28, 2021

Here's a bunch of goodies for the recorder feature (dump-cache that is, --record-file can rot but does gain here too).
Includes fixes for some slight human errors, but also support for cache dumping FLAC streams (previously broken), streams with very long GOPs (also previously broken) and attaching embedded fonts when outputting to matroska (quite useful with ASS subtitles).

The packet queue (long GOPs) commit fixes #8278.

In commit f767857, wm4 chooses to mux
all remaining packets when mp_recorder_mark_discontinuity() is called and
adds a call to mux_packets(). However, it is called only after flush_packets(),
which clears the packets before they can be muxed out. This has no ill
effects per se  - recordings end on keyframes, as before - but judging from
his commit message, the intention explicitly was to output the inter
frames, since long GOPs can mean several seconds of missing content from
the output. So, clear the stream packet queues only after the final mux.

Also, flushing can mean both discarding and committing. What a country!
Sagnac added a commit to Sagnac/streamsave that referenced this pull request Jun 4, 2021
Document new force_extension option.

Revise the Known Issues section in accordance with the codec_tag fix in
mpv-player/mpv@643c699 and the upcoming packet queue fix etc. in
mpv-player/mpv#8877
@TheAMM TheAMM force-pushed the recorder-upgrades branch from 2e6eec2 to 8821dcc Compare June 8, 2021 02:15
@TheAMM
Copy link
Contributor Author

TheAMM commented Jun 8, 2021

Replaced 7b2311e (av_common FLAC extradata fix) with more proper a9fb11c (demux_mkv FLAC extradata fix) as per IRC stuff, and removed the allocation error log from recorder.c font muxing.

@TheAMM TheAMM force-pushed the recorder-upgrades branch from 8821dcc to c14892c Compare June 13, 2021 05:32
dump_cache() calls qsort() to order an array of pointers, while the
comparator forgets it's receiving pointers to pointers.
Since cache-dumping over multiple cache ranges is fairly rare, this
seems to have gone unnoticed.
Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me anyway.

@TheAMM TheAMM force-pushed the recorder-upgrades branch from c14892c to 8b7eb73 Compare June 30, 2021 18:26
@TheAMM
Copy link
Contributor Author

TheAMM commented Jun 30, 2021

Force-pushed the updated range sort commit as discussed on IRC.

@TheAMM TheAMM force-pushed the recorder-upgrades branch from 8b7eb73 to 786b867 Compare July 5, 2021 21:47
@TheAMM
Copy link
Contributor Author

TheAMM commented Jul 5, 2021

Forced again to replace the matroska demuxer patch a9fb11c with an av_common FLAC extradata fix 68f8c5b.

@TheAMM TheAMM force-pushed the recorder-upgrades branch from 786b867 to 585c1ad Compare July 8, 2021 09:13
TheAMM added 3 commits July 8, 2021 12:16
For muxing, FFmpeg expects the FLAC extradata to be just the bare STREAMINFO,
and passing the full FLAC extradata (fLaC header and block size, with any
additional channel layout metadata) will result in malformed output, as
ffmpeg will simply prefix another fLaC header in front.
This can be considered to be a bug.

FFmpeg's own demuxers only store the STREAMINFO, hence the naivety, while
our common source of FLAC streams, the matroska demuxer, holds onto the
full extradata. It has been deemed preferable to adjust the extradata upon
muxing, instead of in the demuxer (ffmpeg's FLAC decoder knows to read
the full fLaC extradata).

This fixes muxing FLAC streams, meaning recorder.c or dump-cache.
I've looked and studied the flow in the recorder, and to my
understanding, the packet queue is moot after the initial sync, maybe
even then - but that's beyond me right now.
With the previous choice to mux trailing packets whatever the case, this
doesn't result in any new ill effects (and some missing packets at the
end is no big deal).
Notably, since we don't have to hold onto the packets after we get
muxing, we'll never run into any issues with veeery long GOPs filling up
our queue (resulting in dropped packets and much user chagrin).
Though, only when the output format is matroska, to avoid muxing errors.
This is quite useful when the input has ASS subtitles, as they tend to
rely on embedded fonts.
@TheAMM TheAMM force-pushed the recorder-upgrades branch from 585c1ad to 38ce821 Compare July 8, 2021 09:16
Copy link
Member

@jeeb jeeb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

The reason for doing the extradata filtering on the muxing side of things is because the interface between a demuxer and the following component for decoder initialization data AKA extradata (usually decoder, but can be other things like the recorder) is the decoder initialization data specified in the container (just like avc or hevc or av1 configuration record is passed on to decoders).

I have only taken a limited look at the packet queue removal bits, but since @sfan5 has noted that he has taken a look at that, I am OK with that.

@jeeb jeeb merged commit 4d3df1c into mpv-player:master Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dump-cache not working on YouTube video

3 participants