How to use the vidgear.gears.helper.get_valid_ffmpeg_path function in vidgear

To help you get started, we’ve selected a few vidgear examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github abhiTronix / vidgear / tests / test_helper.py View on Github external
def test_get_valid_ffmpeg_path(paths, ffmpeg_download_paths, results):
	_windows  = True if os.name == 'nt' else False
	try:
		output = get_valid_ffmpeg_path(custom_ffmpeg = paths, is_windows = _windows, ffmpeg_download_path = ffmpeg_download_paths, logging = True)
		if not (paths == 'wrong_test_path' or ffmpeg_download_paths == 'wrong_test_path'):
			assert bool(output) == results, "FFmpeg excutables validation and correction Test failed at path: {} and FFmpeg ffmpeg_download_paths: {}".format(paths, ffmpeg_download_paths)
	except Exception as e:
		if paths == 'wrong_test_path' or ffmpeg_download_paths == 'wrong_test_path':
			pass
		else:
			pytest.fail(str(e))
github abhiTronix / vidgear / vidgear / gears / writegear.py View on Github external
print('Compression Mode is enabled therefore checking for valid FFmpeg executables!')
				print(self.output_parameters)

			# handles where to save the downloaded FFmpeg Static Binaries on Windows(if specified)
			ffmpeg_download_path_ = ''
			if self.output_parameters and "-ffmpeg_download_path" in self.output_parameters:
				ffmpeg_download_path_ += self.output_parameters["-ffmpeg_download_path"]
				del self.output_parameters["-ffmpeg_download_path"] #clean

			#handle input framerate if specified
			if self.output_parameters and "-input_framerate" in self.output_parameters:
				self.inputframerate += float(self.output_parameters["-input_framerate"])
				del self.output_parameters["-input_framerate"] #clean

			#validate the FFmpeg path/binaries and returns valid FFmpeg file executable location(also downloads static binaries on windows) 
			actual_command = get_valid_ffmpeg_path(custom_ffmpeg, self.os_windows, ffmpeg_download_path = ffmpeg_download_path_, logging = self.logging)

			#check if valid path returned
			if actual_command:
				self.ffmpeg += actual_command #assign it to class variable
				if self.logging:
					print('Found valid FFmpeg executables: `{}`'.format(self.ffmpeg))
			else:
				#otherwise disable Compression Mode
				if self.logging and not self.os_windows:
					print('Kindly install working FFmpeg or provide a valid custom FFmpeg Path')
				print('Caution: Disabling Video Compression Mode since no valid FFmpeg executables found on this machine!')
				self.compression = False # compression mode disabled

		#validate this class has the access rights to specified directory or not
		assert os.access(basepath, os.W_OK), "Permission Denied: Cannot write to directory = " + basepath