lagmoellertim / unsilence

Console Interface and Library to remove silent parts of a media file 🔈
https://unsilence.readthedocs.io/
MIT License
556 stars 45 forks source link

Suggestion for improving the speed of the silencedetect filter #128

Closed l0ophole closed 2 years ago

l0ophole commented 2 years ago

I have edited DetectSilence.py to test this and it seems to increase the silencedetect filter's performance by 2X and cut it's processing time in half. The command line I recommend using is:

    command = [
        "ffmpeg",
        "-i", str(input_file),
        "-af",
        f"silencedetect=noise={kwargs.get('silence_level', -35)}dB:d={kwargs.get('silence_time_threshold', 0.5)}",
        "-vn", "-c:a", "pcm_s32le",
        "-f", "null",
        "-"
    ]

I have checked ffmpeg's output and it prints out identical timestamps to when running it without the added options I suggested. I use your project all the time and it's great. I hope you find this useful. I also added -c:v h264_nvenc to the RenderIntervalThread.py to improve the rendering speed using my GPU, and I haven't noticed any problems with it yet. Maybe you could add that as a command line argument to run with software or hardware rendering.

            if not self.__render_options.audio_only:
                command.extend(["-map", "[v]", "-c:v", "h264_nvenc"])

            command.extend(["-map", "[a]"])
        else:
            if self.__render_options.audio_only:

Thanks for creating this project! Have a great day!