Skip to content

Drop undecodable audio streams during remux - #53

Open
kiskoza wants to merge 4 commits into
mainfrom
fixes/remux-with-undecodable-audio
Open

kiskoza wants to merge 4 commits into
mainfrom
fixes/remux-with-undecodable-audio

Conversation

@kiskoza

@kiskoza kiskoza commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

drop undecodable audio streams before remux

The old plain -c copy only kept the first audio stream during remuxig
the media. However, if the first audio is not decodable by ffmpeg (e.g.:
apac in a sample video), later ffmpeg executions will fail, even if it
would be able to execute the transcode using the non-default audio
stream.

The new code detects if there are any non-decodable audio streams and
pick the first decodable if need to.

reset internal data properly on load

Running the remux could change the number of audio streams as it only
keeps the first one. However, the memoized audio_streams instance
variable was never cleaned up, hence a later ffmpeg command tried to map
the second audio stream (marked decodable using the cache, but it had a
different index by that time) and generated a non-valid ffmpeg command.

New code cleans up the memoized instance variables to avoid this
situation.

The old plain `-c copy` only kept the first audio stream during remuxig
the media. However, if the first audio is not decodable by ffmpeg (e.g.:
apac in a sample video), later ffmpeg executions will fail, even if it
would be able to execute the transcode using the non-default audio
stream.

The new code detects if there are any non-decodable audio streams and
pick the first decodable if need to.
Running the remux could change the number of audio streams as it only
keeps the first one. However, the memoized audio_streams instance
variable was never cleaned up, hence a later ffmpeg command tried to map
the second audio stream (marked decodable using the cache, but it had a
different index by that time) and generated a non-valid ffmpeg command.

New code cleans up the memoized instance variables to avoid this
situation.
@kiskoza
kiskoza force-pushed the fixes/remux-with-undecodable-audio branch from 1767abe to f2eb668 Compare November 12, 2026 14:41
@kiskoza
kiskoza force-pushed the fixes/remux-with-undecodable-audio branch from f2eb668 to 616007e Compare November 12, 2026 14:57
@kiskoza kiskoza changed the title wip: drop undecodable audio streams before remux Drop undecodable audio streams during remux Nov 12, 2026
@kiskoza
kiskoza marked this pull request as ready for review November 12, 2026 15:28

@viktor-duka-inst viktor-duka-inst left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I trust you on the root cause fix, the change does exactly what is described in the PR

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.

2 participants