ruby-av / paperclip-av-transcoder

Audio/Video Transcoder for Paperclip using FFMPEG/Avconv
MIT License
135 stars 83 forks source link

FFMPEG hangs/stalls when converting large files #50

Closed passabilities closed 7 years ago

passabilities commented 7 years ago

So in conjunction I am running Delayed Paperclip to process large files in the background (Not sure if that plays a big role). Couple things:

1) I cannot find anywhere in the source where the command ffmpeg is called. All I really want to do is save the output of ffmpeg to see if there any errors that I do not know about.

2) Large videos always seem to get hung up at a certain point: (the first file is being converted from the second file, and the third file is being converted from the fourth file)
<br />v2@web1 ~/divshare-v2 $ ls -alh /tmp <br />-rw------- 1 v2 v2 70M Sep 10 00:01 2158940a8739e7219125179e0d1528c120160909-14061-8dqfx020160909-14061-egeyeq.mp4 <br />-rw------- 1 v2 v2 515M Sep 9 23:57 2158940a8739e7219125179e0d1528c120160909-14061-8dqfx0.mp4 <br />-rw------- 1 v2 v2 145M Sep 9 23:33 76ba144beb8a14b6cf542225ef885a7c20160909-12733-1ui03vo20160909-12733-y7ywn.mp4 <br />-rw------- 1 v2 v2 604M Sep 9 23:27 76ba144beb8a14b6cf542225ef885a7c20160909-12733-1ui03vo.mp4 <br />
I have tried uploading a couple times and with different files. Always gets caught around the same point. However everything works perfectly when smaller videos (~100-200M).

This is the command being ran:
<br />v2@web1 ~/divshare-v2 $ ps ux | grep ffmpeg <br />USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND <br />v2 14588 26.4 2.9 849840 240524 ? Sl Sep09 12:00 ffmpeg -i /tmp/2158940a8739e7219125179e0d1528c120160909-14061-8dqfx0.mp4 -acodec aac -strict experimental -vcodec libx264 -vb 1000k -profile:v baseline -vf scale=-2:480 -acodec aac -ab 128k -preset slow -threads 0 -movflags faststart -y /tmp/2158940a8739e7219125179e0d1528c120160909-14061-8dqfx020160909-14061-egeyeq.mp4 <br />

Any sort of help debugging this would be awesome.

NOTE: I copied the above command and manually ran the command so that I could see some logs from ffmpeg, and worked seamlessly.

kilink commented 7 years ago

How did you resolve the hanging issue? I am seeing the same problem. My suspicion is that it is a deadlock, because when I strace the hung ffmpeg process, it's blocked writing to stderr.

kilink commented 7 years ago

After experimenting, this is definitely a problem with Cocaine, the dependency paperclip-av-transcoder is using to spawn ffmpeg. I've opened an issue: thoughtbot/cocaine#96

joshuapinter commented 6 years ago

Thanks for tracking this down. I'm running into the same issue.

Were you guys able to resolve this by using a forked version of Cocaine or anything?

joshuapinter commented 6 years ago

FYI, @mmangino has a branch that fixes this and it works great. Read more about it here:

https://github.com/thoughtbot/cocaine/pull/97