Issue running on Docker
sjakati98 opened this issue · 2 comments
Issue
Running video.Read()
on Docker seems to run into the issue where the following loop ends after the first iteration:
for frameCount := 0; video.Read(); frameCount++ {
// ... do some logic on frames
}
Not sure where I am going wrong, running the binary on macOS seems to give me no issues, but running on both alpine:latest
and ubuntu:latest
gives me this issue.
Things I tried
- Using different base images
- Copying video file directly into the container
What my docker image looks like
# Use the official Golang image as the base image
FROM golang:1.18 AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the Go module files
COPY go.mod go.sum ./
# Download and cache the Go module dependencies
RUN go mod download
# Copy the source code into the container
COPY . .
# Build the Go application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o vidstreamsplit .
# Use a minimal Alpine image as the base image for the final image
FROM ubuntu:latest
# Install FFmpeg and AWS CLI
RUN apt update && apt install -y ffmpeg
# Set the working directory inside the container
WORKDIR /app
# Copy the built binary from the previous stage
COPY --from=builder /app/vidstreamsplit .
# Make the binary executable
RUN chmod +x vidstreamsplit
# Copy the scripts directory into the container
COPY scripts ./scripts
# Make all the scripts in the scripts package executable
RUN chmod +x scripts/*.sh
Please let me know if you've run into this issue before. Happy to take a look and try to submit a change if you could point me in the write direction.
If the only issue is that the loop ends after the first iteration, then there most likely is an error in the init
function, and the error is probably coming from the exec.Command
initialization. My guess is that ffmpeg
can't open the file even though you've downloaded it (might be an issue with docker) which would result in the behavior you've described. I'd recommend debugging and checking what the return value of init()
is inside the Read()
function. If the error is at all related to the ffmpeg
process then you'll know that it can't open the video file you've given it.
@sjakati98 Hi! Any luck finding out what the problem is? I'm facing the same problem.