vidgear: Wrong validation - ValueError: [WriteGear:ERROR] :: output_filename value:`/Users/*****/Documents/PythonEnv/1.mp4` is not valid/supported in Compression Mode!

Description

The WriteGear is checking for OS folder access and failing the process for no good reason, after bypassing the check all is working as expected.

Acknowledgment

Environment

VidGear 0.2.0 Branch: PyPi Python 3.9.1 Pip 20.3.4 OS: Mac 10.14.6

Expected Behavior

The local video file should rendered/created using FFMPEG.

Actual Behavior

I got the following error (logging is True):

Output file: /Users/*****/Documents/PythonEnv/1.mp4 15:46:25 :: WriteGear :: WARNING :: The given path:/Users/******/Documents/PythonEnv/1.mp4 does not have write access permission. Skipped! 15:46:25 :: WriteGear :: DEBUG :: Compression Mode is enabled therefore checking for valid FFmpeg executables. 15:46:25 :: WriteGear :: DEBUG :: Output Parameters: {‘-input_framerate’: 29.97002997002997, ‘-vf’: ‘scale=3840x1080’, ‘-c:v’: ‘libx264’, ‘-crf’: ‘1’, ‘-maxrate’: ‘20.0M’, ‘-bufsize’: ‘24M’, ‘-pix_fmt’: ‘yuv420p’} 15:46:25 :: Helper :: DEBUG :: Final FFmpeg Path: ffmpeg 15:46:25 :: Helper :: DEBUG :: FFmpeg validity Test Passed! 15:46:25 :: Helper :: DEBUG :: Found valid FFmpeg Version: b'4.3.1' installed on this system 15:46:25 :: WriteGear :: DEBUG :: Found valid FFmpeg executables: ffmpeg. 15:46:26 :: Helper :: WARNING :: URL scheme /Users/*****/Documents/PythonEnv/1.mp4 is not supported by FFmpeg! Traceback (most recent call last): File “/Users//Documents/PythonEnv/./gyroflow/gyroflow.py", line 1519, in export_video self.stab.renderfile(start_time, stop_time, filename[0], out_size = out_size, File "/Users//Documents/PythonEnv/gyroflow/stabilizer.py”, line 511, in renderfile out = WriteGear(output_filename=outpath, **output_params, logging=True) File “/Users/*******/Documents/PythonEnv/venv391/lib/python3.9/site-packages/vidgear/gears/writegear.py”, line 246, in init raise ValueError( ValueError: [WriteGear:ERROR] :: output_filename value:/Users/******/Documents/PythonEnv/1.mp4 is not valid/supported in Compression Mode!

Possible Fix

In WriteGear.py: Line 126 : I changed: if ( self.__os_windows or os.access in os.supports_effective_ids ) and os.access(os.path.dirname(abs_path), os.W_OK): To if(True) and it all worked. Meaning the if expression is not working properly. My guess is that it is different on a PC vs Mac or that the Virtual Environment is impacting this ‘if’

Steps to reproduce

(Write your steps here:)

  1. Download gyroFlow and all dependencies (VidGear included)
  2. Run Venv (Python Virtual Environment) with all the dependencies
  3. Try to stabilize a video

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (13 by maintainers)

Commits related to this issue

Most upvoted comments

@abhiTronix - Working like a charm: In Venv: Output file: /Users/nivgarber/Documents/PythonEnv/234342.mp4 20:22:11 :: WriteGear :: DEBUG :: Compression Mode is enabled therefore checking for valid FFmpeg executables. 20:22:11 :: WriteGear :: DEBUG :: Output Parameters: {‘-input_framerate’: 29.97002997002997, ‘-vf’: ‘scale=3840x1080’, ‘-c:v’: ‘libx264’, ‘-crf’: ‘1’, ‘-maxrate’: ‘20.0M’, ‘-bufsize’: ‘24M’, ‘-pix_fmt’: ‘yuv420p’} 20:22:11 :: Helper :: DEBUG :: Final FFmpeg Path: ffmpeg 20:22:11 :: Helper :: DEBUG :: FFmpeg validity Test Passed! 20:22:11 :: Helper :: DEBUG :: Found valid FFmpeg Version: b'4.3.1' installed on this system 20:22:11 :: WriteGear :: DEBUG :: Found valid FFmpeg executables: ffmpeg. 20:22:11 :: WriteGear :: DEBUG :: Compression Mode is configured properly! FRAME: 0, IDX: 0 20:22:11 :: WriteGear :: DEBUG :: InputFrame => Height:1080 Width:3840 Channels:3 20:22:11 :: WriteGear :: DEBUG :: Setting Input framerate: 29.97002997002997 20:22:11 :: WriteGear :: DEBUG :: Executing FFmpeg command: ffmpeg -y -f rawvideo -vcodec rawvideo -s 3840x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -vf scale=3840x1080 -c:v libx264 -crf 1 -maxrate 20.0M -bufsize 24M -pix_fmt yuv420p -vcodec libx264 -preset fast /Users/nivgarber/Documents/PythonEnv/234342.mp4 ffmpeg version 4.3.1 Copyright © 2000-2020 the FFmpeg developers built with Apple clang version 11.0.0 (clang-1100.0.33.17) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, rawvideo, from ‘pipe:’: Duration: N/A, start: 0.000000, bitrate: 2983000 kb/s Stream #0:0: Video: rawvideo (BGR[24] / 0x18524742), bgr24, 3840x1080, 2983000 kb/s, 29.97 tbr, 29.97 tbn, 29.97 tbc Multiple -c, -codec, -acodec, -vcodec, -scodec or -dcodec options specified for stream 0, only the last option ‘-c:v libx264’ will be used. Stream mapping: Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264)) FRAME: 1, IDX: 1 [libx264 @ 0x7fd0d8001c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 0x7fd0d8001c00] profile High, level 5.0, 4:2:0, 8-bit [libx264 @ 0x7fd0d8001c00] 264 - core 161 r3027 4121277 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=1 ref=2 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=6 psy=1 psy_

Outside of venv: Output file: /Users/nivgarber/Documents/PythonEnv/234342_not_venv.mp4 20:26:27 :: WriteGear :: DEBUG :: Compression Mode is enabled therefore checking for valid FFmpeg executables. 20:26:27 :: WriteGear :: DEBUG :: Output Parameters: {‘-input_framerate’: 29.97002997002997, ‘-vf’: ‘scale=3840x1080’, ‘-c:v’: ‘libx264’, ‘-crf’: ‘1’, ‘-maxrate’: ‘20.0M’, ‘-bufsize’: ‘24M’, ‘-pix_fmt’: ‘yuv420p’} 20:26:27 :: Helper :: DEBUG :: Final FFmpeg Path: ffmpeg 20:26:27 :: Helper :: DEBUG :: FFmpeg validity Test Passed! 20:26:27 :: Helper :: DEBUG :: Found valid FFmpeg Version: b'4.3.1' installed on this system 20:26:27 :: WriteGear :: DEBUG :: Found valid FFmpeg executables: ffmpeg. 20:26:27 :: WriteGear :: DEBUG :: Compression Mode is configured properly! FRAME: 899, IDX: 0 20:26:29 :: WriteGear :: DEBUG :: InputFrame => Height:1080 Width:3840 Channels:3 20:26:29 :: WriteGear :: DEBUG :: Setting Input framerate: 29.97002997002997 20:26:29 :: WriteGear :: DEBUG :: Executing FFmpeg command: ffmpeg -y -f rawvideo -vcodec rawvideo -s 3840x1080 -pix_fmt bgr24 -framerate 29.97002997002997 -i - -vf scale=3840x1080 -c:v libx264 -crf 1 -maxrate 20.0M -bufsize 24M -pix_fmt yuv420p -vcodec libx264 -preset fast /Users/nivgarber/Documents/PythonEnv/234342_not_venv.mp4 ffmpeg version 4.3.1 Copyright © 2000-2020 the FFmpeg developers built with Apple clang version 11.0.0 (clang-1100.0.33.17) configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_9 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack

Thank you so much for the quick fix!

Good point, didn’t check - Let me try.

Documents folder is indeed present, and as I wrote in the ultra detailed bug openning doc 😉 - Mac 10.14.6

Do you want me to try and see which part of the If statement fails in WriteGear.py?

I can share with you the logging of it failing as well if it helps