Skip to content
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

Feature: file name templating #31

Open
yuyangchee98 opened this issue Mar 23, 2024 · 5 comments
Open

Feature: file name templating #31

yuyangchee98 opened this issue Mar 23, 2024 · 5 comments

Comments

@yuyangchee98
Copy link

yuyangchee98 commented Mar 23, 2024

Hi, thanks for making this.

The current file name seems to be in the format (please correct me if I am wrong):
DISPLAY-YYYY-MM-DD_HH-MM-SS, where HHMMSS is the time started.

Is it possible to automatically save the file such that the file name includes the starting time and the ending time?

"templating" the file name is discussed here but it is closed, and doesn't seem to be a feature from what I can see.

#10

Thanks again, and let me know if I can help or provide more information

@wkaisertexas
Copy link
Owner

I am not too sure about this. Time formats can be quite complex and I am not sure that I want to give people direct access to template strings. To me that seems kind of overwhelming and confusing.

What about an interface which is three dropdowns?

[Device][Start Time][End Time]

[Device]
Display #1
Dsp-1
..

[Start Time]
12/29/2024
29/12/2024
29/12
12/29
...

[End Time]
12/29/2024
29/12/2024
29/12
12/29
10hours
600minutes
...

Something where the format would be conveyed in the dropdowns?

I am not too sure about how this would be integrated which is why I closed #9.

@yuyangchee98
Copy link
Author

yuyangchee98 commented Mar 24, 2024

Agreed that direct access to full templating is not required. I guess I just used the name becuase it was mentioned in #10

I think the interface you drafted is a great idea.

Personally though, all I wanted was to include the end time in the name of the file because it's difficult to keep track of whats going on after several recordings.

Any further formatting of the name can be easily modified by the user with basic bash once the essential data (which is , imo, display, start, end) is there, anyway.

As for implementation, a poor method I came up with was to just rename the file after saving. See example below.

               let originalURL = writer.outputURL
               let fileManager = FileManager.default
               let fileExtension = originalURL.pathExtension
               let baseName = originalURL.deletingPathExtension().lastPathComponent

               // Format the current date and time
               let dateFormatter = DateFormatter()
               dateFormatter.dateFormat = "yyyy-MM-dd-HH-mm-ss"
               let dateString = dateFormatter.string(from: Date())

               let newName = "\(baseName)_\(dateString).\(fileExtension)"
               let directory = originalURL.deletingLastPathComponent().path
               let newURL = URL(fileURLWithPath: directory).appendingPathComponent(newName)
               do {
                   try fileManager.moveItem(at: originalURL, to: newURL)
                   logger.log("File renamed to \(newName)")
               } catch {
                   logger.error("Failed to rename file: \(error.localizedDescription)")
               }

This can be used after within writer.finishWriting {} and after sendNotification(title: "\(self) saved", body: "Saved video", url: writer.outputURL) and logger.log("Saved video to \(writer.outputURL.absoluteString)").

This is probably very far from an optimal solution. I haven't done swe in awhile.

Thoughts?

@wkaisertexas
Copy link
Owner

Yeah, that would definitely be ideal. I currently resort to just showing the video in preview where you can resave, but I will see about adding a feature where it is more explicit and you can specify the name

@wkaisertexas
Copy link
Owner

I have been thinking about this more. I think I am going to change the default DISPLAY-YYYY-MM-DD_HH-MM-SS to make it a bit more compact (probably no need for seconds here). Then, I am going to make a screen which shows a preview of your video and asks you where you want to save it.

Eventually this could be a re-encoder as well if, for example, you wanted to create a ten-minute video or something.

@wkaisertexas
Copy link
Owner

I think this would be better for most people than a fixed template

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants