Avconv中的视频太短 - 但仅在作为crontab运行时

I'm working on a PHP script that creates half-hour videos, combining a 30-minute MP3 with a still-frame background image, and then putting it on YouTube through the Google API. It works great except when I run it from a crontab, and I can't figure out why.

It uses a shell command to run the following.

avconv -loop 1 -framerate 2 -i background.png -loglevel verbose -i audio.mp3 -c:v libx264 -preset medium -tune stillimage -vf scale=\"trunc(oh*a/2)*2:720\" -crf 18 -c:a copy -shortest -y -pix_fmt yuv420p output.mkv

When I run it from my shell, it produces a video just as long as the 30 minute MP3. But if I run it from any kind of crontab, the result is just a fraction of the full length as it will stop at about 3 or 4 minutes.

Typical output below for a failed result. What baffles me is that it's not that the script is aborted, and it doesn't seem to time out. Rather than stop, it keeps going and will upload the short, unfinished version to YouTube.

I thought it might be a shell environment problem, missing some part of the $PATH or variables. But even when I import all the env and path settings, it does not seem to work.

Is there some way to make sure the avconf (or ffmpeg) command continues all the way through and does not stop too early?

Typical output dump below from one of the times it fails: https://gist.github.com/anonymous/ecaa77037926821dba19e9db5ccb3a10

(I used avconv because my host service claimed ffmpeg was deprecated and that I should use avconv instead. Could a library like PHP-FFMPEG be better for this?)