Pre-linked scripting etc. for uploads

Merry Christmas to all,

general question: What would be the easiest way to automate some pre-processing to specific file types before uploading?

My private use case is the following:

For whatever annoying reason my new (!) smartphone uses H.263 as codec for videos. Firefox (Linux/Windows/Android) does not play H.263 embedded, neither standalone, as file, nor within Nextcloud. As I and lot of friends are using (and loving) Firefox, I would like to get my vids converted with ffmpeg before stored finally and shared afterwards in my Nextcloud. Especially these days frequently used, for grand parents, aunts and uncles etc. :slight_smile:

Doing this on outside of Nextcloud on Linux is a no-brainer. But as these are smartphone-made videos, they’re are always upladed with the nextcloud sync app.

So I guess it must/should be some serverside pre-linked whatever, so ideas and hints where to search / where to start are very welcome.

Nextcloud is 12.0.4 on my private virtual server on Linux.

P.S.: I’m aware that there are video converters outside available as app, on android. All of them with tons of adds, transforming your phone into a fairground booth, no thanks, or as shareware, with useless reduced functionality. I’m searching for hints for a solution I can implement myself.

P.P.S.: Not sure if this questions are correct for “general” - thought about “support” or “dev” etc. - feel free to move my topic to anything maybe more appropriate

Merry Christmas,
you could do something with cronjobs. I have a similar problem where I scale down uploaded images that are uploaded to a specific folder.

I currently can’t access my server via SSH, so I can’t share my script, but here is the essential functionality:

  • Check the folder for changes (via size; I store the size in a file to be able to compare to the previous run of the script)
  • Copy the original photos to a new folder
  • Scale down the photos and move them to a new folder as well
  • Rescan folders to tell Nextcloud that something changed

Caution: As this happens outside of Nextcloud, it may cause data loss or corruption (if the files are accessed simultaneously). I think this can be prevented with using an upload folder in External Storage. I never faced any issues with my folder not being shared.

PS: I am hoping for a more flexible workflowengine, so things like this could be implemented as apps that support chaining them together to complex workflows.

1 Like

To avoid that, you could use cURL for file operations inside nextcloud as described here:
I am using cURL for file operations inside my nextcloud quite often and it works well.

Your workflow could then look like this:

  • check folder for changes
  • convert videos with ffmpeg (choose a temp-folder outside of nextcloud as output destination for ffmpeg command)
  • “upload” the converted videos with cURL to your nextcloud
  • move the original videos to another folder of your nextcloud with cURL (to not let them be converted again when script runs again)
1 Like

Thanks Bernie_O and Woschtfinger!

Bernie_O’s hint will perfectly work for me. I forgot to mention, that I’ve enabled encryption for my nextcloud instance. So any pure file system access “outside of Nextcloud” would result in senseless (encrypted) data, whereas a webdav access works perfectly fine, just checked with a KDE/Dolphin webdav share access.

Esp. the nextcloud doc link about curl is very helpful, thank you!

Let me see if I can “wrap” the ffmpeg calls in a makefile, called by a cron script…

Guten Rutsch, woschtfinger, and all the best for 2018, Bernie_O

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.