Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FFMPEG cannot read files in /tmp/ on Heroku

I created a nodejs application hosted on heroku which uses imagemagick. I am doing this operation:

require('child_process').exec(`convert -quiet -delay 1 output.avi ${gif}`);

This should convert output.avi (which is present) to a gif file. In this case, gif is "/app/temp/gifs/xstrycatdq.gif". This command works perfectly on my local windows machine. As I use the path module to get a variable with path.joinand __dirname.

I have installed heroku buildpack:

  • https://github.com/ello/heroku-buildpack-imagemagick

The error I am receiving is:

Command failed: convert -quiet -delay 1 output.avi /app/temp/gifs/xstrycatdq.gif
convert: DelegateFailed `'ffmpeg' -nostdin -v -1 -vframes %S -i '%i' -vcodec pam -an -f rawvideo -y '%u.pam' 2> '%Z'' @ error/delegate.c/InvokeDelegate/1919.
convert: UnableToOpenBlob `magick-93R4VJcemPz0z1.pam': No such file or directory @ error/blob.c/OpenBlob/2705.
convert: NoImagesDefined `/app/temp/gifs/xstrycatdq.gif' @ error/convert.c/ConvertImageCommand/3257.

It seems that the /tmp/ directory can't be written to or anything. I also tried to mkdir /tmp/ but bash tells me that this dir already exists.

I have also tried changing the imagemagick's temp directory with the environment variable by doing export MAGICK_TMPDIR="temp".

Any help?

Edit: The variables are now absolute.

like image 658
Tvde1 Avatar asked Jan 17 '18 19:01

Tvde1


1 Answers

Are you sure it's not an issue of permissions? Can you write a simple text file to /app/temp? Is nothing is being read or written at all, it sounds like an issue of permissions. Maybe it's not necessarily a protection design of ImageMagick, but rather heroku or your programming environment?

This directory you're trying to use, it's special in that it contains corrupt or incomplete files - it may have special protections or guards in place, when certain software is running. temp directories are typically designed (or assumed) to be protected from user interference, as they are only to be used and worked with, by the program itself - not the user's commands of the program.

This question is similar to yours, it might be able to help you.

like image 121
Tanner Babcock Avatar answered Oct 05 '22 06:10

Tanner Babcock