Skip to content

Commit

Permalink
processmedia2 stub for export_media.py
Browse files Browse the repository at this point in the history
  • Loading branch information
calaldees committed Mar 14, 2022
1 parent ece17c8 commit dba281a
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
12 changes: 11 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ services:
- logs:/logs
- ${PATH_HOST_source}:/media/source:ro # The Community interface writes to this location, not too happy about this. Will discuss this with content creators.
- ${PATH_HOST_meta}:/media/meta:ro
#- ${PWD}/website:/app:ro # for local development

## for local development
## docker-compose run --rm --entrypoint /bin/bash --service-ports website
# - ${PWD}/website:/app:ro
# ports:
# - 6543:6543
# #command: pserve ${PATH_CONFIG}/development.ini
# healthcheck:
# interval: 0m # TODO: disbale healthcheck


mosquitto:
image: karakara/mosquitto
Expand Down Expand Up @@ -95,6 +104,7 @@ services:
- ${PATH_HOST_source}:/media/source:ro
- ${PATH_HOST_meta}:/media/meta:rw
- ${PATH_HOST_processed}:/media/processed:rw
- website_static:/static:rw

# Force import
#docker-compose exec processmedia2 /bin/bash
Expand Down
2 changes: 2 additions & 0 deletions processmedia2/config.docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"path_meta": "/media/meta",
"path_processed": "/media/processed",

"path_static": "/static",

"api_host": "website:6543",

"process_order_function": "random",
Expand Down
2 changes: 1 addition & 1 deletion processmedia2/encode_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def _encode_preview_video_from_meta(self, m):
return True

def _encode_images_from_meta(self, m, num_images=4):
target_files = tuple(
target_files = tuple( ## TODO: replace this with enumeration - we need an arbitrary number of images of different formts (jpg, av1, jp2, etc)
m.processed_files['image{}'.format(index+1)]
for index in range(num_images)
)
Expand Down
23 changes: 23 additions & 0 deletions processmedia2/export_media.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
New static track format
"""

# from config.docker.json - `path_static`
#output to `tracks.json`` ?
test = {
'BASE64_HASH': {
'source_filename': '', # For debugging
'attachments': [
{
'url': 'PATH/BASE64_HASH.mp4',
'use': 'preview',
'mime': 'video/mp4',
},
## if you want consistant image order then sort by url-string to get consistent order
],
'duration': 300.0,
'srt': 'SRT_TEXT',
'tags': 'TAG_TEXT', # provide js for translating tag.txt into parent/childs - this is reasonably trivial
}
}

1 change: 1 addition & 0 deletions processmedia2/processmedia2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function run() {
python3 scan_media.py --config ${KARAKARA_PROCESSMEDIA2_CONFIG} && \
python3 encode_media.py --config ${KARAKARA_PROCESSMEDIA2_CONFIG} && \
python3 import_media.py --config ${KARAKARA_PROCESSMEDIA2_CONFIG} --force && \
python3 export_media.py --config ${KARAKARA_PROCESSMEDIA2_CONFIG} && \
if [ "${KARAKARA_PROCESSMEDIA2_CLEANUP:-false}" == "true" ]; then
python3 cleanup_media.py --config ${KARAKARA_PROCESSMEDIA2_CONFIG}
fi
Expand Down
6 changes: 5 additions & 1 deletion processmedia2/processmedia_libs/processed_files_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

class ProcessedFilesManager(object):
FILE_TYPES = (
ProcessedFileType('media', 'image1', 'image', 'jpg', ''),
ProcessedFileType('media', 'image1', 'image', 'jpg', ''), ## TODO: refactor to 'image'+'enumeration_number'. Remote ext and replace with mime_type
ProcessedFileType('media', 'image2', 'image', 'jpg', ''),
ProcessedFileType('media', 'image3', 'image', 'jpg', ''),
ProcessedFileType('media', 'image4', 'image', 'jpg', ''),
Expand Down Expand Up @@ -99,3 +99,7 @@ def gen_string_hash(hashs):
hasher.update(''.join(sorted(hashs)).encode('utf-8'))
hash_str = hasher.hexdigest()
return hash_str
# TODO: use base62 string rather than hex
# re.sub('[+/=]','_', base64.b64encode(hashlib.sha256().digest()).decode('utf8'))[:11]
# This is filesystem safe, but not bi-directional as some data is lost
# pow(62, 11) == 52036560683837093888 # this is 4 times more-ish than int64 pow(2,64)

0 comments on commit dba281a

Please sign in to comment.