发布请求不处理上传

时间:2018-02-21 01:26:09

标签: ruby-on-rails ffmpeg upload ruby-on-rails-5 elastic-beanstalk

我无法将大型视频上传到弹性beanstalk rails实例。当我上传小视频时,我的应用程序运行正常。但是,在上传大型视频时,帖子请求似乎不会处理视频。日志的输出仅返回:

I, [2018-02-13T19:47:11.947391 #20262]  INFO -- : [7f5d6846-c9b4-473d-b1fe-1e94056a6474] Started POST "/movies" for 108.71.214.220 at 2018-02-13 19:47:11 +0000

帖子请求应如下所示:

I, [2018-02-20T03:01:00.228579 #24802]  INFO -- : [174f98cf-d26f-4cc9-987f-021987ead17c] Started POST "/movies" for 108.71.214.220 at 2018-02-20 03:01:00 +0000
I, [2018-02-20T03:01:06.584806 #24802]  INFO -- : [174f98cf-d26f-4cc9-987f-021987ead17c] [paperclip] saving /movies/videos/000/000/003/original/SampleVideo_640x360_30mb.flv
D, [2018-02-20T03:01:09.390598 #24802] DEBUG -- : [174f98cf-d26f-4cc9-987f-021987ead17c]   ^[[1m^[[35m (0.9ms)^[[0m  ^[[1m^[[35mCOMMIT^[[0m
I, [2018-02-20T03:01:09.392579 #24802]  INFO -- : [174f98cf-d26f-4cc9-987f-021987ead17c] [ActiveJob] Enqueued DelayedPaperclip::ProcessJob (Job ID: 01373ae4-89cb-486c-9d44-eaa74d9211c5) to Async(paperclip) with arguments: "Movie", 3, "video"
I, [2018-02-20T03:01:09.392707 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] Performing DelayedPaperclip::ProcessJob (Job ID: 01373ae4-89cb-486c-9d44-eaa74d9211c5) from Async(paperclip) with arguments: "Movie", 3, "video"
I, [2018-02-20T03:01:09.396173 #24802]  INFO -- : [174f98cf-d26f-4cc9-987f-021987ead17c] Completed 201 Created in 3046ms (Views: 0.4ms | ActiveRecord: 4.5ms)
D, [2018-02-20T03:01:09.409028 #24802] DEBUG -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5]   ^[[1m^[[36mMovie Load (0.4ms)^[[0m  ^[[1m^[[34mSELECT  "movies".* FROM "movies" WHERE "movies"."id" = $1 LIMIT $2^[[0m  [["id", 3], ["LIMIT", 1]]
I, [2018-02-20T03:01:09.409801 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] copying /movies/videos/000/000/003/original/SampleVideo_640x360_30mb.flv to local file /tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv
I, [2018-02-20T03:01:12.383537 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] Command :: file -b --mime '/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1xdygtx.flv'
I, [2018-02-20T03:01:12.387977 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
I, [2018-02-20T03:01:12.389194 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
I, [2018-02-20T03:01:12.433230 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Found ["ffmpeg"], using: Ffmpeg
I, [2018-02-20T03:01:12.433323 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: if command -v avprobe 2>/dev/null; then echo "true"; else echo "false"; fi
I, [2018-02-20T03:01:12.434721 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
I, [2018-02-20T03:01:12.436039 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Found ["ffmpeg"], using: Ffmpeg
I, [2018-02-20T03:01:12.436099 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: ffmpeg -i "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv" 2>&1
I, [2018-02-20T03:01:12.658521 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] [transcoder] Transocding supported file /tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv
I, [2018-02-20T03:01:12.658618 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter ["acodec", "aac"]
I, [2018-02-20T03:01:12.658657 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter ["strict", "experimental"]
I, [2018-02-20T03:01:12.658704 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter [:s, "640x480"]
I, [2018-02-20T03:01:12.658759 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: ffmpeg -i "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv" -acodec aac -strict experimental -s 640x480 -y "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl20180220-24802-1hl2kvo.mp4"
I, [2018-02-20T03:01:12.434721 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: if command -v ffmpeg 2>/dev/null; then echo "true"; else echo "false"; fi
I, [2018-02-20T03:01:12.436039 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Found ["ffmpeg"], using: Ffmpeg
I, [2018-02-20T03:01:12.436099 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: ffmpeg -i "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv" 2>&1
I, [2018-02-20T03:01:12.658521 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] [transcoder] Transocding supported file /tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv
I, [2018-02-20T03:01:12.658618 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter ["acodec", "aac"]
I, [2018-02-20T03:01:12.658657 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter ["strict", "experimental"]
I, [2018-02-20T03:01:12.658704 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Adding output parameter [:s, "640x480"]
I, [2018-02-20T03:01:12.658759 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [AV] Running command: ffmpeg -i "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl.flv" -acodec aac -strict experimental -s 640x480 -y "/tmp/1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl20180220-24802-1hl2kvo.mp4"
I, [2018-02-20T03:02:03.194536 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] [transcoder] Successfully transcoded 1198ad681cf1d8dabf71cd056e42731f20180220-24802-1mzblvl to #<File:0x000055aaf9235330>
I, [2018-02-20T03:02:03.227408 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] saving /movies/videos/000/000/003/original/SampleVideo_640x360_30mb.flv
I, [2018-02-20T03:02:06.164693 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] [paperclip] saving /movies/videos/000/000/003/medium/SampleVideo_640x360_30mb.mp4
D, [2018-02-20T03:02:08.467048 #24802] DEBUG -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5]   ^[[1m^[[35m (0.2ms)^[[0m  ^[[1m^[[35mBEGIN^[[0m
D, [2018-02-20T03:02:08.469704 #24802] DEBUG -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5]   ^[[1m^[[36mMovie Exists (0.4ms)^[[0m  ^[[1m^[[34mSELECT  1 AS one FROM "movies" WHERE LOWER("movies"."title") = LOWER($1) AND ("movies"."id" != $2) LIMIT $3^[[0m  [["title", "test"], ["id", 3], ["LIMIT", 1]]
D, [2018-02-20T03:02:08.471260 #24802] DEBUG -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5]   ^[[1m^[[35mSQL (0.3ms)^[[0m  ^[[1m^[[33mUPDATE "movies" SET "video_file_name" = $1, "video_updated_at" = $2, "updated_at" = $3 WHERE "movies"."id" = $4^[[0m  [["video_file_name", "SampleVideo_640x360_30mb.flv"], ["video_updated_at", "2018-02-20 03:01:12.308214"], ["updated_at", "2018-02-20 03:02:08.470020"], ["id", 3]]
D, [2018-02-20T03:02:08.472524 #24802] DEBUG -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5]   ^[[1m^[[35m (0.9ms)^[[0m  ^[[1m^[[35mCOMMIT^[[0m
I, [2018-02-20T03:02:08.472777 #24802]  INFO -- : [ActiveJob] [DelayedPaperclip::ProcessJob] [01373ae4-89cb-486c-9d44-eaa74d9211c5] Performed DelayedPaperclip::ProcessJob (Job ID: 01373ae4-89cb-486c-9d44-eaa74d9211c5) from Async(paperclip) in 59079.31ms

在初始发布请求之后,应该有一个语句显示请求的处理和ffmpeg的处理。你可以看到我没有得到这些。甚至没有完成声明。 任何帮助将不胜感激。

这是我的创建动作的副本

def create      
    movie = Movie.new(movie_params)

    if movie.save
        Resque.enqueue(TranscodeVideo, movie.id)
        render json: movie, status: 201
    else
        render json: { errors: movie.errors }, status: 422
    end
end

这是工人的副本

class TranscodeVideo
    @queue = :movie_queue

    def self.perform(movie_id)
                    movie = Movie.find(movie_id)

                    Delayed::Worker.new.work_off
                    movie.reload
    end
end

1 个答案:

答案 0 :(得分:1)

似乎服务器无法在正文中处理如此大的请求数据,因此您需要在http {}

中修改nginx上的服务器设置

client_max_body_size 50M;

用这个,它可以处理50 MB。它可以相应地改变。