adamspierer / FreeClimber

FreeClimber is a background-subtracting particle detection platform designed to quantify group climbing performance in a Drosophila negative geotaxis (climbing) assay
MIT License
15 stars 5 forks source link

pythonw do nothing (ffmpeg problem?) #6

Open Vegeta4567 opened 10 months ago

Vegeta4567 commented 10 months ago

Hello,

I tried to follow the steps described in https://github.com/adamspierer/FreeClimber/blob/master/TUTORIAL.md

I am pretty sure I followed all the instructions, but when I try to run:

(python36) C:\Users\myUser\Desktop\free\FreeClimber>pythonw .\scripts\FreeClimber_gui.py --video_file .\example\w1118_m_2_1.avi

Is does absolutely nothing. I tried to redirect the output in a file, and I have this. I installed ffmpeg, added to the environment variables, but I am stuck. Do you have an idea?

Thanks a lot for your help and best regards!

Traceback (most recent call last): File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 276, in video_to_array out,err = (ffmpeg AttributeError: module 'ffmpeg' has no attribute 'input'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File ".\scripts\FreeClimber_gui.py", line 40, in OnInit frame = create(None, file_name) File ".\scripts\FreeClimber_gui.py", line 782, in create return main_gui(parent, file_path) File ".\scripts\FreeClimber_gui.py", line 125, in init self.load_video() File ".\scripts\FreeClimber_gui.py", line 192, in load_video variables = vars) File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 76, in init self.image_stack = self.video_to_array(video_file,loglevel='panic') File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 283, in video_to_array print('!! Could not read in video file to an array. Error message (if any):', err) UnboundLocalError: local variable 'err' referenced before assignment

########################################################################

FreeClimber v.0.4.0

Please cite: https://doi.org/10.1242/jeb.229377

Beginning program @ 2023-09-08 14:57:10

######################################################################## --> Video file: .\example\w1118_m_2_1.avi Loading: .\example\w1118_m_2_1.avi

!! Could not read .\example\w1118_m_2_1.avi into FreeClimber. Likely due to unacceptable video file or FFmpeg not installed !! Could not read in video file metadata OnInit returned false, exiting...

adamspierer commented 10 months ago

Hi @Vegeta4567,

It is likely an issue with the installation of FFmpeg. Could you try to install it manually from https://ffmpeg.org/ , restart your computer, and try again?

Otherwise, can you help me with the following in order:

  1. What version of Python are you running? Others have found issues when the Python version is incompatible. That said, the virtual environment should make that a non-issue if you are running in it. If you are using the virtual environment then move onto 2.
  2. Does the non-GUI version of the script work with the test files? This will tell me if wxPython is the issue or the installation of FFmpeg.
  3. Could you re-run the GUI and non-GUI versions of the script with the --debug tag as well? That will tell me which lines are unhappy and ideally it is the same part of the script for both.

Try this and let me know how things go!

Vegeta4567 commented 10 months ago

Hello,

Thanks for your fast reply!

I am using Python 3.6.0 in the virtual env. 3.6.10 in the base (same problem):

I reinstalled ffmpeg. ffmpeg -version gives: ffmpeg version 6.0-essentials_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers

The versions: argparse = 1.1 ffmpeg-python = 0.2.0 matplotlib = 3.1.3 numpy=1.19.5 pandas=1.0.5 pip=20.1.1 scipy=1.5.0 trackpy=0.4.2 wxPython = 4.0.4

If I run: pythonw .\scripts\FreeClimber_main.py --video_file .\example\w1118_m_2_1.avi it's the same problem. I suppose it's the non-GUI right?

I am not really familiar with Python, where I put the --debug command?

Thanks a lot and best!

adamspierer commented 10 months ago

The debug command would go at the end of when you call the script: pythonw .\scripts\FreeClimber_main.py --video_file .\example\w1118_m_2_1.avi --debug

To run the non-GUI, try this as well: python FreeClimber_main.py --config_file ./example/example.cfg --debug

Vegeta4567 commented 10 months ago

Hello,

The first command returns absolutely nothing.

For the second one, I have this result:

########################################################################

FreeClimber v.0.4.0

Please cite: https://doi.org/10.1242/jeb.229377

Beginning program @ 2023-09-12 08:58:52

######################################################################## Namespace(config_file='./example/example.cfg', debug=True, no_concat=False, optimization_plots=False, process_all=False, process_custom=False, process_undone=False) main.check_config Namespace(config_file='./example/example.cfg', debug=True, no_concat=False, optimization_plots=False, process_all=False, process_custom=False, process_undone=False) FreeClimber.init FreeClimber.load_parameters FreeClimber.get_filelist FreeClimber.file_walker FreeClimber.create_log_header Creating completed .log file: ./examplelog/completed.log Creating skipped .log file: ./examplelog/skipped.log ./example\w1118_m_2_1.h264 FreeClimber.process FreeClimber.print_new_video

== [1 || 1] w1118_m_2_1.h264 ===========================================

detector.init detector.check_video...detector.load_for_main detector.load_for_main: --------variables-------- detector.load_for_main: x=100 detector.load_for_main: y=136 detector.load_for_main: w=1112 detector.load_for_main: h=380 detector.load_for_main: check_frame=100 detector.load_for_main: blank_0=0 detector.load_for_main: blank_n=145 detector.load_for_main: crop_0=0 detector.load_for_main: crop_n=145 detector.load_for_main: threshold="auto" detector.load_for_main: diameter=7 detector.load_for_main: minmass=100 detector.load_for_main: maxsize=11 detector.load_for_main: ecc_low=.05 detector.load_for_main: ecc_high=.58 detector.load_for_main: vials=3 detector.load_for_main: window=50 detector.load_for_main: pixel_to_cm=46 detector.load_for_main: frame_rate=29 detector.load_for_main: vial_id_vars=2 detector.load_for_main: outlier_TB=1 detector.load_for_main: outlier_LR=3 detector.load_for_main: naming_convention="geno_sex_day_rep" detector.load_for_main: path_project="./example" detector.load_for_main: file_suffix="h264" detector.load_for_main: convert_to_cm_sec=True detector.load_for_main: trim_outliers=True detector.check_variable_formats

detector.specify_paths_details detector.specify_paths_details: self.path_data='./example\w1118_m_2_1.raw.csv' detector.specify_paths_details: self.path_filtered='./example\w1118_m_2_1.filtered.csv' detector.specify_paths_details: self.path_diagnostic='./example\w1118_m_2_1.diagnostic.png' detector.specify_paths_details: self.path_slope='./example\w1118_m_2_1.slopes.csv' detector.video_to_array !! Could not read ./example\w1118_m_2_1.h264 into FreeClimber. Likely due to unacceptable video file or FFmpeg not installed !! Could not read in video file metadata Traceback (most recent call last): File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 276, in video_to_array out,err = (ffmpeg AttributeError: module 'ffmpeg' has no attribute 'input'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File ".\scripts\FreeClimber_main.py", line 489, in main() File ".\scripts\FreeClimber_main.py", line 464, in main fc.process(video_file = File,variables = None, config_file = fc.config_file) File ".\scripts\FreeClimber_main.py", line 191, in process d = detector.detector(video_file = video_file, config_file = config_file, debug = self.args.debug) File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 76, in init self.image_stack = self.video_to_array(video_file,loglevel='panic') File "C:\Users\myUser\Desktop\free\FreeClimber\scripts\detector.py", line 283, in video_to_array print('!! Could not read in video file to an array. Error message (if any):', err) UnboundLocalError: local variable 'err' referenced before assignment

simxn18 commented 9 months ago

I get the same error. Please help:(

Vegeta4567 commented 9 months ago

Hello,

For me, the problem was the virtual env.

I have totally uninstalled python and anaconda. Reinstalled anaconda Installed python 3.6.8 https://www.python.org/ftp/python/3.6.8/python-3.6.8-amd64.exe Reboot the computer Launched a anaconda console Installed the dependencies needed. pip install argparse pip install ffmpeg-python pip install matplotlib pip install numpy pip install pandas pip install scipy pip install trackpy pip install wxPython pip install FreeClimber

And it works :-)