Compare commits
5 Commits
81a416cb83
...
v1.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
| 4aaff495e1 | |||
| be12f5220b | |||
| 0ceed7fbc1 | |||
| ddc78cccf1 | |||
| 83461eda7b |
@@ -20,11 +20,11 @@ jobs:
|
|||||||
id: get_version
|
id: get_version
|
||||||
run: echo "VERSION=${{ github.head_ref }}" >> $GITHUB_OUTPUT
|
run: echo "VERSION=${{ github.head_ref }}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# - name: Generate Changelog
|
- name: Generate Changelog
|
||||||
# id: changelog
|
id: changelog
|
||||||
# uses: https://github.com/metcalfc/changelog-generator@v4.6.2
|
uses: https://github.com/metcalfc/changelog-generator@v4.6.2
|
||||||
# with:
|
with:
|
||||||
# myToken: ${{ secrets.GITHUB_TOKEN }}
|
myToken: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
run: |
|
run: |
|
||||||
@@ -41,6 +41,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
tag_name: ${{ steps.get_version.outputs.VERSION }}
|
||||||
name: ${{ steps.get_version.outputs.VERSION }}
|
name: ${{ steps.get_version.outputs.VERSION }}
|
||||||
# body: ${{ steps.changelog.outputs.changelog }}
|
body: ${{ steps.changelog.outputs.changelog }}
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
+1
-1
@@ -3,7 +3,7 @@ LABEL org.opencontainers.image.vendor="JDB-NET"
|
|||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY . /app
|
COPY . /app
|
||||||
ARG VERSION=dev
|
ARG VERSION=dev
|
||||||
ENV APP_VERSION=${VERSION}
|
ENV VERSION=${VERSION}
|
||||||
RUN pip install -r requirements.txt
|
RUN pip install -r requirements.txt
|
||||||
RUN apt-get update && apt-get install -y curl ffmpeg procps
|
RUN apt-get update && apt-get install -y curl ffmpeg procps
|
||||||
RUN rm -rf /var/lib/apt/lists/*
|
RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|||||||
@@ -552,13 +552,11 @@ class AudioEncoder:
|
|||||||
def process_file(encoder_type, file_path, encoder):
|
def process_file(encoder_type, file_path, encoder):
|
||||||
"""Process a single file"""
|
"""Process a single file"""
|
||||||
global current_jobs
|
global current_jobs
|
||||||
if not ENCODING_ENABLED:
|
|
||||||
logger.info(f"Encoding is disabled. Skipping {file_path}")
|
|
||||||
db_manager.remove_from_queue(encoder_type, file_path)
|
|
||||||
with job_lock:
|
|
||||||
current_jobs[encoder_type] = None
|
|
||||||
return
|
|
||||||
try:
|
try:
|
||||||
|
logger.info(f"Starting to process {file_path} for {encoder_type}")
|
||||||
|
if not ENCODING_ENABLED:
|
||||||
|
logger.info(f"Encoding is disabled. Skipping {file_path}")
|
||||||
|
return
|
||||||
if not os.path.exists(file_path):
|
if not os.path.exists(file_path):
|
||||||
logger.warning(f"File {file_path} no longer exists, skipping")
|
logger.warning(f"File {file_path} no longer exists, skipping")
|
||||||
return
|
return
|
||||||
@@ -724,16 +722,17 @@ def process_file(encoder_type, file_path, encoder):
|
|||||||
if os.path.exists(temp_input):
|
if os.path.exists(temp_input):
|
||||||
os.remove(temp_input)
|
os.remove(temp_input)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error processing {file_path}: {e}")
|
logger.error(f"Error processing {file_path}: {e}", exc_info=True)
|
||||||
try:
|
try:
|
||||||
|
file_size = os.path.getsize(file_path) if os.path.exists(file_path) else 0
|
||||||
db_manager.add_job_report(
|
db_manager.add_job_report(
|
||||||
encoder_type, file_path, os.path.getsize(file_path), 0,
|
encoder_type, file_path, file_size, 0,
|
||||||
os.path.splitext(file_path)[1], '', 'failed',
|
os.path.splitext(file_path)[1], '', 'failed',
|
||||||
error_message=str(e),
|
error_message=str(e),
|
||||||
target_resolution=target_resolution
|
target_resolution=target_resolution if 'target_resolution' in locals() else None
|
||||||
)
|
)
|
||||||
except:
|
except Exception as report_error:
|
||||||
pass
|
logger.error(f"Failed to add job report: {report_error}", exc_info=True)
|
||||||
finally:
|
finally:
|
||||||
# Remove from queue after processing is complete
|
# Remove from queue after processing is complete
|
||||||
db_manager.remove_from_queue(encoder_type, file_path)
|
db_manager.remove_from_queue(encoder_type, file_path)
|
||||||
@@ -743,23 +742,28 @@ def process_file(encoder_type, file_path, encoder):
|
|||||||
def worker_thread(encoder_type):
|
def worker_thread(encoder_type):
|
||||||
"""Worker thread for processing jobs"""
|
"""Worker thread for processing jobs"""
|
||||||
encoder = VideoEncoder() if encoder_type == 'video' else AudioEncoder()
|
encoder = VideoEncoder() if encoder_type == 'video' else AudioEncoder()
|
||||||
|
logger.info(f"Started {encoder_type} worker thread")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
with job_lock:
|
with job_lock:
|
||||||
queue = db_manager.get_queue(encoder_type, limit=1)
|
queue = db_manager.get_queue(encoder_type, limit=1)
|
||||||
if queue and not current_jobs[encoder_type]:
|
if queue and not current_jobs[encoder_type]:
|
||||||
file_path = queue[0]
|
file_path = queue[0]
|
||||||
|
logger.debug(f"{encoder_type} queue item: {file_path}")
|
||||||
# Check file exists before processing
|
# Check file exists before processing
|
||||||
if os.path.exists(file_path):
|
if os.path.exists(file_path):
|
||||||
current_jobs[encoder_type] = {
|
current_jobs[encoder_type] = {
|
||||||
'file_path': file_path,
|
'file_path': file_path,
|
||||||
'start_time': time.time()
|
'start_time': time.time()
|
||||||
}
|
}
|
||||||
|
logger.info(f"Starting job for {file_path}")
|
||||||
# Do NOT remove from queue here anymore
|
# Do NOT remove from queue here anymore
|
||||||
else:
|
else:
|
||||||
# Remove from queue if file does not exist
|
# Remove from queue if file does not exist
|
||||||
|
logger.warning(f"File {file_path} does not exist, removing from queue")
|
||||||
db_manager.remove_from_queue(encoder_type, file_path)
|
db_manager.remove_from_queue(encoder_type, file_path)
|
||||||
if current_jobs[encoder_type]:
|
if current_jobs[encoder_type]:
|
||||||
|
logger.debug(f"Processing {current_jobs[encoder_type]['file_path']}")
|
||||||
process_file(encoder_type, current_jobs[encoder_type]['file_path'], encoder)
|
process_file(encoder_type, current_jobs[encoder_type]['file_path'], encoder)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
@@ -898,6 +902,7 @@ def add_config():
|
|||||||
encoder_type = request.form.get('encoder_type')
|
encoder_type = request.form.get('encoder_type')
|
||||||
watch_folder = request.form.get('watch_folder')
|
watch_folder = request.form.get('watch_folder')
|
||||||
temp_dir = request.form.get('temp_dir') or '/temp'
|
temp_dir = request.form.get('temp_dir') or '/temp'
|
||||||
|
target_resolution = request.form.get('target_resolution') or None
|
||||||
ffmpeg_flags = None
|
ffmpeg_flags = None
|
||||||
if encoder_type == 'video':
|
if encoder_type == 'video':
|
||||||
crf = request.form.get('crf', '24')
|
crf = request.form.get('crf', '24')
|
||||||
@@ -907,7 +912,7 @@ def add_config():
|
|||||||
audio_bitrate = request.form.get('audio_bitrate', '320k')
|
audio_bitrate = request.form.get('audio_bitrate', '320k')
|
||||||
ffmpeg_flags = f'-b:a {audio_bitrate}'
|
ffmpeg_flags = f'-b:a {audio_bitrate}'
|
||||||
if encoder_type in ['video', 'audio'] and watch_folder:
|
if encoder_type in ['video', 'audio'] and watch_folder:
|
||||||
db_manager.add_config(encoder_type, watch_folder, ffmpeg_flags, temp_dir)
|
db_manager.add_config(encoder_type, watch_folder, ffmpeg_flags, temp_dir, target_resolution)
|
||||||
return redirect(url_for('config'))
|
return redirect(url_for('config'))
|
||||||
|
|
||||||
@app.route('/edit_config/<int:config_id>', methods=['POST'])
|
@app.route('/edit_config/<int:config_id>', methods=['POST'])
|
||||||
|
|||||||
Reference in New Issue
Block a user