Skip to content

Commit

Permalink
add another quote command
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukas Wingerberg committed Oct 22, 2024
1 parent 399ddc3 commit ac24a67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
ARG PROTOC_VERSION=28.2
FROM debian:bookworm-slim AS builder
ARG PROTOC_VERSION

# Setzen der Arbeitsverzeichnis im Container
WORKDIR /app
Expand All @@ -7,9 +9,11 @@ WORKDIR /app
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
protobuf-compiler \
&& rm -rf /var/lib/apt/lists/*

RUN curl -LO https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip && \
unzip protoc-${PROTOC_VERSION}-linux-x86_64.zip -d /app/.local

# Upgrade pip
RUN pip3 install --break-system-packages --upgrade pip

Expand All @@ -18,7 +22,7 @@ COPY proto/ffmpeg.proto .

# Kompilieren der .proto-Datei für Python
RUN python3 -m pip install --break-system-packages grpcio grpcio-tools
RUN python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ffmpeg.proto
RUN PATH="$PATH:$HOME/app/.local/bin" python3 -m grpc_tools.protoc -I. --python_out=. --grpc_python_out=. ffmpeg.proto

# Final stage
FROM debian:bookworm-slim
Expand Down
13 changes: 12 additions & 1 deletion client/grpc-ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,21 @@ def handle_quoted_arguments(command_args):
if ' ' in vf_arg or ',' in vf_arg or ':' in vf_arg:
vf_arg = f'"{vf_arg}"'

# Reassemble the -filter_complex argument
# Reassemble the -vf argument
rffmpeg_command.append(arg)
rffmpeg_command.append(vf_arg)
i += 2 # Skip the next argument as it's part of -vf
elif arg == '-hls_segment_filename' and i + 1 < len(command_args):
hls_segment_filename_arg = command_args[i + 1]

# Quote the filter complex string if it contains spaces, commas, or colons
if ' ' in hls_segment_filename_arg or ',' in hls_segment_filename_arg or ':' in hls_segment_filename_arg:
hls_segment_filename_arg = f'"{hls_segment_filename_arg}"'

# Reassemble the -hls_segment_filename argument
rffmpeg_command.append(arg)
rffmpeg_command.append(hls_segment_filename_arg)
i += 2 # Skip the next argument as it's part of -hls_segment_filename
# Append any other arguments as is
else:
rffmpeg_command.append(arg)
Expand Down

0 comments on commit ac24a67

Please sign in to comment.