Skip to content

fix(issues): G.711 audio - #114

Merged
keyldev merged 3 commits into
mainfrom
fix/issues-112-113
Nov 11, 2026
Merged

keyldev merged 3 commits into
mainfrom
fix/issues-112-113

Conversation

@keyldev

@keyldev keyldev commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Fixes #112 Fixes #113

  • G.711 audio (pcm_alaw/pcm_mulaw) from OpenIPC cameras made
    avformat_write_header fail with EINVAL, so Android recorded nothing.
  • Streams avformat_query_codec rejects are dropped with a warning.
  • "-c copy" into mp4 failed on G.711 audio (pcm_alaw/pcm_mulaw), so desktop
    recorded nothing from such cameras.
  • Map only video + optional audio, copy video, encode audio to AAC.

Related

Type

  • Bug fix
  • Feature
  • Refactor / cleanup
  • Docs / CI
  • Other:

Checklist

  • Builds with 0 warnings (TreatWarningsAsErrors=true).
  • Tests pass (dotnet test); new Core logic has unit tests.
  • No layering violation — App references Core only (Infrastructure / Video / Devices wired via DI in a head).
  • Scope stays within one phase (didn't pull work from a later phase's "Не входит").
  • README / docs updated if public commands, options, or setup changed.

Platforms tested

  • Windows
  • Linux
  • macOS
  • Android
  • iOS
  • CI build only

Screenshots / notes

- G.711 audio (pcm_alaw/pcm_mulaw) from OpenIPC cameras made
  avformat_write_header fail with EINVAL, so Android recorded nothing.
- Streams avformat_query_codec rejects are dropped with a warning.
- "-c copy" into mp4 failed on G.711 audio (pcm_alaw/pcm_mulaw), so desktop
  recorded nothing from such cameras.
- Map only video + optional audio, copy video, encode audio to AAC.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix MP4 recording from cameras with G.711 audio

🐞 Bug fix 🕐 20-40 Minutes

Grey Divider

AI Description

• Preserve desktop recordings by encoding camera audio as AAC while copying video into MP4.
• Preserve Android video recordings by skipping streams the MP4 muxer cannot accept.
Diagram

graph TD
    Cam["Camera streams"] --> Cli["Desktop FFmpeg"] --> Aac["AAC audio"] --> Mp4["MP4 recording"]
    Cam --> Native["Android libavformat"] --> Gate{"MP4 supported?"} -->|yes| Mp4
    Cli -->|copied video| Mp4
    Gate -->|no: skip| Drop["Skipped stream"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Encode Android audio to AAC too
  • ➕ Preserves G.711 audio on both platforms
  • ➕ Provides consistent recording contents
  • ➖ Requires a native decode-and-encode pipeline instead of stream copying
  • ➖ Adds mobile CPU cost and implementation complexity

Recommendation: The split approach is pragmatic for restoring recordings: desktop can use FFmpeg's AAC encoder directly, while Android retains its simpler remuxing pipeline and prioritizes video. Consider native AAC encoding separately if preserving Android audio is a requirement.

Files changed (2) +24 / -1

Bug fix (2) +24 / -1
FfmpegRecordingSession.csMap camera media explicitly and encode desktop audio to AAC +9/-1

Map camera media explicitly and encode desktop audio to AAC

• Replaces blanket stream copying with video and optional audio mapping. Video remains copied, while audio is encoded to AAC so G.711 audio does not prevent MP4 recording; other track types are excluded.

src/OpenIPC.Viewer.Video/Recording/FfmpegRecordingSession.cs

LibavformatRecordingSession.csSkip MP4-incompatible streams in native recordings +15/-0

Skip MP4-incompatible streams in native recordings

• Checks video and audio codecs against the MP4 muxer before creating output streams, logging a warning when one is skipped. Fails explicitly if no output streams remain instead of attempting to write an empty recording.

src/OpenIPC.Viewer.Video/Recording/LibavformatRecordingSession.cs

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. The recording project fails to compile ⊘ Outdated
Description
The new LogWarning call passes the native pointer returned by ffmpeg.avcodec_get_name directly
as a logging argument, but a pointer cannot be used as a generic argument or boxed into the logging
overload's object array. Building the Video project reaches this call even before an unsupported
camera stream is encountered.


Remediation recommended

2. Some cameras produce audio-only recordings ✓ Resolved
Description
The new outputCtx->nb_streams guard accepts an audio stream as sufficient even though the codec
filter may have discarded the camera's video stream. When video is unsupported but audio is
supported, the session writes the audio, emits Started, and registers a recording with no picture.

Grey Divider

Tip of the day
💡 Did you know, you can import rules and skills only from the repositories your team follows

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

- If mp4 rejected the video but kept the audio, the recording was audio-only.
- Fail before opening the output unless at least one video stream survives.
@keyldev
keyldev merged commit 14ad3ad into main Nov 11, 2026
5 of 6 checks passed
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.

Recording fails with "Conversion failed!" when RTSP stream contains G.711 (pcm_alaw) audio Can't Record - Tenda IT7-L(P)RS

1 participant