Use shutil.which to discover ffmpeg.
How did I miss such an easy solution for so long?? So glad I did not go the env var route.
This commit is contained in:
parent
84599b44f7
commit
e186653e36
2 changed files with 29 additions and 9 deletions
|
@ -55,7 +55,6 @@ If you are interested in helping, please raise an issue before making any pull r
|
||||||
- Add a `Photo.merge` to combine duplicate entries.
|
- Add a `Photo.merge` to combine duplicate entries.
|
||||||
- Generate thumbnails for vector files without falling victim to bombs.
|
- Generate thumbnails for vector files without falling victim to bombs.
|
||||||
- Allow photos to have nonstandard, orderby-able properties like "release year". How?
|
- Allow photos to have nonstandard, orderby-able properties like "release year". How?
|
||||||
- Make the FFmpeg path configurable. Some kind of global config? Or part of the database config file? It's not like every photodb needs a separate one. I don't like using environment variables for application config but maybe it would be appropriate here.
|
|
||||||
- Improve the appearance of album page. Too many section headers and the "Create album" interface should allow giving a title immediately.
|
- Improve the appearance of album page. Too many section headers and the "Create album" interface should allow giving a title immediately.
|
||||||
- When users have '%' or '#', etc. in their username, it is difficult to access their /user/ URL. I would prefer to fix it without simply blacklisting those characters.
|
- When users have '%' or '#', etc. in their username, it is difficult to access their /user/ URL. I would prefer to fix it without simply blacklisting those characters.
|
||||||
- Currently, the Jinja templates are having a tangling influence on the backend objects, because Jinja cannot import my other modules like bytestring, but it can access the methods of the objects I pass into the template. As a result, the objects have excess helper methods. Consider making them into Jinja filters instead. Which is also kind of ugly but will move that pollution out of the backend at least.
|
- Currently, the Jinja templates are having a tangling influence on the backend objects, because Jinja cannot import my other modules like bytestring, but it can access the methods of the objects I pass into the template. As a result, the objects have excess helper methods. Consider making them into Jinja filters instead. Which is also kind of ugly but will move that pollution out of the backend at least.
|
||||||
|
|
|
@ -4,18 +4,39 @@ This file provides data and objects that do not change throughout the runtime.
|
||||||
|
|
||||||
import converter
|
import converter
|
||||||
import logging
|
import logging
|
||||||
|
import shutil
|
||||||
import string
|
import string
|
||||||
import traceback
|
import traceback
|
||||||
|
import warnings
|
||||||
|
|
||||||
try:
|
FFMPEG_NOT_FOUND = '''
|
||||||
|
ffmpeg or ffprobe not found.
|
||||||
|
Add them to your PATH or use symlinks such that they appear in:
|
||||||
|
Linux: which ffmpeg & which ffprobe
|
||||||
|
Windows: where ffmpeg & where ffprobe
|
||||||
|
'''
|
||||||
|
|
||||||
|
def _load_ffmpeg():
|
||||||
|
ffmpeg_path = shutil.which('ffmpeg')
|
||||||
|
ffprobe_path = shutil.which('ffprobe')
|
||||||
|
|
||||||
|
if (not ffmpeg_path) or (not ffprobe_path):
|
||||||
|
warnings.warn(FFMPEG_NOT_FOUND)
|
||||||
|
return None
|
||||||
|
|
||||||
|
try:
|
||||||
ffmpeg = converter.Converter(
|
ffmpeg = converter.Converter(
|
||||||
ffmpeg_path='D:\\software\\ffmpeg\\bin\\ffmpeg.exe',
|
ffmpeg_path=ffmpeg_path,
|
||||||
ffprobe_path='D:\\software\\ffmpeg\\bin\\ffprobe.exe',
|
ffprobe_path=ffprobe_path,
|
||||||
)
|
)
|
||||||
except converter.ffmpeg.FFMpegError:
|
except converter.ffmpeg.FFMpegError:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
ffmpeg = None
|
ffmpeg = None
|
||||||
|
|
||||||
|
return ffmpeg
|
||||||
|
|
||||||
|
ffmpeg = _load_ffmpeg()
|
||||||
|
|
||||||
FILENAME_BADCHARS = '\\/:*?<>|"'
|
FILENAME_BADCHARS = '\\/:*?<>|"'
|
||||||
|
|
||||||
# Note: Setting user_version pragma in init sequence is safe because it only
|
# Note: Setting user_version pragma in init sequence is safe because it only
|
||||||
|
|
Loading…
Reference in a new issue