Videos: Option to automatically transcode videos upfront #920

Open
opened 2026-02-20 00:01:51 -05:00 by deekerman · 10 comments
Owner

Originally created by @jkgeyti on GitHub (May 3, 2021).

Originally assigned to: @lastzero on GitHub.

Problem: mp4 videos are never transcoded, but lots of MP4 containers use unsupported audio codecs, or are too big to comfortably stream through a browser. Video transcoding is an contentious subject, in particular when it comes to caching [ https://github.com/photoprism/photoprism/issues/1070 ] , and it's not clear what the most appropriate strategy for determining when to convert and store a transcoded video is.

A simpler (intermediate?) approach, could be to introduce a config flag to enable always transcoding videos when requested through the API.

From a UX perspective, this doesn't really change anything. Unlike cached JPEGs that enable fast navigation through libraries, videos are inherently slow to absorb, and photoprism already focuses on a simple flow, where we always serve the full video after clicking a thumbnail. As such, it should make no difference to the end user whether a cached or transcoded video stream is delivered.

The only downside, is when transcoding happens at a lower than 1.0x rate, and hence cause permanent stuttering of videos, whereas caching would only cause a video to stutter the first time it's played back.

If this could be enabled, I'd be happy to extent the documentation with instructions on how to enable hardware-encoding on Intel CPUs (with integrated GPUs).

Originally created by @jkgeyti on GitHub (May 3, 2021). Originally assigned to: @lastzero on GitHub. Problem: mp4 videos are never transcoded, but lots of MP4 containers use unsupported audio codecs, or are too big to comfortably stream through a browser. Video transcoding is an contentious subject, in particular when it comes to caching [ https://github.com/photoprism/photoprism/issues/1070 ] , and it's not clear what the most appropriate strategy for determining when to convert and store a transcoded video is. A simpler (intermediate?) approach, could be to introduce a config flag to **enable always transcoding videos when requested through the API**. From a UX perspective, this doesn't really change anything. Unlike cached JPEGs that enable fast navigation through libraries, videos are inherently slow to absorb, and photoprism already focuses on a simple flow, where we always serve the full video after clicking a thumbnail. As such, it should make no difference to the end user whether a cached or transcoded video stream is delivered. The only downside, is when transcoding happens at a lower than 1.0x rate, and hence cause permanent stuttering of videos, whereas caching would only cause a video to stutter the first time it's played back. If this could be enabled, I'd be happy to extent the [documentation](https://docs.photoprism.org/getting-started/advanced/transcoding/) with instructions on how to enable hardware-encoding on Intel CPUs (with integrated GPUs).
Author
Owner

@lastzero commented on GitHub (May 4, 2021):

Makes sense. There are many other ideas waiting to be implemented, so we can't do it right now. Once funding improves, we can grow our team and deliver feature requests like this faster.

@lastzero commented on GitHub (May 4, 2021): Makes sense. There are many other ideas waiting to be implemented, so we can't do it right now. Once [funding](https://docs.photoprism.org/funding/) improves, we can grow our team and deliver feature requests like this faster.
Author
Owner

@lastzero commented on GitHub (May 23, 2021):

Our recently published example config shows how to run a background job for this:

https://dl.photoprism.org/docker/scheduler/

This job in jobs.ini will run photoprism convert once a day to make sure files are transcoded / converted as needed (change this to run the job more often, depending on your requirements):

[job-exec "photoprism convert"]
schedule = @daily
container = photoprism
command = photoprism convert

Does this work for you? I'd rather not convert videos while scanning for new / changed files as this may have a huge performance impact.

@lastzero commented on GitHub (May 23, 2021): Our recently published example config shows how to run a background job for this: https://dl.photoprism.org/docker/scheduler/ This job in `jobs.ini` will run `photoprism convert` once a day to make sure files are transcoded / converted as needed (change this to run the job more often, depending on your requirements): ``` [job-exec "photoprism convert"] schedule = @daily container = photoprism command = photoprism convert ``` Does this work for you? I'd rather not convert videos while scanning for new / changed files as this may have a huge performance impact.
Author
Owner

@wormvortex commented on GitHub (Jul 6, 2021):

where would you put the jobs.ini file and what do you need to do to get it to run?

@wormvortex commented on GitHub (Jul 6, 2021): where would you put the jobs.ini file and what do you need to do to get it to run?
Author
Owner

@lastzero commented on GitHub (Jul 6, 2021):

See example:

https://dl.photoprism.org/docker/scheduler/

@lastzero commented on GitHub (Jul 6, 2021): See example: https://dl.photoprism.org/docker/scheduler/
Author
Owner

@wormvortex commented on GitHub (Jul 6, 2021):

I'm still not understanding exactly what to do with that jobs.ini file listed?

@wormvortex commented on GitHub (Jul 6, 2021): I'm still not understanding exactly what to do with that jobs.ini file listed?
Author
Owner

@lastzero commented on GitHub (Jul 6, 2021):

Put it next to the docker-compose.yml file, same directory.

@lastzero commented on GitHub (Jul 6, 2021): Put it next to the docker-compose.yml file, same directory.
Author
Owner

@maximecurioni commented on GitHub (Sep 19, 2021):

I wanted to second @jkgeyti's idea. Having a global flag to always transcode videos would be really useful, especially when one has hardware transcoding working.

My camera uses the following codecs:

  • video: h264 (High) (avc1 / 0x31637661)
  • audio: pcm_s16le (sowt / 0x74776F73)

Because these videos are sent in passthrough fashion by Photoprism and Firefox/Chrome don't support the audio codec, I have to manually copy the video link and reopen the file in Safari or VLC to hear the audio. This somewhat hinders my Photoprism experience.

I understand that using photoprism convert is an option for some. I personally do not want to overwrite any of my originals.

@maximecurioni commented on GitHub (Sep 19, 2021): I wanted to second @jkgeyti's idea. Having a global flag to always transcode videos would be really useful, especially when one has hardware transcoding working. My camera uses the following codecs: - video: `h264 (High) (avc1 / 0x31637661)` - audio: `pcm_s16le (sowt / 0x74776F73)` Because these videos are sent in passthrough fashion by Photoprism and Firefox/Chrome don't support the audio codec, I have to manually copy the video link and reopen the file in Safari or VLC to hear the audio. This somewhat hinders my Photoprism experience. I understand that using `photoprism convert` is an option for some. I personally do not want to overwrite any of my originals.
Author
Owner

@lastzero commented on GitHub (Sep 19, 2021):

photoprism convert won't overwrite your originals. PCM is in fact not a supported audio codec for MP4 (at best MOV may be a valid container as it existed before MP4 was standardized). While we can implement a workaround for that, there are lots of existing tools to fix non standard files and convert them to proper MP4. We'll eventually come up with a complete video solution and maybe even live transcoding with variable bitrate depending on your connection speed and hardware - but most likely not this year. Our next goals are facial recognition and batch edit.

@lastzero commented on GitHub (Sep 19, 2021): photoprism convert won't overwrite your originals. PCM is in fact not a supported audio codec for MP4 (at best MOV may be a valid container as it existed before MP4 was standardized). While we can implement a workaround for that, there are lots of existing tools to fix non standard files and convert them to proper MP4. We'll eventually come up with a complete video solution and maybe even live transcoding with variable bitrate depending on your connection speed and hardware - but most likely not this year. Our next goals are facial recognition and batch edit.
Author
Owner

@maximecurioni commented on GitHub (Sep 19, 2021):

Thanks for the quick answer, @lastzero!

Indeed, I should have clarified, my camera uses MOV as the container format for videos.

I appreciate the clarification on photoprism convert. I didn't read the documentation closely enough to understand that sidecar files would be created.

I totally understand your prioritization for the year. Thanks again for the team's amazing work.

@maximecurioni commented on GitHub (Sep 19, 2021): Thanks for the quick answer, @lastzero! Indeed, I should have clarified, my camera uses MOV as the container format for videos. I appreciate the clarification on `photoprism convert`. I didn't read the documentation closely enough to understand that sidecar files would be created. I totally understand your prioritization for the year. Thanks again for the team's amazing work.
Author
Owner

@graciousgrey commented on GitHub (Nov 2, 2021):

Marked as low-priority as the scheduler can be used for this

@graciousgrey commented on GitHub (Nov 2, 2021): Marked as low-priority as the scheduler can be used for this
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/photoprism#920
No description provided.