Skip to content

Using another filename convention #76

Description

@birtezuidinga

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions