Skip to content

Fix webm recording when dealing with files that already exist#401

Merged
mondain merged 1 commit intoRed5:mainfrom
kdkd:cherry-pick-792e07f-20251126-124943
Nov 26, 2025
Merged

Fix webm recording when dealing with files that already exist#401
mondain merged 1 commit intoRed5:mainfrom
kdkd:cherry-pick-792e07f-20251126-124943

Conversation

@kdkd
Copy link
Copy Markdown

@kdkd kdkd commented Nov 26, 2025

Commit from kdkd fork 792e07f

io/webm/WebmWriter.java: Fixed two bugs:

  1. Append mode overwrites instead of appending: WebmWriter never seeks to
    the end of the target file in append mode, so writeTag writes from
    offset 0 and destroys existing data

  2. Existing file not truncated when rewriting: when append is false, the
    final copy writes new data to the destination but never truncates the
    file first. If the destination already exists and is larger than the
    new content, stale bytes remain at the end, producing a corrupted WebM.

Fixed by:

  1. Append mode now seeks to the end of the existing file before writing, so
    new data no longer overwrites from offset 0.

  2. Rewrite mode truncates the destination before copying temporary data,
    preventing stale trailing bytes from older, larger files.


1) Append mode overwrites instead of appending: WebmWriter never seeks to
    the end of the target file in append mode, so writeTag writes from
    offset 0 and destroys existing data

2) Existing file not truncated when rewriting: when append is false, the
    final copy writes new data to the destination but never truncates the
    file first.  If the destination already exists and is larger than the
    new content, stale bytes remain at the end, producing a corrupted WebM.

Fixed by:

1) Append mode now seeks to the end of the existing file before writing, so
    new data no longer overwrites from offset 0.

2) Rewrite mode truncates the destination before copying temporary data,
    preventing stale trailing bytes from older, larger files.
@mondain mondain merged commit cc248a5 into Red5:main Nov 26, 2025
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