jooola / earhorn

Listen, monitor and archive your Icecast streams!
GNU General Public License v3.0
10 stars 4 forks source link

Fix different silence duration between ffmpeg and earhorn #109

Closed jooola closed 2 years ago

jooola commented 2 years ago

We compute the silence duration in both ffmpeg and earhorn and log when we see a too big difference between the 2.

The computation on the python side could probably be improved with the decimal module. We migth also have some rounding issues.

Some logs:

2022-08-16 08:35:46.212 | ERROR    | earhorn.stream_silence:validate_silence_duration:48 - computed duration '3.0' differs from ffmpeg duration '2.94234'
2022-08-16 08:35:46.212 | INFO     | earhorn.stream_silence:parse_process_output:90 - silence end: 2022-08-16 08:35:46.212178
2022-08-16 08:35:46.212 | DEBUG    | earhorn.event:run:90 - silence: {"when": "2022-08-16T08:35:46.212178", "kind": "end", "seconds": 32756.4, "duration": 2.94234, "name": "silence"}

2022-08-16 08:50:56.694 | INFO     | earhorn.stream_silence:parse_process_output:90 - silence start: 2022-08-16 08:50:56.694790
2022-08-16 08:50:56.696 | DEBUG    | earhorn.event:run:90 - silence: {"when": "2022-08-16T08:50:56.694790", "kind": "start", "seconds": 33664.4, "duration": null, "name": "silence"}

2022-08-16 08:50:56.811 | ERROR    | earhorn.stream_silence:validate_silence_duration:48 - computed duration '2.1999999999970896' differs from ffmpeg duration '2.21741'
2022-08-16 08:50:56.812 | INFO     | earhorn.stream_silence:parse_process_output:90 - silence end: 2022-08-16 08:50:56.811735
2022-08-16 08:50:56.812 | DEBUG    | earhorn.event:run:90 - silence: {"when": "2022-08-16T08:50:56.811735", "kind": "end", "seconds": 33666.6, "duration": 2.21741, "name": "silence"}

2022-08-16 08:54:45.953 | INFO     | earhorn.stream_silence:parse_process_output:90 - silence start: 2022-08-16 08:54:45.953585
2022-08-16 08:54:45.953 | DEBUG    | earhorn.event:run:90 - silence: {"when": "2022-08-16T08:54:45.953585", "kind": "start", "seconds": 33893.8, "duration": null, "name": "silence"}

2022-08-16 09:24:31.719 | ERROR    | earhorn.stream_silence:validate_silence_duration:48 - computed duration '5.400000000001455' differs from ffmpeg duration '5.42009'
2022-08-16 09:24:31.720 | INFO     | earhorn.stream_silence:parse_process_output:90 - silence end: 2022-08-16 09:24:31.719796
2022-08-16 09:24:31.720 | DEBUG    | earhorn.event:run:90 - silence: {"when": "2022-08-16T09:24:31.719796", "kind": "end", "seconds": 35681.4, "duration": 5.42009, "name": "silence"}