Giter VIP home page Giter VIP logo

unsilence's Introduction

Hey ๐Ÿ‘‹

That's what I'm doing currently:

  • ๐Ÿฆ€ Learning Rust

Feel free to look around my profile and contribute to my projects!

Have fun ๐ŸŽ‰

If you really like my work ๐Ÿ˜ƒ

I'm part of the official GitHub Sponsors program where you can support me on a monthly basis.

GitHub Sponsors

You can also contribute by buying me a coffee (this is a one-time donation).

Ko-Fi Sponsors

Thank you for your support! ๐Ÿ‘

unsilence's People

Contributors

atilioa avatar dependabot[bot] avatar garbaz avatar ilyakharlamov avatar lagmoellertim avatar lukasherz avatar nylontowel avatar orestisfl avatar qhyun2 avatar romankornev avatar simon-wessel avatar vijayabhaskar96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

unsilence's Issues

Add location for TMP files

Hi,

I use my RAM as /tmp, which i would like to use for the temporary storage.

I fixed this by adding

parser.add_argument("--tmp", type=convert_to_path(should_exist=False, should_parents_exist=True), default=".tmp",
                        help="Path to where the tmp files should be")

to ParseArguments.py, and this

+  tmpdir=args.tmp
-  continual = Unsilence(args.input_file)
+  continual = Unsilence(args.input_file,temp_dir=tmpdir)

to EntryPoint.py.

Sorry I am not used to editing others people's git's

Hardware Acceleration

Describe the solution you'd like
It would be great if hardware acceleration could be added to the ffmpeg usage. I assume it would really speed up the video manipulation aspect.

Additional context
This seems to be a good starting point: https://trac.ffmpeg.org/wiki/HWAccelIntro

If you point me in the right direction as to how you would like this done I can get working on a PR.

Love this project BTW. Been using it for school all year and it really is a time saver!

Performance Improvements

Describe the solution you'd like
I've been tinkering with the MediaRenderer code and noticed some room for performance improvements.

First off, I combined the rendering of multiple intervals in a single ffmpeg call, reducing process creation overhead.
The larger the filtergraph gets, though, the slower ffmpeg becomes. The sweet spot seems to be around 32 intervals per ffmpeg process. With this, ffmpeg itself already does a bit of multithreading, but not enough to fuly utilize my CPU.

The Popen interface already runs the subprocess in a non-blocking fashion. To run multiple ffmpeg instances simultaneously, we thus don't need multiple threads in the Python script.

On my (8 core, 16 threads) machine, the optimal setting seems to run 4 ffmpeg processes with access to 4 cores each. We should probably make this configurable.

Finally, we can speed up encoding quite a bit by passing -c:v libx264 -preset fast -profile:v baseline to ffmpeg.

Tests
Implementing all these things made unsilencing a 1.5 hour 300MB take about 220 seconds rather than 400. Almost a ~2x speedup. Unsilencing a smaller. 5 minute, video sped up ~1.5 times.

The resulting video, however, is smaller and shorter than when using the original unsilence tool. Smaller can be explained by better compression when processing larger segments, but shorter seems bad. Taking the same 1:32:52 file as before, the CLI tells me the result should be 1:18:01 (both in the original and after modifications), the original gives a 1:20:25 file and the modified gives a 1:18:12 video. There are no obvious faults in either file (they start and end the same), but I haven't been able to do a full side-by-side comparison yet.

TL;DR: I made some performance enhancements. The results seem promising, but I'm not sure if the modified version is still correct. I plan to make a PR once I've cleaned it up, so any comments are welcome.

AttributeError: 'NoneType' object has no attribute 'groups'

unsilence 1.mp4 2.mp4

After trying to use it in cmd it returns:
AttributeError: 'NoneType' object has no attribute 'groups'

FFmpeg in %PATH% and I'm using Windows 10 64 bit. I also tried using it with other videos but it returns the same error.

List object as no attribute 'join'

captura
I installed with pip3 install unsilence, and tried with pip install unsilence after pip3 uninstall unsilence.

Maybe a [0,1].join("") instead of "".join([0,1])?

No directory found [.tmp]

I installed the unsilence on both my windows and my Linux machine and in both cases, I am getting the error that a file is not found.

Complete error:

โ”Œโ”€โ”€(kaliใ‰ฟkali)-[~/Desktop]
โ””โ”€$ unsilence sample1.wav sampout.wav
Calculating Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type     โ”ƒ Before          โ”ƒ After           โ”ƒ Difference        โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Combined โ”‚ 0:00:32 (100%)  โ”‚ 0:00:22 (68.4%) โ”‚ -0:00:10 (-31.6%) โ”‚
โ”‚ Audible  โ”‚ 0:00:20 (62.0%) โ”‚ 0:00:20 (62.0%) โ”‚ 0:00:00 (0.0%)    โ”‚
โ”‚ Silent   โ”‚ 0:00:12 (38.0%) โ”‚ 0:00:02 (6.3%)  โ”‚ -0:00:10 (-31.6%) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

[?] Continue with these options? (Y/n) Y
Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00  
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   0% -:--:--  
FileNotFoundError: [Errno 2] No such file or directory: '/home/kali/Desktop/.tmp/9381a093-1ede-4d5f-babc-6d97cafdd5dc/out_final.wav' -> '/home/kali/Desktop/sampout.wav'

During handling of the above exception, another exception occurred:

FileNotFoundError: [Errno 2] No such file or directory: '/home/kali/Desktop/.tmp/9381a093-1ede-4d5f-babc-6d97cafdd5dc/out_final.wav'

The command executed on windows and linux are:

unsilence sample.wav sampleout.wav

For installation, I tried with the pip installation and as well as installation from the source.

OS: Windows 10 and Kali Linux

Unsilencing some .mp4's result in a bad conversion

Description
When I pulled some lectures from a zoom recording, I am unable to unsilence them.
Upon opening the converted file, the file would play for a few frames and then freeze.

Example:
I download a 3 hr lecture, the calculated interval returns a reduction of 25% (making is a 2hr and someting lecture), upon continueing with those options, the file starts to get unsilenced.
2020-09-28_14-12

Upon completion, mediainfo shows me that the file is 400 hours long. When I open the file, the recording is stuck on the first frame.
filesize

A possible reason
I downloaded the lecture .mp4 with the following trick: https://www.youtube.com/watch?v=2ANwf9FJO3I&ab_channel=EatYourVegs

  • OS + version:
    NAME="KDE neon"
    VERSION="5.19"
    ID=neon
    ID_LIKE="ubuntu debian"
    PRETTY_NAME="KDE neon User Edition 5.19"
    VARIANT="User Edition"
    VERSION_ID="20.04"

  • Python version: 3.8

  • FFMPEG version: ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers

Better way to access intervals than string parsing?

After the file has been analyzed (e.g., u.detect_silence()) the string representation of the output appears to be a list:

print(intervals)
> 
[<Interval start=0 end=6.48452 duration=6.48452 is_silent=True>, <Interval start=6.48452 end=30.5007 duration=24.01618 is_silent=False>, <Interval start=30.5007 end=30.7924 duration=0.2917000000000023 is_silent=True>, <Interval start=30.7924 end=34.5449 duration=3.7524999999999977 is_silent=False>, <Interval start=34.5449 end=35.1873 duration=0.6424000000000021 is_silent=True>, <Interval start=35.1873 end=36.6571 duration=1.4697999999999993 is_silent=False>, <Interval start=36.6571 end=37.0472 duration=0.3900999999999968 is_silent=True>, <Interval start=37.0472 end=39.1134 duration=2.066200000000002 is_silent=False>, <Interval start=39.1134 end=41.2278 duration=2.1144000000000034 is_silent=True>, <Interval start=41.2278 end=42.6118 duration=1.3840000000000003 is_silent=False>, <Interval start=42.6118 end=43.4757 duration=0.863900000000001 is_silent=True>, <Interval start=43.4757 end=45.4288 duration=1.9530999999999992 is_silent=False>, <Interval start=45.4288 end=45.779 duration=0.35020000000000095 is_silent=True>, <Interval start=45.779 end=50.3659 duration=4.5869 is_silent=False>, <Interval start=50.3659 end=50.6756 duration=0.3096999999999994 is_silent=True>, <Interval start=50.6756 end=52.5234 duration=1.8477999999999994 is_silent=False>, <Interval start=52.5234 end=53.0856 duration=0.5621999999999971 is_silent=True>, <Interval start=53.0856 end=54.4425 duration=1.356900000000003 is_silent=False>, <Interval start=54.4425 end=55.1487 duration=0.7061999999999955 is_silent=True>, <Interval start=55.1487 end=55.7332 duration=0.5844999999999985 is_silent=False>, <Interval start=55.7332 end=56.7 duration=0.9668000000000063 is_silent=True>, <Interval start=56.7 end=57.6843 duration=0.9842999999999975 is_silent=False>, <Interval start=57.6843 end=58.0523 duration=0.3680000000000021 is_silent=True>, <Interval start=58.0523 end=63.55 duration=5.497699999999995 is_silent=False>]

It would be extremely useful to work with those intervals. The object does not appear to be an iterable, however, and indexing fails.

Is there a better way of working with it than casting it to a string and then parsing out its elements to get the list of intervals I require?

Request: Add arguments to affect the "strictness" in determining the DB difference between "silent" / audible content

Is your feature request related to a problem? Please describe.
The videos I am attempting to edit do have some low-volume background music and sound effects that are significantly quieter than my voice/commentary. This tool generally does a good job of distinguishing them but if the background music spikes slightly in volume (louder, but still nowhere near as loud as my voice) the fast forward will briefly stop during the mini-spike.

Describe the solution you'd like
I'd like to be able to specify an argument that affects the "silence" determination, where not specifying an argument uses the current default behavior and specifying a value makes the silence determination more or less strict based on the average volume of the entire file.

Other solutions
I could specify the exact dB threshold I'd like to use for "silent" vs. "audible" content, but I could see that ending up buggier than specifying a "strictness" variable, where a strictness of 5 = the default behavior (no arguments).

Additional context
I could share sample pre- & post-processed files showing points where small spikes in the background music that are much quieter than my commentary are treated as "audible" when I'd prefer them to be treated as "silent"; let me know the best way to share these!

AttributeError: 'NoneType' object has no attribute 'groups'

Hi,
I'm having this problem while trying to use your code from the powershell in windows 10. I use python and I have installed unsilence for the CLI and as library.
I don't get the traceback as when error with other python programs occur. So, I used "-d" and I got:

File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1264.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 87, in run_code
exec(code, run_globals)
File "C:\Users\usuario2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\Scripts\unsilence.exe_main
.py", line 7, in
File "C:\Users\usuario2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\unsilence\command_line\EntryPoint.py", line 20, in main
run()
File "C:\Users\usuario2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\unsilence\command_line\EntryPoint.py", line 66, in run
continual = Unsilence(args.input_file)
File "C:\Users\usuario2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\unsilence\Unsilence.py", line 27, in init
ffmpeg_version = get_ffmpeg_version()
File "C:\Users\usuario2\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\unsilence\lib\tools\ffmpeg_version.py", line 16, in get_ffmpeg_version
groups = match.groups()
AttributeError: 'NoneType' object has no attribute 'groups'

Thanks for your contribution. I'm currently using jumcutterv2 and auto-editor and it would be awesome to test your code against my set of teaching videos.

Best,

Error reading metadata with Polish characters

Description
An mp4 file with some Polish characters in metadata breaks unsilence.

Characters which I've found cause the error: ฤ˜, ล, ลƒ. Ohters such as ฤ„, ฤ†, ร“, ลš, ลป, ลน are working fine. All of these characters in lowercase are working fine (including ฤ™, ล‚, ล„).

To Reproduce

  1. Grab/create an mp4 file, let's call it in.mp4.
  2. Right click on it -> Properties -> Details
  3. Edit field Title or Comments and paste there at least one of: ฤ˜, ล, ลƒ.
  4. Use command unsilence in.mp4 out.mp4
  5. See error

Expected behavior
unsilence should proceed to analyzing video file.

Error
Error for title field containing ฤ˜:

> unsilence in.mp4 out.mp4
Calculating Intervals... โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 0% -:--:--
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 257: character maps to

Error for title field containing ล:

> unsilence in.mp4 out.mp4
Calculating Intervals... โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 0% -:--:--
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 257: character maps to

Full error (title metadata fields contains ล):

> unsilence in.mp4 out.mp4 -d
Calculating Intervals... โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ 0% -:--:--
Traceback (most recent call last):
File "c:\users\matem\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\users\matem\anaconda3\lib\runpy.py", line 85, in run_code
exec(code, run_globals)
File "C:\Users\matem.local\bin\unsilence.exe_main
.py", line 7, in
File "c:\users\matem.local\pipx\venvs\unsilence\lib\site-packages\unsilence\command_line\EntryPoint.py", line 20, in main
run()
File "c:\users\matem.local\pipx\venvs\unsilence\lib\site-packages\unsilence\command_line\EntryPoint.py", line 79, in run
**argument_dict_for_silence_detect
File "c:\users\matem.local\pipx\venvs\unsilence\lib\site-packages\unsilence\Unsilence.py", line 53, in detect_silence
self.__intervals = detect_silence(self.__input_file, **kwargs)
File "c:\users\matem.local\pipx\venvs\unsilence\lib\site-packages\unsilence\lib\detect_silence\DetectSilence.py", line 50, in detect_silence
for line in console_output:
File "c:\users\matem\anaconda3\lib\encodings\cp1250.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x81 in position 257: character maps to

Desktop (please complete the following information):

  • OS + version: Windows 10
  • Python version: 3.7.4
  • FFMPEG version: 4.3.2
  • unsilence: 1.0.7

Additional context
My guess is that unsilence is not using right encoding when reading file metadata.

unsilence fails if output path is in a new directory

Describe the bug
unsilence folder1/input.mp4 folder2/output.mp4 fails if folder2 does not exist.

To Reproduce
Steps to reproduce the behavior:

  1. create folder1/input.mp4
  2. run unsilence folder1/input.mp4 folder2/output.mp4
  3. OSError: Parent directory not found

Expected behavior
It should create folder2.

Desktop (please complete the following information):

  • macOS 11.0.1
  • Python 3.9.0
  • FFMPEG version 4.3.1

out_final does not seem to being created

Might be identical to #4 or #13.
All of my attempts to run unsilence are getting the same error:

unsilence "example.mp4" "example_faster.mp4"ยด
Calculating Intervals... โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“ 100% 0:00:00

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Type     โ”‚ Before          โ”‚ After           โ”‚ Difference        โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ Combined โ”‚ 0:00:42 (100%)  โ”‚ 0:00:21 (50.2%) โ”‚ -0:00:21 (-49.8%) โ”‚
โ”‚ Audible  โ”‚ 0:00:17 (40.2%) โ”‚ 0:00:17 (40.2%) โ”‚ 0:00:00 (0.0%)    โ”‚
โ”‚ Silent   โ”‚ 0:00:25 (59.8%) โ”‚ 0:00:04 (10.0%) โ”‚ -0:00:21 (-49.8%) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

[?] Continue with these options? (Y/n) y
Rendering Intervals... โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“ 100% 0:00:00
Combining Intervals... โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“   0% -:--:--
FileNotFoundError: [WinError 2] Le fichier spรฉcifiรฉ est introuvable (File can not be found): '[...]\\.tmp\\8ce6f9a5-841d-4107-a2d9-2c936285392a\\out_final.mp4' -> '[...]\\example_faster.mp4'

During handling of the above exception, another exception occurred:

FileNotFoundError: [Errno 2] No such file or directory: '[...]\\.tmp\\8ce6f9a5-841d-4107-a2d9-2c936285392a\\out_final.mp4'

The program creates all temp out_{i} files but it looks like it does not create out_final, so it ultimately fails.
I'm using FFmpeg 4.3.0 on Windows 10. Will test on Linux Mint 20 soon.

FileNotFoundError

Hi! I get the following error when trying to use unsilence. Thank you!

Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00  
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   0% -:--:--  
Traceback (most recent call last):
  File "/usr/lib/python3.9/shutil.py", line 803, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/home/dilson/Documentos/.tmp/6af8866c-3d1f-4139-abbc-839bba6da3a7/out_final.mp4' -> '/home/dilson/Documentos/teste.mp4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dilson/.local/bin/unsilence", line 11, in <module>
    sys.exit(main())
  File "/home/dilson/.local/lib/python3.9/site-packages/unsilence/command_line/EntryPoint.py", line 19, in main
    run()
  File "/home/dilson/.local/lib/python3.9/site-packages/unsilence/command_line/EntryPoint.py", line 101, in run
    continual.render_media(
  File "/home/dilson/.local/lib/python3.9/site-packages/unsilence/Unsilence.py", line 96, in render_media
    renderer.render(self.__input_file, output_file, self.__intervals, **kwargs)
  File "/home/dilson/.local/lib/python3.9/site-packages/unsilence/lib/render_media/MediaRenderer.py", line 125, in render
    shutil.move(final_output, output_file)
  File "/usr/lib/python3.9/shutil.py", line 817, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.9/shutil.py", line 432, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.9/shutil.py", line 261, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/home/dilson/Documentos/.tmp/6af8866c-3d1f-4139-abbc-839bba6da3a7/out_final.mp4'

Change or keep the name unsilence?

Hey,
it seems like some people find the name unsilence somewhat misleading, since the function of this piece of software is not that well explained by its name. So if you think the name should be changed, feel free to write your favorite name for it in the comments (it would be great if you could also click on the poll before so that I can get an overview).

Cheers ๐ŸŽ‰

P.S.: If you have any ideas, please comment or add a +1 to existing comments so that I now which one you favour.


Exception in thread (Thread-4 and Thread-3)

I tested with different parameters and video files from different sources, but I always get "Exception in thread":
PS E:\Vรญdeos\A procesar automaticamente\ListaAlfredoFL> unsilence '..\Lista Emu8086\08.mp4' .\acortados\01.mp4 -as 1.25 -ss 100000 -st 0.1 -ao

Calculating Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type โ”ƒ Before โ”ƒ After โ”ƒ Difference โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Combined โ”‚ 0:03:59 (100%) โ”‚ 0:02:39 (66.5%) โ”‚ -0:01:20 (-33.5%) โ”‚
โ”‚ Audible โ”‚ 0:03:18 (83.1%) โ”‚ 0:02:39 (66.5%) โ”‚ -0:00:40 (-16.6%) โ”‚
โ”‚ Silent โ”‚ 0:00:40 (16.9%) โ”‚ 0:00:00 (0.0%) โ”‚ -0:00:40 (-16.9%) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

[?] Continue with these options? (Y/n)
Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 0% -:--:--
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 0% -:--:-- Exception in thread Thread-4:
Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 0% -:--:--
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 0% -:--:-- Exception in thread Thread-3:
Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 1% -:--:--
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 0% -:--:--

By the way, ASCII Output is wonderful ;-)
Thanks!

Invalid render options

Getting this error, any help would be greatly appreciated.

Exception in thread Thread-3:
ValueError: Invalid render options
Exception in thread Thread-4:
ValueError: Invalid render options

image

Performance improvements

Considering that the performance in this tool are important and depends to ffmpeg there are some ways to improve it.

https://pypi.org/project/perflint/ reported those things

************* Module unsilence.lib.render_media.MediaRenderer
unsilence/lib/render_media/MediaRenderer.py:122:12: W8205: Importing the "sleep" name directly is more efficient in this loop. (dotted-import-in-loop)
unsilence/lib/render_media/MediaRenderer.py:80:26: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
unsilence/lib/render_media/MediaRenderer.py:81:30: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
unsilence/lib/render_media/MediaRenderer.py:177:19: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/render_media/MediaRenderer.py:177:19: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/render_media/MediaRenderer.py:156:18: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
************* Module unsilence.lib.intervals.Intervals
unsilence/lib/intervals/Intervals.py:15:28: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
unsilence/lib/intervals/Intervals.py:83:38: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
************* Module unsilence.lib.detect_silence.DetectSilence
unsilence/lib/detect_silence/DetectSilence.py:53:22: W8205: Importing the "search" name directly is more efficient in this loop. (dotted-import-in-loop)
unsilence/lib/detect_silence/DetectSilence.py:76:22: W8205: Importing the "search" name directly is more efficient in this loop. (dotted-import-in-loop)
unsilence/lib/detect_silence/DetectSilence.py:61:15: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:61:15: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:81:29: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/lib/detect_silence/DetectSilence.py:30:14: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
************* Module unsilence.command_line.EntryPoint
unsilence/command_line/EntryPoint.py:48:39: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
unsilence/command_line/EntryPoint.py:56:33: W8301: Use tuple instead of list for a non-mutated sequence (use-tuple-over-list)
************* Module unsilence.command_line.ChoiceDialog
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:23:15: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:17:31: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)
unsilence/command_line/ChoiceDialog.py:23:15: W8201: Consider moving this expression outside of the loop. (loop-invariant-statement)

-----------------------------------
Your code has been rated at 9.36/10

FileNotFoundError out_final.mp4

Describe the bug

Using a completely vanilla/default invocation (except --debug, issue also happens without --debug) of unsilence on Amazon Linux, it crashes it with FileNotFound:

[ec2-user@ip-172-31-42-91 ~]$ unsilence --debug input.mp4 output.mp4
Calculating Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00

โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“
โ”ƒ Type     โ”ƒ Before          โ”ƒ After           โ”ƒ Difference        โ”ƒ
โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ
โ”‚ Combined โ”‚ 0:03:00 (100%)  โ”‚ 0:01:57 (65.1%) โ”‚ -0:01:03 (-34.9%) โ”‚
โ”‚ Audible  โ”‚ 0:01:45 (58.1%) โ”‚ 0:01:45 (58.1%) โ”‚ 0:00:00 (0.0%)    โ”‚
โ”‚ Silent   โ”‚ 0:01:15 (41.9%) โ”‚ 0:00:13 (7.0%)  โ”‚ -0:01:03 (-34.9%) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

[?] Continue with these options? (Y/n) y
Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   0% -:--:--
Traceback (most recent call last):
  File "/usr/lib64/python3.7/shutil.py", line 566, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/.tmp/45c670ce-03e7-4d50-b540-e07c7a616810/out_final.mp4' -> '/home/ec2-user/output.mp4'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/unsilence", line 33, in <module>
    sys.exit(load_entry_point('unsilence==1.0.9', 'console_scripts', 'unsilence')())
  File "/usr/local/lib/python3.7/site-packages/unsilence-1.0.9-py3.7.egg/unsilence/command_line/EntryPoint.py", line 21, in main
  File "/usr/local/lib/python3.7/site-packages/unsilence-1.0.9-py3.7.egg/unsilence/command_line/EntryPoint.py", line 107, in run
  File "/usr/local/lib/python3.7/site-packages/unsilence-1.0.9-py3.7.egg/unsilence/Unsilence.py", line 105, in render_media
  File "/usr/local/lib/python3.7/site-packages/unsilence-1.0.9-py3.7.egg/unsilence/lib/render_media/MediaRenderer.py", line 138, in render
  File "/usr/lib64/python3.7/shutil.py", line 580, in move
    copy_function(src, real_dst)
  File "/usr/lib64/python3.7/shutil.py", line 266, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib64/python3.7/shutil.py", line 120, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/home/ec2-user/.tmp/45c670ce-03e7-4d50-b540-e07c7a616810/out_final.mp4'

This appears to be related to #17, but that was believed to be solved by #8. This is still happening to me using the currently latest master (f113336).

To Reproduce

  1. Use an amazon linux t3.nano
  2. Install ffmpeg using this guide: https://www.maskaravivek.com/post/how-to-install-ffmpeg-on-ec2-running-amazon-linux
  3. sudo yum update && sudo yum install git
  4. Install unsilence from source as per repo instructions
  5. unsilence input.mp4 output.mp4

Expected behavior

Should generate output.mp4 with silences sped up.

Desktop (please complete the following information):

  • OS + version: Amazon Linux amzn2-ami-kernel-5.10-hvm-2.0.20220606.1-x86_64-gp2
    ami-07620139298af599e
  • Python version: 3.7.16
  • FFMPEG version: 5.1.1-static https://johnvansickle.com/ffmpeg/

Crashes on `Segment-Durations-Ms` trying to interpret it as `Duration`

Describe the bug
Crashes on certain output of ffmpeg

To Reproduce
Steps to reproduce the behavior:

  1. unsilence in.mkv out.mkv
  2. Error Nonetype is not subsriptable

Expected behavior
Skips the Segment-Durations-Ms line instead of crashing.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS + version: W10 x64
  • Python version 3.9
  • FFMPEG version ffmpeg version 4.4-full_build-www.gyan.dev

Additional context
Seems to be an error in elif "Duration" in line: logic in DetectSilence.py.
Snippet of ffpmeg output, note Segment-Durations-Ms:

Input #0, matroska,webm, from '4_in.mkv':
  Metadata:
    HTTP://YOUTUBE.COM/STREAMING/OTF/DURATIONS/112015: Segment-Count: 1424
                    : Segment-Durations-Ms: 5067,5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),5066,5067(r=1),506
                    :
                    :
    ENCODER         : Lavf58.29.100
  Duration: 02:00:12.07, start: 0.000000, bitrate: 363 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709/unknown/unknown), 1280x720, SAR 1:1 DAR 16:9, 30 fps, 30 tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 02:00:11.999000000
  Stream #0:1(eng): Audio: aac (LC), 44100 Hz, stereo, fltp (default)
    Metadata:
      HANDLER_NAME    : ISO Media file produced by Google Inc.
      DURATION        : 02:00:12.071000000
Stream mapping:
  Stream #0:0 -> #0:0 (vp9 (native) -> wrapped_avframe (native))
  Stream #0:1 -> #0:1 (aac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help

Video renders silent

Describe the bug
I have a specific 7-hour 15-minute video which analyzes and renders successfully, but after rendering the completed video is completely silent. It fast forwards at the appropriate points where the original video is audible and silent, but there is no sound. When loaded into video editing software like Vegas Pro the rendered *.mp4 does not seem to include an audio track.

The original video does have audio which plays appropriately both in its native *.flv format and after remuxing to *.mp4 in the same players in which I am testing the rendered video.

I've tried using Unsilence on the original *.flv & remuxed *.mp4, and I've tried adjusting the parameters, but the rendered video always has no audio.

To Reproduce
This appears to only impact one video of mine; I can share the source and final files but as the source file is 7 hours long and 19GB I wanted to see if this was a known issue with larger files. If this isn't a known issue I can try to load the source and rendered files and provide more detail.

Parameters I'm using:

-as 1 -ss 64 -t 11 -stt 1 -sl -30

I have a different 7-hour 10-minute VOD that I was able to render successfully using multiple parameters, so I am not sure what is causing this video to lose audio in the rendering process.

The program doesnt seem to like my ffmpeg

Describe the bug

While running the example code provided on the repo I get this error.

File "C:\Users\Fran\Desktop\Videos Clases\videoprocesss test.py", line 4, in
u = Unsilence("file_example_MP4_480_1_5MG.mp4")

File "C:\Python38\Lib\site-packages\unsilence\Unsilence.py", line 27, in init
ffmpeg_version = get_ffmpeg_version()

File "C:\Python38\Lib\site-packages\unsilence\lib\tools\ffmpeg_version.py", line 20, in get_ffmpeg_version
groups = match.groups()

AttributeError: 'NoneType' object has no attribute 'groups'

Desktop (please complete the following information):

  • OS + version: Windows 10]
  • Python version 3.8
  • FFMPEG version 4.3

Im pretty new to all this, so I might be doing something wrong.
Any help would be appreciated.

Functionality Clarification: "Stretch Time too large" Error

Hello, I've continued to use this tool over the past week on the recent merge and it has been working great.

I did have one clarification request -- what causes the "Stretch time too large" error after "Calculating Intervals"? Is there a way to know if this error will be thrown before the interval calculation proceeds? Right now the "Calculating Intervals" part of the script takes 10-20 minutes for my very large video files, so it has been tough for me to experiment with stretch times that will work.

Define level of silence

Is your feature request related to a problem? Please describe.
This works really well however I have some background noise that is carried through and that I would like to be removed too Therefore it would be great if I could ignore silence below a certain threshold.

Describe the solution you'd like
A parameter of say decibels below which sound is treated as silence. Default can be zero.

Describe alternatives you've considered

Additional context

FileNotFoundError

When I try to use unsilence, the following happens:

Rendering Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” 100% 0:00:00
Combining Intervals... โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”   0% -:--:--
FileNotFoundError: [WinError 2] ็ณป็ปŸๆ‰พไธๅˆฐๆŒ‡ๅฎš็š„ๆ–‡ไปถใ€‚: 'C:\\Users\\h-zhao_01\\.tmp\\2815269f-cf00-4535-bce9-7c0523be2a54\\out_final.mp4' -> 'D:\\videos\\output.mp4'

During handling of the above exception, another exception occurred:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\h-zhao_01\\.tmp\\2815269f-cf00-4535-bce9-7c0523be2a54\\out_final.mp4'

I have tried with ffmpeg 4.3 and 4.2.3 versions, and both of them produced the same error. It seems that this is a different issue from #4. Is there anything I can do to fix it? Thank you!

Define a minimum of silence to remove

Is your feature request related to a problem? Please describe.
I have a podcast and I remove manually those long silence but reading the readme seems that there is no way to define a minimum of silence to remove.

Describe the solution you'd like
A parameter in milliseconds will be interesting for that.

unsilence leaves bash unusable

very cool project, already used on 3 video presentation
the issue i'm having is that, after unsilence terminates, bash is left in a wrong state and doesn't display what i'm typing. i have to blindly type a reset to return to a normal state.
here is a recording: https://asciinema.org/a/Ty6hLwjAUhSPb6dfKb3xEf96M
if you skip at the end, you can see that i try to type something without success

Suggestion for improving the speed of the silencedetect filter

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!

Recording truncated

Describe the bug
Since 2 weeks unsilence is not working anymore to me.

To Reproduce

unsilence $1 pulito-$1 -stt 0.4 -ao -sl '-18' -t 4

I always used in this way to clean my weekly podcast.
As example if I run this on the mp3 of this episode https://funkwhale.it/library/tracks/2065/ (that I cleaned manually after the issue to publish it)
Screenshot_20210914_154002
Unsilence detect the silence, and generate a cleaned file. With the original before the manual clean it was truncating the audio.

So if you download https://funkwhale.it/library/tracks/2057/ the previous episode that wasn't cleaned manually the problem is happening
Screenshot_20210914_154434

It is again everything working but the audio file generated:
immagine
Instead is just 2~ minutes

Desktop (please complete the following information):

  • OS + version: Debian sid
  • Python version 3.9.7
  • FFMPEG version 4.4-6

Add a fade on cutting

Is your feature request related to a problem? Please describe.
It is possible to add kind of audio transition after the audio is cut? I mean audio is cut so like for 0.3 seconds before the audio start with a fade so it is less brutal on listening (as it is now can be like an interruption).

AttributeError: 'NoneType' object has no attribute 'groups'

Same issue as #6

ffmpeg -version
ffmpeg version n4.2.3 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 10.1.0 (GCC)
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-avisynth --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmfx --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-version3
libavutil      56. 31.100 / 56. 31.100
libavcodec     58. 54.100 / 58. 54.100
libavformat    58. 29.100 / 58. 29.100
libavdevice    58.  8.100 / 58.  8.100
libavfilter     7. 57.100 /  7. 57.100
libswscale      5.  5.100 /  5.  5.100
libswresample   3.  5.100 /  3.  5.100
libpostproc    55.  5.100 / 55.  5.100

Commenting out the following fixes the issue:
https://github.com/lagmoellertim/unsilence/blob/master/unsilence/Unsilence.py#L27-L36

Request: Add argument to specify minimum buffer (# milliseconds) before fast-forwarding starts or ends

Is your feature request related to a problem? Please describe.
In my videos, I occasionally have extremely brief sounds or noises (mouse clicks, coughs) which cause a fast-forwarded "silent" portion to briefly return to normal speed, or sometimes the fast-forwarded gap causes the cadence of speech/pausing to sound awkward.

Describe the solution you'd like
Add an optional argument that specifies a minimum buffer in milliseconds that must elapse before a "silent" period transitions to an "audible" transition or vice-versa.

For example, if the user sets the buffer to 1000 milliseconds, then at least 1000 milliseconds of "audible" video will need to occur before fast-forwarding ends.

Describe alternatives you've considered
It would be great if we had an argument both for "silent buffer" (# milliseconds of audible video in order for fast forwarding to end) and for an "audible buffer" (# milliseconds of silent video in order for fast forwarding to begin), but a global buffer setting ought to be fine.

Additional context
As with my feature request for an argument to control the dB, strictness of the "silent" vs. "audible" sections, I can share pre- and post-processed examples of video where this issue is present per request.

Feature request: delete silence

Hi, I'm using unsilence for making vlogs and it is of great help so far. However, I need to delete silent parts of the video for my vlogs and it seems unsilence has not been able to achieve it.

I tried increasing the silence speed to 99 or so, but it results in video and audio out-of-sync problems. Also, it doesn't allow me to set silence speed to zero by returning a "zero division error".

It would be of great help if the triming silence function can be implemented.

Relax Python prerequisite?

Why is Python >=3.8 necessary?
Seems to be working fine on Python 3.7.7 at least (Windows 10 1909 x64):
image

Request: specify ffmpeg encoder and parameters

I would like the ffmpeg output to be losslessly encoded using libx265 -preset ultrafast -crf 0 -pix_fmt yuv420p for further editing using different application. The current implementation when specifying .mp4 output seems to make ffmpeg use the default libx264 -preset medium -crf 23. Or add just an option to pass lossless encoding to ffmpeg would be good too.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.