Repository navigation
Description
Summary
A plain SD MKV with mono MP3 audio cannot be played on the native route at all. The mp3 → E-AC-3 bridge is selected, the first segment cut is deferred because no audio sample entry can be built, the forward prime scan does not find one, the pump exits muxerFailed, both rebuilds fail identically, the revive cap is reached and the session ends with:
Source audio cannot be muxed (code -22)
Reproduced nine times out of nine, at nine different start positions including 0.00s, on the same file. The software route plays the same file perfectly.
This looks distinct from the three neighbours, and I have tried to rule each out below rather than assume:
- EAC3 first segment with no audio wedges the muxer: cutFragmentForNextSegment lacks the moov guard flushPendingFragment has #222 — its guard is present and doing its job here. The log line is literally
AE#222 … cut deferred … scanning forward for a prime frame, i.e. the muxer is correctly declining to write a moov. What fails is the scan that follows. - muxerFailed / permanent black screen: first-segment audio prime scan gives up when the selected audio track is sparsely interleaved (UHD remux) #366 — there the selected source track was sparsely interleaved and physically far away (Czech AC-3 in a 61.8 GB UHD remux). Here the source audio is 9 ms from the first video packet (
audio gate open: actual=9 target=0 … gapMs=0.0), so the source packet is not what is missing. The 6.25.x midpoint-seeking scan is in this build. - VOD start at resume position with bridged audio (mp3→EAC3) never becomes ready; recovery re-anchor kills the muxer ("Cannot write moov atom before EAC3 packets parsed") with no escalation (#93 residual) #99 — that was bridged mp3→EAC3 at a non-zero
startPosition, arriving via the seek/re-anchor path. This reproduces identically from 0.00s with no seek at all.
Environment
- AetherEngine 6.27.1
- iPad mini (6th generation), iOS 26.5 (23F77)
- Host: our Flutter app, own
video_playerbackend; AetherEngine as rung 1, libVLC as rung 2 - Route: native / loopback (
canHardwareDecode codec=27 640x272 -> true)
Source media (ffprobe)
Matroska over HTTP from an Xtream-style IPTV origin, 358,378,434 B. Absolute byte ranges are
honoured (206); the origin does not honour suffix ranges, which the engine notices once
and stops asking for — pump tail prefetch rejected after 1676ms: Content-Range: bytes -65536/358378434 does not describe the 65536B asked for; not asking this origin again this session. Mentioning it only to be complete: it is the same on every run, including the ones
where the software route plays the file to the end.
0 h264 video 640x272 High/L2.1 yuv420p 23.976 fps tel (default)
1 mp3 audio mono 44100 Hz 40 kb/s tel (default) <- selected
2 mp3 audio mono 24000 Hz 32 kb/s tam
3 mp3 audio mono 24000 Hz 32 kb/s hin
4 subrip sub eng (default)
duration 7070.189s, overall bitrate ~405 kb/s
What the engine does
[AetherEngine] dispatch: codec=27 → native
[HLSVideoEngine] video codecpar: codec=27 640x272 profile=100 level=21 fieldOrder=1 extradata=44B head=01640015ffe1001c
[HLSVideoEngine] segment plan: keyframe-aligned, 2152 IRAPs → 1690 segments [firstKeyframePts=0 (0.000s) videoStream.start_time=0 format.start_time=0us plan[0].startSeconds=0.000]
[HLSVideoEngine] audio: codec=mp3 (bridge required), decoding + EAC3 re-encode
[AudioBridge] init: mode=surroundCompat srcCodec=86017 sampleRate=44100 sourceChannels=1 encoderChannels=1 bitRate=128 kbps (source=container, container=1, decoder=1)
[HLSSegmentProducer] init OK (baseIndex=0, segments=1674, targetDur=4.000s, srcVideoTb=1/1000) audio=bridge inTb=1/44100
[HLSVideoEngine] prepared: codec=avc1.640015,ec-3 resolution=640x272 fps=23.976 range=SDR DV=none segments=1674 duration=7070.2s
[AetherEngine] #321: effective video route = loopback
The failure, from 0.00s
[HLSSegmentProducer] video gate open: actual=0 anchorPts=0 target=-9223372036854775808 desired=0 shift=0 videoPID=0 reconstructed=false
[HLSSegmentProducer] first video pkt: dts=0 pts=0 duration=41 size=1060 (fallback=41 in srcVideoTb)
[HLSSegmentProducer] audio gate open: actual=9 target=0 desired=0 shift=0 gapMs=0.0
[HLSSegmentProducer] #65 ledger seg-0 base=0 itemAxis=0.000s sourceStart=0.000s planSource=0.000s drift=0.000s shift=0.000s
[HLSSegmentProducer] #65 ledger seg-1 base=0 itemAxis=20.771s sourceStart=20.771s planSource=10.427s drift=10.344s shift=0.000s
[HLSSegmentProducer] AE#222 seg-0.m4s cut deferred: audio sample entry needs a parsed packet and none has been muxed; scanning forward for a prime frame
[HLSSegmentProducer] pump finished: reason=muxerFailed packetsRead=1308 packetsWritten=500 lastError=0 elapsed=526ms cacheCount=0
[HLSVideoEngine] #99 VOD pump died with muxerFailed; rebuilding producer + muxer at 0.00s -> seg0 (attempt 1/2)
… identical, elapsed=19ms …
[HLSVideoEngine] #99 VOD pump died with muxerFailed; rebuilding producer + muxer at 0.00s -> seg0 (attempt 2/2)
… identical, elapsed=15ms …
[HLSVideoEngine] #99 VOD muxerFailed revive cap reached (3 failures, cap 2); giving up (source not muxable in this session)
Two things stand out to us, offered as observation rather than diagnosis:
- The source audio is right there.
gapMs=0.0, first audio packet at 9 ms. Whatever is missing is downstream of the demuxer — the bridge's encoded E-AC-3 output, not a source packet. - The scan does travel.
seg-1lands atsourceStart=20.771sagainstplanSource=10.427s, a 10.3 s drift, so roughly twenty seconds of media went by without an audio sample entry ever being available.
Every attempt, same file
Nine sessions, nine start positions, nine identical outcomes. packetsWritten/packetsRead is 0.37–0.38 throughout.
| startPosition | anchor seg | packetsRead | packetsWritten | first attempt |
|---|---|---|---|---|
| 0.00 s | seg-0 | 1308 | 500 | 526 ms |
| 2214.00 s | seg-545 | 584 | 221 | 400 ms |
| 2483.00 s | seg-611 | 602 | 228 | 763 ms |
| 2932.00 s | seg-720 | 1025 | 389 | 447 ms |
| 3331.00 s | seg-809 | 811 | 305 | 487 ms |
| 5295.00 s | seg-1306 | 713 | 270 | 650 ms |
| 5658.00 s | seg-1398 | 589 | 222 | 496 ms |
| 5867.00 s | seg-1451 | 414 | 155 | 489 ms |
| 5908.00 s | seg-1460 | 494 | 185 | 429 ms |
Both rebuilds always read exactly the same packet counts as the first attempt and fail in 12–23 ms, so as in #222 the retry re-enters the same configuration rather than changing the decision that caused the failure.
Two things we checked so you don't have to
- The software route plays this file completely. Same URL, same 6.27.1, on the iOS simulator, which has no VideoToolbox decoder —
codec=27 not hardware-decodable by VideoToolbox; routing to the software path so it plays instead of a black screen (#2): 683 frames in 30 s,route=software, all three audio tracks named and selectable, subtitle selection works. So demux and decode of this file are fine; the failure is confined to the loopback muxer path. - Mono 44.1 kHz E-AC-3 into fragmented MP4 is not inherently impossible. Standalone,
ffmpeg -f lavfi -i sine=…:sample_rate=44100 -ac 1 -c:a eac3 -b:a 128k -movflags +empty_moov+default_base_moof+frag_keyframe+delay_moov -f mp4produces a valideac3 / 44100 / 1chtrack. We are not claiming that is the same code path — only that the encoder configurationAudioBridgereports is one ffmpeg will accept.
Impact for us
Low, and we are not blocked: our ladder demotes to libVLC and the viewer gets a picture. We are reporting it because mono MP3 in MKV is ordinary IPTV catalogue material rather than an exotic shape, and because a source the software route plays end to end is worth having on the native route too.
Happy to run any diagnostic build against this file, or to try a synthetic reproduction if you would like one — a three-track mono-MP3 MKV should be straightforward to generate.
🤖 Written and posted by Claude Code on behalf of @ksktech-dev.
Activity
fix(audio): a silent transcoding bridge names itself instead of dying…
superuser404notfound commentedon Aug 18, 2026
Thanks for this, and for ruling out #222, #366 and #99 before filing. All three checks were the right ones and all three answers hold up, which saved a wrong start.
Reproduced 1:1
Fixture: a mono MP3 44.1 kHz MKV whose audio payloads the decoder cannot make a frame of. The session comes out line for line the same, including the two rebuilds finishing in 2 to 3 ms with identical packet counts and the terminal
Source audio cannot be muxed (code -22).Observation 1 was exactly right, and it is the entire failure
What is missing is the bridge's encoded output, not a source packet. FFmpeg's mp4 muxer can only build an AC-3/E-AC-3 sample entry from a packet it has PARSED, and on a bridged source those packets come from the bridge's encoder. It emitted none for the whole of segment 0. Everything after that follows mechanically: the cut defers (the #222 guard doing its job), the pump exits
muxerFailed, the revive cap ends the session, and the sentence that reaches the viewer names the muxer and the source, which are the two subsystems that were fine.Observation 2 needs one correction, because it points somewhere else
The scan did not travel.
scanForAudioMoovPrimeFrameis scoped to single-demuxer stream-copy audio and returns without looking on a bridged session: there is nothing in the source to scan for, since the frames the muxer needs come out of the encoder. The line promising a forward scan was printed unconditionally, so it announced an action that never happened, on the one path where the interesting question had no log line at all. That is fixed.The
seg-1ledger line is not the scan either. It is the video cutter reaching plan index 1, which is what REQUESTS the segment-0 cut. So the 10.3 s gap betweenplanSourceand the actual keyframe is a separate property of that file (the plan's boundaries come from the container index, the cutter waits for a real IRAP) and is unrelated to the audio. What the two lines together do establish is your conclusion: about 20.8 s of media went by with no audio sample entry ever becoming available.A synthetic reproduction would not help, though thanks for offering
I built the three-track mono-MP3 MKV first. It plays. Mono 44.1 kHz MP3 through the
surroundCompatbridge produces a validec-3 / 44100 / 1 chtrack on the native route, both with a 4 s first segment and with a 20.8 s one. So neither mono, nor 44.1 kHz, nor a long first segment is the trigger. Something specific to that file's audio is, and only that file can say what.What is on
mainnow (9870892c, PR #397)The reason neither of us can name the failing step from your log is that there is no step to read. Every stage between a source packet and an encoded frame ends in a
returnor in a loop that stops on a negative code: a packetavcodec_send_packetrejects,while avcodec_receive_frame(...) >= 0(which reads as "drain what is there" and behaves as "drop the reason there is nothing"), four early returns in the resampler,avcodec_receive_packetbreaking on any negative code. Per packet that is right, one bad frame must not end a session. In aggregate it made a bridge that emitted nothing for a whole segment indistinguishable from one that had simply not been asked yet.AudioBridgenow counts each of those arms and keeps the decoder's own error code instead of discarding it.PlaybackErrorKind.audioBridgeProducedNoOutputfor the failure, replacingvodSourceFailed. For a ladder that matters:vodSourceFailedreads as "the source is gone" and is a reason to stop, while here the source is neither gone nor unreadable and a second engine that decodes the track itself plays the file. This one is a demote.It is on
main; say the word if a tagged build is easier to vendor and I will cut one.One discriminator, and it needs no new build at all
Both routes open the mp3 decoder identically:
avcodec_parameters_to_contextfollowed byavcodec_open2(ctx, codec, nil), no options, inAudioDecoderand inAudioBridgealike.So: on the software route, does that file actually produce sound? The report says the three tracks are named and selectable, which is a demuxer statement rather than a decoder one.
With the build, one line settles it, either at the deferred cut or as
[AudioBridge] ERROR: AE#396 ..., in this shape:decoded=0is a decoder verdict.decoded>0 emitted=0is the encoder. Frames decoded withenqueued=0is the resampler.Leaving this open: the change makes the failure legible and stops it costing three attempts, it does not yet make that file play. That needs the arm named.
superuser404notfound commentedon Aug 18, 2026
Tagged: 6.31.0, so this can be vendored as a pin rather than off
main.Minor rather than patch because of the new
PlaybackErrorKind.audioBridgeProducedNoOutput; nothing else in the public API moved, and healthy bridged playback is unchanged.The cheap question still stands ahead of any run: on the software route, does that file actually produce sound, or do the three tracks only list and select?
kskchaitanya1993 commentedon Aug 21, 2026
Resolved, and it was not a defect in the engine — our app was linking a second FFmpeg over yours. Sorry for the noise. Your 6.31.0 counters found it in a single run, and there is one thing in here that is genuinely yours, at the bottom.
The counters answered it immediately
fed == decodedon every packet, 2,785,536 samples into the resampler. The encoder arm, by your own table — which also retires the cheap question: the decoder was never involved, so "audible on software" could not have discriminated anything.It was never that file
fed=2418 decoded=2418 enqueued=2785536 emitted=0fed=2757 decoded=2757 enqueued=3176064 emitted=0fed=687 decoded=687 enqueued=791424 emitted=0fed=840 decoded=840 enqueued=860160 emitted=0fed=894 decoded=894 enqueued=857928 emitted=0Not mono, not 44.1 kHz, not mp3, not that origin — the last three were served from a local server that answers absolute ranges cleanly. Every bridged source on that build emitted nothing. Nothing of ours is needed to reproduce it; the third row is
and the last two are the same video with
-c:a pcm_s16leor-c:a libopus. The container and the source codec are irrelevant; the trigger is entirely host-side.What it was
The line that gave it away is one neither of us was reading:
It is not absent from yours.
Libavcodec.frameworkas shipped is62.28.102, its configure ends--enable-encoder=flac --enable-encoder=eac3, and both encoders' encoder-only AVOptions are in that binary. The engine was not asking your libavcodec.Our app also shipped MediaBridge, an older FFmpeg→HLS path of our own, whose FFmpeg was
-force_loaded as a static archive into the executable — so its symbols became ordinary external definitions, and a definition in a.obeats a dylib for every other object in the same link:That build has
--enable-encoder=eac3and no--enable-encoder=flac— exactly and only the combination the engine reported. AetherEngine expects libavcodec 62 and was executing against 61.The control, before we touched anything: the file from this issue, unchanged, on our tvOS app, which links the same engine and had no second FFmpeg —
FLAC bridge, playing,
packetsWritten=4076 muxCuts=39at t=30s. Same engine, same file, same 6.32.0.Fixed on our side
MediaBridge had already been superseded by AetherEngine and switched off in our code — it was doing no work and still linking a whole FFmpeg — so we deleted it rather than contained it. The engine now binds its own dylibs, and the file plays on the native route:
Close this as invalid whenever suits.
One thing we ran into that we could not fix upstream of ourselves
Removing our static copy turned out not to be enough on its own, and this is the part we would value your view on. Before we corrected the link order, the engine still did not reach your dylib — it bound MobileVLCKit's:
libVLC beside AetherEngine is a fairly ordinary shape for the fallback ladder your API is built around, and CocoaPods puts it earlier in the link than a vendored framework. We fixed ours by forcing your frameworks ahead of it, which works, but it is a workaround we only found because we already knew what to look for.
Two ideas, offered rather than asked for — you will have context we do not, and either may be more trouble than it is worth:
Would a libavcodec version check at init be worth adding?
avcodec_versionandavcodec_configurationappear zero times in the shipped binary, so as far as we can tell the engine has no way to notice it is running against a different major. Comparing the compile-timeLIBAVCODEC_VERSION_MAJORwith the runtimeavcodec_version()would have pointed us at this in the first minute instead of after five fixtures and two devices. If you did add it, the same value might be worth carrying intoflac bridge encoder absent from this FFmpeg build— that line reads as a statement about your build, and in our case it was really the first symptom of the wrong build being loaded.Is namespacing the vendored FFmpeg symbols feasible? It would remove the failure mode entirely rather than leaving each host to discover it. We appreciate this is a much larger change than the first, and possibly not one you want.
Happy either way, and thank you for the counters — they are what made this findable at all.
Your correction about
scanForAudioMoovPrimeFramereturning without looking on a bridged session, and about theseg-1ledger line being the cutter rather than the scan, both hold. The deferred-cut line printing the bridge account instead of announcing a scan it does not run is what made any of this legible.This comment was drafted and posted automatically by Claude, working on behalf of @kskchaitanya1993.
superuser404notfound commentedon Aug 22, 2026
That is a complete diagnosis, and the control is what makes it one: the same file, the same engine, the same 6.32.0, on a build with no second FFmpeg, playing. Nothing left to argue with.
Both of the ideas were worth having. The first is built and out.
The check is in, in 6.34.1
Every session now opens with the FFmpeg that answered:
and when a major does not match the headers the engine compiled against, that line becomes an
ERROR:naming the mismatch, the two shapes that cause it, the probes, and the configure line of the libavcodec that answered. On the build described here it would have read:Two things beyond the suggestion. All four linked libraries are checked, not just libavcodec: libavutil is the one that really matters, because a major shift there moves struct layouts, so that failure is a crash rather than a silence, and it would have been read as an engine crash. And the healthy line is emitted too, since "which FFmpeg answered" is not reconstructible afterwards from a log that stayed quiet.
The second half of the suggestion is in as well. The cascade message now reads
flac bridge encoder absent from libavcodec 61.19.101, NOT the 62.x this engine was built against, so a sentence about "this FFmpeg build" always says which build it means. That line was true and pointed the wrong way, which is the whole cost of this issue.Namespacing, declined, and the reasoning is worth having on the record
It needs a post-build symbol rewrite across every slice plus rewritten headers, and it breaks every consumer that uses the FFmpeg headers directly, which is a real group. The cause is also not really the shared symbol names: it is that link order is the host's to set and nothing inside a library can reach it. So the gap was a witness, not a rename.
The libVLC half is documented rather than solved
That part is the more useful finding of the two, because it is not a mistake anyone made. libVLC beside AetherEngine is the ordinary shape for the ladder this API invites, CocoaPods sorts a pod ahead of a vendored framework by default, and removing a force-loaded static copy therefore does not finish the job.
docs/api.mdcarries it as a host contract now, with thenm -moutput in both of its forms, and the README says it next to the note about the frameworks staying dynamically embedded. Being dynamically embedded is not the same as being reached, which was not written down anywhere before.Closing as invalid, as suggested. Thanks for chasing this all the way into your own link and then writing it up properly instead of stopping at "fixed on our side"; the five fixtures across three codecs and two containers are what made the host-side conclusion airtight, and this release exists because of the write-up.