Skip to content

Instantly share code, notes, and snippets.

@datio
Created March 8, 2026 18:02
Show Gist options
  • Select an option

  • Save datio/1154bbae00a22eb9c96f8da0bf8588ac to your computer and use it in GitHub Desktop.

Select an option

Save datio/1154bbae00a22eb9c96f8da0bf8588ac to your computer and use it in GitHub Desktop.
Ctronics Camera Files & Linux Tools

Ctronics Camera Files & Linux Tools

1. Ctronics / Hikvision Proprietary Container

  • Files with .h265 extension from Ctronics cameras are not standard H.265 bitstreams
  • They use a proprietary HXVT/HXVF/HXVS container format (magic bytes: HXVT, HXVF at file header)
  • This is why ffprobe, mediainfo, and cat concat all failed to detect audio
  • The NALU type 40 errors in ffmpeg are caused by this proprietary wrapper

2. FFmpeg HXVS Support

  • FFmpeg bug #9245 tracked missing HXVS/HXVF/HXVT support — fixed in git master (commit e1d946f)
  • The fix was NOT included in the stable ffmpeg n8.0.1 Arch package
  • Solution: install ffmpeg-git from AUR via yay -S ffmpeg-git
  • Verify support with: ffmpeg -formats | grep -i hx — look for hxvs

3. Installing ffmpeg-git on Arch

yay -S ffmpeg-git
# If conflict with existing ffmpeg:
sudo pacman -Rdd ffmpeg
sudo pacman -U /home/user/.cache/yay/ffmpeg-git/ffmpeg-git-*.pkg.tar.zst

4. Converting a Single HXVS File

# To MKV (lossless, no transcoding, preserves audio)
ffmpeg -f hxvs -i input.h265 -c copy output.mkv

# To MP4 — requires audio transcode since pcm_alaw isn't supported in MP4
ffmpeg -f hxvs -i input.h265 -c:v copy -c:a aac output.mp4

5. Audio Format Inside HXVS Files

  • Audio codec: PCM A-law (pcm_alaw), 8000 Hz, mono
  • MP4 does not support pcm_alaw — use MKV or transcode audio to AAC for MP4
  • MKV supports pcm_alaw natively with -c copy

6. Concatenating Multiple HXVS Files

# Step 1: Convert each file to MKV
for f in *.h265; do ffmpeg -f hxvs -i "$f" -c:v copy -c:a copy "${f%.h265}.mkv"; done

# Step 2: Create file list
ls -1 *.mkv | sort | sed "s/^/file '/" | sed "s/$/'/" > mkvlist.txt

# Step 3: Concat
ffmpeg -f concat -safe 0 -i mkvlist.txt -c copy output_all.mkv

7. Extracting Audio from MKV

# As raw PCM
ffmpeg -i output_all.mkv -vn -c:a copy audio.pcm

# As WAV
ffmpeg -i output_all.mkv -vn -c:a pcm_alaw audio.wav

8. Adding a Second Audio Track to MKV

ffmpeg -i output_all.mkv -i "hq3_1_audio_(Vocals).wav" -c copy -map 0 -map 1:a output_with_2tracks.mkv
  • -map 0 keeps all original streams
  • -map 1:a adds the new audio track alongside the existing one

9. Useful Diagnostic Commands

# Identify file type / magic bytes
file somefile.h265
xxd somefile.h265 | head -20

# Check streams
ffprobe -show_streams somefile.h265
mediainfo somefile.h265

# Check ffmpeg supported formats
ffmpeg -formats | grep -i hx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment