Skip to content

HLS and recording corruption when processing H.264 MP4 files with malformed SEI NAL units #4728

Description

@Belal2

Describe the bug

Some uploaded H.264 MP4 files generated by a drone encoder contain malformed SEI (Supplemental Enhancement Information) NAL units.

The source MP4 files:

  • Pass the available media validation checks.
  • Are successfully analyzed by ffprobe.
  • Play normally in standard media players.
  • Contain valid and decodable video frames.

However, when Oryx/SRS remuxes these files into MPEG-TS segments for HLS and recording, the generated HLS stream and recorded video become corrupted or unplayable.

Our investigation indicates that the malformed H.264 SEI NAL units (NAL unit type 6) cause the parser to lose the correct NAL boundaries while generating the TS segments.

Removing the SEI units before processing resolves the problem:

ffmpeg -y -i affected.mp4 \
  -map 0 \
  -c copy \
  -bsf:v filter_units=remove_types=6 \
  sanitized.mp4

The sanitized file works correctly with the same Oryx/SRS pipeline.

This FFmpeg operation uses stream copy and does not re-encode the video. It only removes the H.264 SEI NAL units.

Version

  • Oryx version: v5.15.20
  • Deployment: Docker
  • SRS version: We are using the SRS version bundled with the Oryx v5.15.20 Docker image.

To Reproduce

Steps to reproduce the behavior:

  1. Run Oryx v5.15.20 using Docker.
  2. Upload or process an affected H.264 MP4 file generated by the drone encoder.
  3. Verify that the original MP4 plays normally and can be analyzed by ffprobe.
  4. Let Oryx/SRS generate the HLS stream and recording.
  5. Play the generated HLS playlist or recorded file.
  6. Observe that the generated TS segments and recording are corrupted or unplayable.
  7. Remove the H.264 SEI NAL units using:
ffmpeg -y -i affected.mp4 \
  -map 0 \
  -c copy \
  -bsf:v filter_units=remove_types=6 \
  sanitized.mp4
  1. Process sanitized.mp4 through the same Oryx/SRS pipeline.
  2. Observe that the HLS stream and recording work correctly.

Expected behavior

Oryx/SRS should handle malformed optional SEI NAL units without corrupting the following video NAL units or the generated MPEG-TS output.

The expected behavior could be one of the following:

  • Safely skip malformed SEI NAL units.
  • Provide an option to strip SEI units during processing.
  • Reject the input with a clear error before generating corrupted output.
  • Log enough information to identify the malformed NAL unit and its location.

The resulting HLS segments and recordings should remain playable without requiring video re-encoding.

Screenshots

Not applicable. The problem appears in the generated media stream and recording rather than in the Oryx UI.

Additional context

The original video cannot be shared publicly because it is private drone footage.

If needed, we may be able to provide redacted ffprobe output, SRS logs, FFmpeg logs, and other non-sensitive media metadata.

Important observations:

  • The original MP4 plays correctly.
  • The corruption appears when SRS generates TS segments for HLS and recording.
  • Removing H.264 NAL unit type 6 resolves the issue.
  • No re-encoding is required.
  • Video resolution, frame rate, codec, and quality remain unchanged after sanitization.
  • This suggests that the issue is related to malformed SEI parsing or NAL-boundary handling during the MP4-to-TS remuxing process.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TransByAITranslated by AI/GPT.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions