You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thank you for all your work regarding the last update! It is great that video files are not overwritten anymore.
However, I now found out that one of my own changes to the code is not working anymore as I intended, probably because I implemented it wrongly. What I would like is for all generated files, that the name does not only consist of the timestamp of recording start, but also the date and animal number. Basically, adding the name of the parent folder to the filename itself, like so:
C:\Users\zuidinga\Data\protocol_name\220331_f60\220331_f60_110908_video.mp4 instead of
C:\Users\zuidinga\Data\protocol_name\220331_f60\110908_video.mp4
(this change used to be enough for it to work for all files, since the write.py of the video process also used self.filename_base: birtezuidinga@7984edd)
Now that different methods are used in write.py to get the filename_base, I cannot get it to work anymore for the video and video_times files. I tried changing the __generate_filename code to the following:
def __generate_filename(self, filename: str) -> str:
"""
Generates the filename dependent on the given filename and the extension.
Parameters
----------
filename
a unique identifier to be used in the filename for saving the video file.
"""
detailed_name = str(filename.parts[-2]) + "_" + str(filename.name)
directory = filename.parent
new_filename_base = directory / detailed_name
return str(new_filename_base) + "video." + self._extension
Sometimes, it works correctly, and other times it gives this error:
Process :
Traceback (most recent call last):
File "C:\Users\zuidinga\Miniconda3\envs\stytra_env_github\lib\multiprocessing\process.py", line 297, in _bootstrap
self.run()
File "C:\Users\zuidinga\PycharmProjects\stytra_birte\stytra\stytra\hardware\video\write.py", line 91, in run
self._configure(current_frame.shape)
File "C:\Users\zuidinga\PycharmProjects\stytra_birte\stytra\stytra\hardware\video\write.py", line 295, in _configure
self._container = av.open(self.__container_filename, mode="w")
File "av\container\core.pyx", line 364, in av.container.core.open
File "av\container\core.pyx", line 146, in av.container.core.Container.__cinit__
ValueError: Could not determine output format
Do you have any idea how I could fix this? I probably don't understand the process of the filename queue correctly, I think I'd need to change some default string there, but I cannot find it.
The text was updated successfully, but these errors were encountered:
I think it would be far easier to rely on the JSON that gets auto-generated with the video on getting metadata, or writing a small script in python that renames files rather than changing the internals of Stytra. What exactly are you doing with the videos afterwards that requires such a naming schema?
Thank you for your reply. Did not realise it would be a difficult change to copy the folder name in front of the timestamp. But I will rename the files afterwards then.
The reason is that I prefer to immediately see which videos were from which flies on which day just from the name, since I am importing many videos separately into a behavioural classification model. The outputs of this model use the names of the video files. And so by having a unique name for each experimental trial, I can search through these outputs quickly to match it to other information saved in the metadata and other files. Since the videos in the analysis end up together in a different folder, the nice folder structure that Stytra outputs gets lost there.
Thank you for all your work regarding the last update! It is great that video files are not overwritten anymore.
However, I now found out that one of my own changes to the code is not working anymore as I intended, probably because I implemented it wrongly. What I would like is for all generated files, that the name does not only consist of the timestamp of recording start, but also the date and animal number. Basically, adding the name of the parent folder to the filename itself, like so:
C:\Users\zuidinga\Data\protocol_name\220331_f60\220331_f60_110908_video.mp4 instead of
C:\Users\zuidinga\Data\protocol_name\220331_f60\110908_video.mp4
(this change used to be enough for it to work for all files, since the write.py of the video process also used self.filename_base: birtezuidinga@7984edd)
Now that different methods are used in write.py to get the filename_base, I cannot get it to work anymore for the video and video_times files. I tried changing the __generate_filename code to the following:
Sometimes, it works correctly, and other times it gives this error:
Do you have any idea how I could fix this? I probably don't understand the process of the filename queue correctly, I think I'd need to change some default string there, but I cannot find it.
The text was updated successfully, but these errors were encountered: