excitoon / video-remove-silence

Tool for removing silence from video files
MIT License
109 stars 23 forks source link

Errror after gaps found #3

Open alexandreraufast opened 5 years ago

alexandreraufast commented 5 years ago

Hello, I'm trying your code, find it incredibly useful, but i've got an error. Do you have a clue about what's happening ? (I'm on Windows10 x64, Python 3.5.2)

Thank you very much for this excellent code (edit : I've got the problem with multiple mp4 files)

C:>video-remove-silence test.mp4 Extracting audio... Finding gaps... Found 1 gaps, 15.6 seconds total Traceback (most recent call last): File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\video-remove-silence", line 162, in frames = ffprobe.get_frames(args.path) File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 16, in get_frames for stream in _get_json(path)['streams']: File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 6, in _get_json result = subprocess.run(['ffprobe', path, '-loglevel', 'quiet', '-print_format', 'json', '-show_streams'], stdout=subprocess.PIPE) File "C:\Program Files\Python35\lib\subprocess.py", line 693, in run with Popen(*popenargs, **kwargs) as process: File "C:\Program Files\Python35\lib\subprocess.py", line 947, in init restore_signals, start_new_session) File "C:\Program Files\Python35\lib\subprocess.py", line 1224, in _execute_child startupinfo) FileNotFoundError: [WinError 2] Le fichier spécifié est introuvable

excitoon commented 5 years ago

It seems that it misses ffprobe.exe tool from FFmpeg. Can you place it to %PATH%?

alexandreraufast commented 5 years ago

Hello, I did add them to path, actually I've tried with C:\ffmpeg ; C:\ffmpeg\bin and C:\ffmpeg\bin\ffprobe.exe and I tried rebooting my PC, I've got exactly same error. The name I gave to the path variable is "ffprobe.exe", and i also tried "ffprobe", but it doesn't matter does it ?

Thk you so much for your help

alexandreraufast commented 5 years ago

Ok, I'll solve this problem myself, doing 'set PATH=%PATH%;C:\ffmpeg\bin' before executing does the job, but unlucky, I still get an error

Extracting audio... Finding gaps... Found 1 gaps, 15.6 seconds total Traceback (most recent call last): File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\video-remove-silence", line 162, in frames = ffprobe.get_frames(args.path) File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 16, in get_frames for stream in _get_json(path)['streams']: File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 8, in _get_json return json.loads(result.stdout) File "C:\Program Files\Python35\lib\json__init.py", line 312, in loads s.class.name__)) TypeError: the JSON object must be str, not 'bytes'

alexandreraufast commented 5 years ago

I don't know if that will help you, but if I try forcing String type with return json.loads(str(result.stdout)) in ffprobe line 8, I get this error

Extracting audio... Finding gaps... Found 1 gaps, 15.6 seconds total Traceback (most recent call last): File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\video-remove-silence", line 162, in frames = ffprobe.get_frames(args.path) File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 16, in get_frames for stream in _get_json(path)['streams']: File "C:\Users\Tensorflow\Desktop\REMOVE_SILENCES_FROM_VIDEO\video-remove-silence-master\ffprobe.py", line 8, in _get_json return json.loads(str(result.stdout)) File "C:\Program Files\Python35\lib\json__init__.py", line 319, in loads return _default_decoder.decode(s) File "C:\Program Files\Python35\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\Python35\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

excitoon commented 5 years ago

@alexandreraufast May I ask you to start fresh cmd.exe and type:

ffprobe c:/test.mp4
alexandreraufast commented 5 years ago

ffprobe version N-93252-gf948082e5f Copyright (c) 2007-2019 the FFmpeg developers built with gcc 8.2.1 (GCC) 20190212 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt libavutil 56. 26.100 / 56. 26.100 libavcodec 58. 47.102 / 58. 47.102 libavformat 58. 26.101 / 58. 26.101 libavdevice 58. 6.101 / 58. 6.101 libavfilter 7. 48.100 / 7. 48.100 libswscale 5. 4.100 / 5. 4.100 libswresample 3. 4.100 / 3. 4.100 libpostproc 55. 4.100 / 55. 4.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'c:/test.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: mp41isom creation_time : 2018-08-11T15:10:44.000000Z artist : Microsoft Game DVR title : test Duration: 00:00:15.60, start: 0.000000, bitrate: 10371 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1376x744 [SAR 1:1 DAR 172:93], 9668 kb/s, 30.23 fps, 60 tbr, 30k tbn, 59.94 tbc (default) Metadata: creation_time : 2018-08-11T15:10:44.000000Z handler_name : VideoHandler encoder : AVC Coding Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 169 kb/s (default) Metadata: creation_time : 2018-08-11T15:10:44.000000Z handler_name : SoundHandler

egrinant commented 4 years ago

@alexandreraufast necro post perhaps but I will leave it here if anyone else needs it. In ffprobe.py change line 8 to return json.loads(result.stdout.decode())