Commit Graph

344 Commits

Author SHA1 Message Date
Isaac Connor
a17aea1261 refactor: use CxxUrl for URL auth injection in FFmpegCamera
Replace fragile string manipulation (hardcoded substr offsets) with
CxxUrl's Url parser for injecting mUser/mPass into mPath and
mSecondPath. Only applies credentials when the URL has no existing
auth info, preserving inline credentials on the secondary path.
Non-URL paths (e.g. v4l2 devices) are handled gracefully via
try/catch.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 18:16:55 -05:00
Isaac Connor
b62285b90b fix: null-check mAudioStream before dereferencing in FfmpegCamera::Capture
When mSecondFormatContext is set but no audio stream was found during
PrimeCapture, mAudioStream is null. Dereferencing mAudioStream->time_base
causes a segfault (SIGSEGV at fault address 0x20). Add mAudioStream to
the condition check, consistent with the existing null guard on line 172.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-09 15:57:22 -05:00
Isaac Connor
94f3a5771b fix: release GPU surfaces immediately after hw transfer
The nvidia-vaapi-driver would fail with "list argument exceeds maximum
number" when decoding HEVC because GPU surfaces were being held in the
packet queue after transfer, exhausting the VAAPI surface pool.

Changes:
- Transfer hw frames to software immediately in receive_frame() while
  the VA context is still valid, then release the GPU surface
- Check hw_frames_ctx in needs_hw_transfer() to detect already-transferred
  frames
- Remove extra_hw_frames and thread_count settings (not needed with
  immediate surface release)
- Fix EAGAIN handling in send_packet to wait instead of busy-loop

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 22:51:21 -05:00
Isaac Connor
c012f55962 Set reference frames and turn off multi-threading when doing hwaccel 2026-02-04 21:35:06 -05:00
Isaac Connor
a96b776949 fix: apply credentials to secondary URL and fix buffer overflow in DumpSettings
- Apply credentials to secondary stream URL in FFmpegCamera (was causing 401 Unauthorized)
- Add empty check for rtsp_second_path in RTSP2WebManager before applying credentials
- Replace unsafe sprintf pattern in Monitor::DumpSettings with std::string + stringtf
- Refactor Zone::DumpSettings to return std::string instead of writing to char buffer
- Add decimal precision to event duration debug output

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-04 17:40:26 -05:00
Isaac Connor
65bbaa4ab8 fix: add null check and fix incomplete error message in FFmpegCamera
- Add null check after avformat_alloc_context() to prevent null pointer
  dereference if allocation fails
- Fix incomplete error message that was missing the path parameter

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 11:00:38 -05:00
Isaac Connor
2eebda8c64 Cleanup hw_pix_fmt and get_hw_format 2026-01-26 14:40:10 -05:00
Isaac Connor
12ffa835c7 Merge in code to iterate through available codecs and try each one. 2026-01-26 13:17:25 -05:00
Isaac Connor
5c5cce12fa Fix spacing 2025-07-26 11:52:21 -04:00
Isaac Connor
fbd2dd6c58 Allow setting of decoder threads using opts 2025-06-21 21:37:10 -04:00
Isaac Connor
66adcab8ea Merge pull request #4131 from SteveGilvarry/ffmpeg7-avcodec_close
Removing avcodec_close, avcodec_free_context is replacement and been …
2025-02-12 15:07:56 -05:00
Isaac Connor
f2e8741984 Choose altnernate video stream if it matches the specified resolution. Don't return packets that don't match our stream. discard unmatched streams. 2025-01-24 12:37:36 -05:00
Isaac Connor
10b3619a66 clear probesize so ffmpeg doesn't complain abou it 2024-10-28 13:59:21 -04:00
Isaac Connor
e600472625 If using WallClockTimestamps, don't sweat a big jump in time. 2024-10-22 18:22:50 -04:00
Isaac Connor
e7d4fa334d Initialize lastPTS and only set lastAudioPTS if the stream is audio. 2024-09-25 10:53:47 -04:00
Isaac Connor
07d221569d Let higher ups deal with non-video non-audio packets. Might fix a memleak 2024-09-24 19:30:30 -04:00
Steve Gilvarry
88227105b8 Removing avcodec_close, avcodec_free_context is replacement and been around since 2014, so should be no reason to version test. 2024-09-14 11:06:55 +10:00
Isaac Connor
ae34457031 Take importance into count when logging failure to read packet.
Clear reorder_queue_size from opts as it only applies to avformat
2024-07-24 12:07:56 -04:00
Isaac Connor
63a2ed4b06 Take Importance into accoutn when logging Unable to read from stream 2024-07-08 08:39:41 -04:00
Isaac Connor
aa1aee230f If camera time jumps back more than 10 seconds, fail the capture. 2024-07-03 08:54:46 -04:00
Isaac Connor
90b5b1f154 Reduce time jump amount to 20seconds. We have many cameras that jump more than 20, but less than 40 and so the dts are accepted by reordering. Better to restart capture I think. 2024-04-07 11:30:22 -04:00
Aaron Kling
c4683d90a9 Format code using astyle google format
Commands used:
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.cpp
astyle --style=google --indent=spaces=2 --keep-one-line-blocks src/*.h
2024-03-26 13:43:58 -05:00
Isaac Connor
26231c4579 Return 0 if packet is not for video or audio stream 2024-03-02 11:19:27 -05:00
Isaac Connor
e4a2f9879e Don't assume video if not audio, could be data 2024-03-02 11:00:03 -05:00
Isaac Connor
bb4858103d Increase time jump to 40 seconds because Avigilon cameras seem to do this a lot 2024-03-02 09:58:22 -05:00
Isaac Connor
3eede7228c Use Importance when logging about time jumping back too far 2024-02-27 17:39:52 -05:00
Isaac Connor
ff41c1612f Use time instead of pts for legibility in warning about jumping back in time. Don't break capture until we have at least 5 of these errors. 2024-02-19 09:52:10 -05:00
Isaac Connor
de7b915291 Increase the time jump to 20 seconds. 2024-02-06 15:59:08 -05:00
Isaac Connor
b869a6e5a9 Must always CLose in PrimeCapture because each OpenFfmpeg allocates structures. 2024-01-29 10:10:56 -05:00
Isaac Connor
21743f71a1 Reset lastPTS on Close 2024-01-27 10:27:39 -05:00
Isaac Connor
543d3bdd98 Fix lastPTS assignment when not using a second input. Use a 10 sec max pts gap before fail to capture 2024-01-26 19:47:39 -05:00
Isaac Connor
4888019f1b Add detection for significant jump back in time in incoming packets 2024-01-26 18:16:24 -05:00
Isaac Connor
db135cba46 Add isPrimed to camera class instead of it just being in ffmpeg_camera. Rename mCanCapture to isPrimed in ffmpeg_camera. 2023-12-06 09:38:38 -05:00
Isaac Connor
558aed0561 Fix memleak due to not freeing the opts dict except on error. 2023-10-26 13:44:02 -04:00
Isaac Connor
3f7e9d57ae Put back code to free audio context and codec. If we aren't useing second input, we still need to free them. 2023-10-20 10:51:44 -04:00
Isaac Connor
7eb601ef4d Restore audio recording 2023-09-13 10:47:45 -04:00
David Schmidt
5bfa28d172 Use unique_ptr instread of local scope object pointer for second input 2023-09-09 18:51:54 +02:00
Isaac Connor
9295c390ca re-parse Options into opts so that they are available to open_codec 2023-07-28 17:39:08 -04:00
Isaac Connor
ef29805a4d Test for word auto in decodername and don't do lookup for it 2023-07-17 17:01:39 -04:00
Isaac Connor
0a0293f34a Turn warning about mismatched dimensions into a debug 2023-06-12 10:17:11 -04:00
Isaac Connor
f8ca7cee94 Cleanup constructor a bit 2023-06-08 10:58:08 -04:00
Isaac Connor
ab9298cbf0 Add DecoderName to Monitors, and use it in ffmpeg_camera instead of just trying all options 2023-02-26 16:30:56 -05:00
Isaac Connor
c1c25aeb76 Add sqv hwaccel types 2023-02-25 18:07:54 -05:00
Isaac Connor
7a1066c534 Disable multi-threaded decoding as a test 2023-01-26 18:46:38 -05:00
Isaac Connor
32add0952c Differentiate between negative pts and AV_NOPTS_VALUE when looking for wrap around. 2023-01-10 14:19:40 -05:00
Isaac Connor
0d569c26d7 fix formatting string 2023-01-07 12:35:24 -05:00
Isaac Connor
090b90565f Add uriencoding of the password 2023-01-06 12:22:04 -05:00
Isaac Connor
48c18ca4ed Attempt to better handle 32bit wrap around in the pts in the input stream. 2022-12-23 09:02:41 -05:00
AngeloGioacchino Del Regno
7f8badc334 zm_ffmpeg_camera: Add support for Jetson Nano/Xavier NVMPI
Add support for the NVMPI hardware decoders (not CUDA decoders!)
of the Tegra SoCs found in the Jetson Nano/TX/TX2 and Xavier NX/AGX.

This platform supports hardware decoding of H264, HEVC, MPEG2,
MPEG4, VP8 and VP9.
2022-11-24 00:09:02 +01:00
Isaac Connor
dd82a01291 Don't encode the user/pass. If they were properly entered in the web ui then we will double encode them. 2022-09-18 12:35:04 -04:00