-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GPU hardware encoding: Option hwaccel (use HW accelerated decoding) cannot be applied to output url #12
Comments
Good job hunting down the hard-coded bug in in the writer. To see if the GPU is being utilized, you can look at GPU0 tab's video encoding usage in Windows task manager. I haven't tested with AMD GPU for a while, so it may be time to refresh the AMD GPU options in campy. The fps issue could be related to triggering. Seems like the camera is trying to run at the max frame rate given your 10 ms exposure time. Not sure why FLIR isn't setting the proper frame rate, but I can look into that with my FLIR testing camera. In the meantime, perhaps you can try hardware triggering to hard-cap the frame rate. See the trigger modules I wrote for Teensy and Arduino microcontrollers. P.S. I apologize for the slow reply to your issue. |
no worries. we are all busy. :) so here is what I learned in the mean time:
then the camera parameters are changed as per the users specs. maybe you dont want to do that each time but refreshes the camera such that changes to the nodes can be written.
alright, hardware triggering is next. i ll report back if that works on my flir/amd combo. cheers |
Hi all. This thread has been very helpful for setting up my blackflyl s mono cameras.
|
@histun It looks like the line numbers have changed a bit in the flir.py file. Would you be able to provide the specific line that needed commenting out in the flir.py file to fix plotting the video? I am currently troubleshooting my FLIR monochrome cam setup as well. |
Never mind! I found it! For those who are experiencing this issue; the correct lines to comment out in the flir.py file to make the video window show up is below, simply replace with this function with the correct lines commented out (also be sure that you follow @histun and @chgebhardt 's instructions regarding editing the flir.py and display.py files.
|
Great package. Saved us a lot of trouble trying to dig into PySpin and dealing with camera nodes etc ourselves. :)
We have several Blackfly S BFS-U3-51S5M FLIR cameras that in the far future we want to combine into a behavior setup plus open ephys system. So far we have managed to install the newest campy-master on a win 10 system with AMD Radeon Pro Wx 7100 without major hickups in a conda environment as per your instructions.
Due to the cameras being mono we had to comment out camera.BalanceWhiteAuto.SetValue in function ConfigurePixelFormat() and changed pixelFormatInput from "rgb24" to "gray" in the config.yaml. also StreamBufferCountManual.SetValue() only works with a value of 60 instead of 100 without crashing during acquisition. so far, we can stream from two cameras without GPU support.
We hit a bit of a wall though when we wanted to activate GPU support (using one camera atm). ffmpeg is installed in the environment and working but we get this error message:
`Opened: d:/data/20210910/Camera0\0.mp4 using GPU 0 to compress the stream.
WARNING: QApplication was not created in the main() thread.
Trigger source set to None...
Width set to 1280...
Height set to 1024...
Shutter time set to 10000 us...
Gain set to 1 dB.
Gamma correction disabled.
Buffer count now set to: 60
BufferMode has been set to Oldest First
Opened Camera0: flir Blackfly S BFS-U3-51S5M
Camera0 ready to trigger.
Option hwaccel (use HW accelerated decoding) cannot be applied to output url d:/data/20210910/Camera0\0.mp4 -- you are trying to apply an input option to an output file or vice versa. Move this option before the file it belongs to.
Error parsing options for output file d:/data/20210910/Camera0\0.mp4.
Error opening output files: Invalid argument
multiprocessing.pool.RemoteTraceback:
"""
Traceback (most recent call last):
File "C:\Users\kim\anaconda3\envs\campy\lib\site-packages\imageio_ffmpeg_io.py", line 493, in write_frames
p.stdin.write(bb)
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kim\anaconda3\envs\campy\lib\multiprocessing\pool.py", line 121, in worker
result = (True, func(*args, **kwds))
File "C:\Users\kim\anaconda3\envs\campy\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "c:\users\kim\campy-master\campy\campy.py", line 71, in AcquireOneCamera
writer.WriteFrames(cam_params, writeQueue, stopReadQueue, stopWriteQueue)
File "c:\users\kim\campy-master\campy\writer.py", line 153, in WriteFrames
writer.send(writeQueue.popleft())
File "C:\Users\kim\anaconda3\envs\campy\lib\site-packages\imageio_ffmpeg_io.py", line 500, in write_frames
raise IOError(msg)
OSError: [Errno 32] Broken pipe
FFMPEG COMMAND:
C:\Users\kim\anaconda3\envs\campy\Library\bin\ffmpeg.exe -y -f rawvideo -vcodec rawvideo -s 1280x1024 -pix_fmt gray -r 40.00 -an -i - -an -vcodec hevc_amf -pix_fmt yuv420p -qscale:v 16 -v warning -r:v 40 -usage lowlatency -rc cqp -qp_i 21 -qp_p 21 -qp_b 21 -bf:v 0 -hwaccel auto -hwaccel_device 0 d:/data/20210910/Camera0\0.mp4
FFMPEG STDERR OUTPUT:
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\kim\anaconda3\envs\campy\Scripts\campy-acquire-script.py", line 33, in
sys.exit(load_entry_point('campy', 'console_scripts', 'campy-acquire')())
File "c:\users\kim\campy-master\campy\campy.py", line 78, in Main
p.map_async(AcquireOneCamera,range(params["numCams"])).get()
File "C:\Users\kim\anaconda3\envs\campy\lib\multiprocessing\pool.py", line 657, in get
raise self._value
OSError: [Errno 32] Broken pipe
FFMPEG COMMAND:
C:\Users\kim\anaconda3\envs\campy\Library\bin\ffmpeg.exe -y -f rawvideo -vcodec rawvideo -s 1280x1024 -pix_fmt gray -r 40.00 -an -i - -an -vcodec hevc_amf -pix_fmt yuv420p -qscale:v 16 -v warning -r:v 40 -usage lowlatency -rc cqp -qp_i 21 -qp_p 21 -qp_b 21 -bf:v 0 -hwaccel auto -hwaccel_device 0 d:/data/20210910/Camera0\0.mp4
FFMPEG STDERR OUTPUT:`
somehow hwaccel ends up as an output option in the ffmpeg call but is expected as input option? on a hunch we commented -hwaccel and hwaccel_device out in writer.py in lines 85 and 86. campy-acquire is running through now without error message. we are just not sure that it actually uses the GPU. also the framerate of the acquisition seems to be independent of what we specify in the config.yaml and is always 98fps (as confirmed by the timestamps). the correct number of frames (=frameRate*recTimeSec) is recorded though.
sorry if the solution is obvious but any pointer on how to get GPU encoding to run would be appreciated.
thank you so much,,
chris
The text was updated successfully, but these errors were encountered: