Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate and fix frames dropping issues in videocapture found in ses-20240830 #111

Merged
merged 15 commits into from
Oct 23, 2024

Conversation

vmdocua
Copy link
Collaborator

@vmdocua vmdocua commented Sep 17, 2024

This PR is brother of issue #68 we have with frames dropping. Got this issue in ReproNim ses-20240830 time calibration session. Closes #112. Closes #113. Closes #114.

Proposal is listed below:

Re-configure reprostim-videocapture/ffmpeg with options:

  • v_enc:

    • -preset ultrafast - fastest encoding, lowest compression efficiency.
    • -crf 18 - consider CRF value 17 or 18 to be visually lossless or nearly.
    • -tune zerolatency - reduce latency during encoding, to improove timing in recorded videos.
    • -b:v 2M - cut video bitrate to 2 Mbps (this rate can be changed later).
    • -maxrate 2M - set the same as plain bitrate, and don't allow encoder to exceed it even temporarily.
    • -bufsize 4M - hardcode video buffer size to 4 Mbps.
    • -vf setpts=PTS-STARTPTS - apply filter to reset the timestamps of the video frames, starting from 0. ?? Consider in future explict frame rate specification via -r *** option like 60 FPS.
  • n_threads:

    • -threads 4 - force ffmpeg to use only 4 CPU/threads explicitly. Consider in furture 2 or 3 values according to reproiner box hardware (it's 4 core box by now).
  • a_enc:

    • -af asetpts=PTS-STARTPTS - apply filter to reset the timestamps of the audio frames, starting from 0. ?? Consider in future explicit -ar *** sample rate values extracted from ALSA/Magewell (44.1K, 48K etc) to improove timing and synchronization with video stream.

Current results of applied options on dev PC:

  1. Linux OOM doesn't kill ffmpeg anymore after 1-2 minutes of video capture.
  2. Video and audio streams are almost in sync in recorded video file, but it's possible some small deviations still exists.
  3. CPU usage should be reduced in 2+ times.
  4. Visually don't see video quality lost, but it's possible on real system we will need still to increase it.
  5. Increased *.mkv file size. For test was used video from calibration session we have, resolution 1920x1080, 60 FPS. Video length 10 minutes, video file size is 100MB, so this corresponds to 10MB/minute, 0.6GB /hour, 14.4GB /day or 430GB /month.

Current results of applied options @reproiner:

  1. Bad picture quality for dynamic videos, sports etc. It's possible that we need to increase bitrate from 2M close to standard quality for 1080p 60fps H.264 like 8-12Mbps. e.g -b:v 8M -maxrate 8M -bufsize 16M and monitor CPU, *.mkv size and quality.

@vmdocua vmdocua self-assigned this Sep 18, 2024
@vmdocua vmdocua marked this pull request as ready for review October 23, 2024 20:09
@vmdocua vmdocua merged commit 7b7190b into master Oct 23, 2024
1 check 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
1 participant