-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Videos: Add transcoding config options #703
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
Comments
Good news: I've enabled the mutex for rendering videos so that only one video is transcoded at a time. Also make sure you have JSON sidecar files enabled as exiftool is used by PhotoPrism to detect the (supposed) codec. PhotoPrism can't directly decode Video-Metadata yet as that is beyond our (initial) scope... safe to assume we're also going to provide a complete video management solution one day 🥇 |
Thanks @lastzero for the improvement! While I know feature creep is real, I'm glad videos are included, even if their integration is forever minimal. Since the app is providing access to precious memories, it's nice to be able to click to all records of these moments, instead of having to access videos using an entirely different method. I can confirm that only one I'm not familiar enough with the code side of this project, but from the outside it seems that if a block of items loading via endless scroll includes an on-demand transcode, the entire chunk is blocked until it finishes. That means all photos from that batch continue to be gray spinners. I'm sure there are more incremental improvements that can be made on this problem, and I appreciate the swift response! |
I should note, the UI blocking I'm talking about refers to loading thumbnail images. After your update, I can now easily click to see individual photos, and switch to other pages in the app easily, so it's a definite improvement. It's just an issue of not being able to continue browsing thumbnails unless 100% of the live photo videos have been cached. |
I would really like the option to be able to tell photoprism to transcode and cache every live photo and mov video in advance. |
You may sponsor this issue so that we can move it to Upcoming ⏳ on our Roadmap. |
I think |
Here is a workaround to disable video transcoding, by overwriting the path fo
|
It would be great to have feature to cache converted videos/Live Photos during indexing. |
For transcoding, With help of proper graphics hardware, transcoding can be much easier, If grahpics card not available on the server, especially for VPS setup, |
I have an i7-8550U and just mapped the /dev/dri directory into my photoprism docker container, but it doesn't seem to make a difference. |
Extra flags needed to use hardware acceleration, please see Jellyfin's Hardware Acceleration for detailed explanation Also the user runs ffmpeg should be in group video or render. Photoprism construct ffmpeg command here, Changes can be made with help of Example usages of ffmpeg VAAPI or QuickSync
|
|
Thank you. As I understand, to enable hardware video rendering for ffmpeg, I have to change source code. If I change source code, how to make this changes persistent after automated updates to new versions? Maybe I should propose to add feature- to add variable to docker-compose where to specify ffmpeg command line options? |
We'll add more config params as soon as possible... just can't do everything at the same time :) |
This should work with |
Needs more work. We also use ffmpeg to render preview images. |
Anyone willing to sponsor this with a golden label? |
You may also try reducing the bitrate for 4K, Pi might just be too slow for 50M. |
Thanks for the ideas. I’ve tried them and still have others to try. After re-reading through this thread, I see that I’m just running into the same issue @uxusoft had with 4K videos (#703 (comment)). ffmpeg hangs and Photoprism is unable to recover. Seems to be a ffmpeg problem that may eventually get resolved upstream. |
Added one more config option for you - let's leave it at that for now please 👯 |
$ dmesg
|
add
|
@uxusoft CMA is new to me. Looking into it a bit, seems there are some other config options that are needed to enable CMA, and then there are two cma options to be set, a low and a high value. I haven't played with this yet but will see if it makes a difference this weekend.
|
Would one of you like to contribute hardware transcoding docs for our Advanced section in Getting Started? https://docs.photoprism.org/getting-started/advanced/scalability/ |
@uxusoft Could you please share your config.txt and cmdline.txt contents? I don't get cma errors anymore, but I'm still trying to fix this one: It causes ffmpeg to spit out this:
Increasing cma beyond 2048 doesn't seem to take effect; it gets reset to 0. |
@inthreedee I have the same errors:
Sometime transcoding freezes forever. But overall, there is a huge improvement. Nearly all Live photos are transcoding instantly. For the long videos I do converting to mp4 before upload and it is ready to play instantly. config.txt:
cmdline.txt
|
I am happy to contribute. But it seems that maybe that this feature is not ready for production because of memory errors. The problem that it is sometimes hangs with hardware decoding forever and fallback to libx264 does not happen. Maybe we have to wait until ffmpeg stable release that will work without issues. |
Wouldn't mind starting with the docs before ffmpeg / ubuntu managed to fix all remaining bugs, which may be never... might be up to us to build our own fixed version. HEIF converter makes trouble as well. Never ending story. |
Just want to add, video streaming is completely broken for me. Im using a VPS and not a rasberry PI I see the following output but none of my videos play anymofre
Can you clarify, are these changes targeted at Rasberry PI's? Is on the fly transcoding meant to be improved in anyway or can we request to convert files prior to streaming? Right now I see a regression from before where some videos would play but now none play whatsoever. |
@muzzah Hi! |
@muzzah I'm not sure which device you'd need to pass for your setup, but for a RPi, the docker-compose needs:
Your system logs may give you a clue as to which device it's trying to use. Otherwise, if you try running ffmpeg in debug mode separately from Photoprism, it will cycle through all the devices until it finds one compatible with the h264_v4l2m2m encoder, and from that you'd know which device to pass. If you know your hardware supports that codec and you've given the container permission for the correct device, then this looks very much like the issue we've been running into where the FFmpeg process freezes, the fallback to libx264 fails to kick in, and transcoding gets broken. As far as we can tell, it might be an upstream FFmpeg issue. I've yet to have the fallback to libx264 kick in correctly though, so I don't know if that's a problem with the Photoprism fallback code or not. |
Thanks for the info, I will look into it but as mentioned Im not using a RPI but a hosted VPS. Im no ffmpeg expert but I looked into the dev fold er but there are no video device since its headless. So I am not sure I will be able to provide a video device, in this situation should I not bother providing a specific codec and just use the libx264 codec? |
Yes, it sounds like you should stick with the defaults. |
Not sure if I should open a new issue, but is it possible to manually encode a video and tell PhotoPrism to use and stream this video as the transcoded one? The original one is kept alongside as the one going to be downloaded, and this encoded one for playing in the browser. The main thing is that I'm running the container on a Windows machine on a Celeron N3150... The CPU is pretty weak. The iGPU does have Quick Sync, but currently it's not possible to access the GPU from a container on Windows version Docker. That being said, even if I do The workaround I'm thinking is that I can go through all the videos and find HEVC ones or the ones with very high (say 50K) bitrate. Then I encode them on my desktop with ffmpeg and move the original videos outside PhotoPrism library folders. I believe this will allow me to play all my videos, but I will lose the ability to download the original ones if I want to keep the original one locally somehow. |
A MP4 file with H264 video and AAC audio codecs will be playable without transcoding. I used this command to convert my files : |
While we also try to detect the exact codecs, it's best to use .mp4 or .avc as extension for MPEG4 / AVC / AAC files. They don't need transcoding then. We use |
Indeed! I thought high bitrate H264 ones would have been transcoded as well, but it turns out to be just my impatience. At least all the 50Mbps H264 videos can load without any problem other than a few seconds loading time. |
Nice to know the So I converted an HEVC videos to .avc, so I have Is this the intended behavior? I thin it's ok if this is the case. I would just move the original one outside the folder and completely forget about it. But thanks for the replies and also @alexislefebvre. At least this is a good workaround for me before I can switch to a Linux host. |
I don't suppose anyone has got hardware transcoding working on Intel NUCs? I imagine this is too broad of a question as there are lots of different models with lots of different GPUs but wondered if some general advice would work for all (to help others). Cheers! |
@timdonovanuk I suggest to add a new issue or discussion specifically about Intel NUC. A message after a very long thread will easily be missed. |
Anytime I browse the library and hit new live photos taken with an iPhone, I end up with gray squares, spinners, and then many (4-8?)
ffmpeg
processes start up and completely choke my modest PC home server's CPU for 5-15 minutes. Even when uncached thumbnail generation is turned off, processing live photo videos seems to always happen on-demand. This has made a previously satisfactory PhotoPrism instance barely usable.According to @lastzero in Gitter:
Proposal 1 - two new config options
Assuming there are two potential issues with live video transcoding (extra disk space used if up-front, and CPU bottleneck on less powerful servers if generated on the spot), a pair of new config options, along with default the live photo feature to "off", might fit most consistently with the existing options.
PHOTOPRISM_LIVE_PHOTO_TRANSCODE
- decides whether these videos are transcoded at all. If true, converts and caches them during indexing/importing. Default: false (saves disk for those who don't need the live photo feature at all)PHOTOPRISM_LIVE_PHOTO_TRANSCODE_UNCACHE
- if true, transcodes on demand (and either saves them or not? Don't know what's best here). Default: false (saves CPU for those who don't need the feature at all)Setting either to true would enable live photos, depending on whether disk or CPU is more important, while avoiding the performance and disk space issues if left off. Open to any feedback on this idea!
Proposal 2 - live photo transcoding should respect workers option
It seems like the values of the
WORKERS
option didn't affect how manyffmpeg
processes I saw started at once. If it did, I could set it to1
, and my dual-core server may continue to respond to requests even while slowly generating live videos on demand.The text was updated successfully, but these errors were encountered: