Initial commit: Jellyfin Black Bar Remover MVP
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import os
|
||||
|
||||
def transcode_video(input_file, output_file, crop_param, hw_accel=False):
|
||||
"""
|
||||
Transcodes the video and applies cropping.
|
||||
crop_param: string in the format "W:H:X:Y"
|
||||
hw_accel: boolean, if true we use hardware acceleration (NVENC as an example)
|
||||
"""
|
||||
cmd = ['ffmpeg', '-y', '-i', input_file]
|
||||
|
||||
# We apply the crop filter
|
||||
vf_param = f'crop={crop_param}'
|
||||
|
||||
if hw_accel:
|
||||
# Example using NVIDIA NVENC.
|
||||
# In a real Jellyfin environment, this would be constructed based on Jellyfin's profile.
|
||||
cmd.extend([
|
||||
'-c:v', 'h264_nvenc',
|
||||
'-preset', 'fast',
|
||||
'-vf', vf_param,
|
||||
'-c:a', 'copy' # Keep audio as is
|
||||
])
|
||||
else:
|
||||
# Software encoding fallback
|
||||
cmd.extend([
|
||||
'-c:v', 'libx264',
|
||||
'-preset', 'fast',
|
||||
'-crf', '23',
|
||||
'-vf', vf_param,
|
||||
'-c:a', 'copy'
|
||||
])
|
||||
|
||||
cmd.append(output_file)
|
||||
|
||||
print(f"Running transcoding command: {' '.join(cmd)}")
|
||||
|
||||
# In a real scenario, this would stream to Jellyfin's output or write to the required segment files.
|
||||
process = subprocess.Popen(cmd)
|
||||
process.wait()
|
||||
|
||||
if process.returncode == 0:
|
||||
print("Transcoding completed successfully.")
|
||||
else:
|
||||
print(f"Transcoding failed with code {process.returncode}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) < 4:
|
||||
print("Usage: python transcode_crop.py <input_file> <output_file> <crop_param>")
|
||||
sys.exit(1)
|
||||
|
||||
input_file = sys.argv[1]
|
||||
output_file = sys.argv[2]
|
||||
crop_param = sys.argv[3]
|
||||
|
||||
transcode_video(input_file, output_file, crop_param, hw_accel=False)
|
||||
Reference in New Issue
Block a user