Commit d817799
refactor(mp4ctl): rewrite recording loop for robust serial processing
The previous loop_worker implementation attempted to maintain several
mathematically incompatible invariants simultaneously:
1. Exact video duration (e.g., 60s).
2. Filenames with "round" timestamps (e.g., :00 seconds).
3. Zero processing time between files.
4. Keyframes arriving exactly at minute boundaries.
5. System clock is monotonic and never jumps (e.g. via NTP).
In practice, this caused issues because:
- Processing overhead (open/close) takes time, causing natural drift.
- Wall clock adjustments (NTP) can shift time unexpectedly.
- Keyframes/metadata arrive at unpredictable intervals, often requiring 1-2s delays.
- The "catch-up" logic intended to align timestamps caused drift, dropped segments,
and errors.
This rewrite abandons the attempt to "beautify" timestamps in favor of
reliability:
- Independent Iterations: Each recording loop iteration is now independent.
- Natural Drift: We accept that filenames will reflect the actual start time
(e.g., 12-34-56.mp4) rather than a forced round number.
- Current Time: Timestamps are derived from now() immediately before
file creation, ensuring accuracy over cosmetic alignment.
- Simplified Logic: Removed round_up_to_minute and sleep_until_time helpers.1 parent aa0c794 commit d817799
1 file changed
Lines changed: 9 additions & 68 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
99 | 99 | | |
100 | 100 | | |
101 | 101 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | 102 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | 103 | | |
129 | 104 | | |
130 | 105 | | |
| |||
860 | 835 | | |
861 | 836 | | |
862 | 837 | | |
863 | | - | |
864 | | - | |
865 | | - | |
866 | | - | |
867 | | - | |
| 838 | + | |
868 | 839 | | |
869 | 840 | | |
870 | | - | |
871 | | - | |
872 | | - | |
873 | | - | |
874 | | - | |
875 | | - | |
876 | | - | |
877 | | - | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
900 | | - | |
901 | 841 | | |
902 | 842 | | |
903 | 843 | | |
904 | 844 | | |
905 | | - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
906 | 852 | | |
907 | 853 | | |
908 | 854 | | |
909 | 855 | | |
| 856 | + | |
910 | 857 | | |
911 | 858 | | |
912 | 859 | | |
913 | 860 | | |
914 | | - | |
915 | | - | |
916 | | - | |
917 | | - | |
918 | | - | |
919 | | - | |
920 | 861 | | |
921 | 862 | | |
922 | 863 | | |
| |||
0 commit comments