lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.39k stars 160 forks source link

convert-video when called by cron fails with <outputfile> Does Not Exist #178

Closed rncole closed 7 years ago

rncole commented 7 years ago

I have written a script that calls on the convert-video utility and have it scheduled via crontab on OS X 10.13. The script when invoked via command line directly functions as expected. When it is called via crontab it fails with Does Not Exist.

lisamelton commented 7 years ago

@rncole Then it's likely the value of your $PATH variable is different when the script is invoked via crontab as opposed to when you invoke it directly from the command line. I recommend adding a line to your script which prints out the value of $PATH so you can check this.

lisamelton commented 7 years ago

@rncole It's also possible that if the user and group are different when the crontab is invoked, then some kind of privilege violation is happening. You may want to check that as well.

rncole commented 7 years ago

Here are two instances, the first of it failing, and the second is manually run:

iMac:~/bin rncole$ cat tmp/cron-transcode-mkv.log Tue Nov 21 22:19:00 EST 2017 path: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE No MP4 Found; Transcoding... Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv MP4 Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 transcode-video --quick --mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 Does Not Exist iMac:~/bin rncole$ ./cron-transcode-mkv Tue Nov 21 22:19:08 EST 2017 path: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE No MP4 Found; Transcoding... Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv MP4 Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 transcode-video --quick --mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv

On Nov 21, 2017, at 10:37 PM, Don Melton notifications@github.com wrote:

@rncole https://github.com/rncole It's also possible that if the user and group are different when the crontab is invoked, then some kind of privilege violation is happening. You may want to check that as well.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/donmelton/video_transcoding/issues/178#issuecomment-346233963, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8TrwndAfTnUaA0pC9_jrRIza4lusZaks5s45cDgaJpZM4Qmztj.

rncole commented 7 years ago

Note that it’s in my user crontab, and the files are in my user folder. The only output from the script is as shown ( Does Not Exist).

Oh, and thanks for the immediate reply - that was quick!

On Nov 21, 2017, at 10:46 PM, Robert Cole rncole@gmail.com wrote:

Here are two instances, the first of it failing, and the second is manually run:

iMac:~/bin rncole$ cat tmp/cron-transcode-mkv.log Tue Nov 21 22:19:00 EST 2017 path: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE No MP4 Found; Transcoding... Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv MP4 Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 transcode-video --quick --mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 Does Not Exist iMac:~/bin rncole$ ./cron-transcode-mkv Tue Nov 21 22:19:08 EST 2017 path: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE No MP4 Found; Transcoding... Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv MP4 Line: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 transcode-video --quick --mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv

On Nov 21, 2017, at 10:37 PM, Don Melton <notifications@github.com mailto:notifications@github.com> wrote:

@rncole https://github.com/rncole It's also possible that if the user and group are different when the crontab is invoked, then some kind of privilege violation is happening. You may want to check that as well.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/donmelton/video_transcoding/issues/178#issuecomment-346233963, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8TrwndAfTnUaA0pC9_jrRIza4lusZaks5s45cDgaJpZM4Qmztj.

lisamelton commented 7 years ago

@rncole Is your current working directory somehow different in the two cases?

rncole commented 7 years ago

I was JUST about to email you. I just noticed that when manually run here the output file is being put in the bin folder where I’m invoking it.

I had understood your documentation that the output file would be placed in the same folder as the input file, and couldn’t find a way to specify the output file. I added a cd $path command to my script and it appears to be working correctly.

Thanks again for your help.

On Nov 21, 2017, at 10:51 PM, Don Melton notifications@github.com wrote:

@rncole https://github.com/rncole Is your current working directory somehow different in the two cases?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/donmelton/video_transcoding/issues/178#issuecomment-346235646, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8Tr4ydb_Gv4L93rwg59NKlDhPqczMZks5s45o5gaJpZM4Qmztj.

lisamelton commented 7 years ago

@rncole The built-in --help and the README document do say that output, by default, is placed "in current working directory." But maybe I should make that more obvious?

Anyway, I'm glad your problem is solved! Thank you so much for opening this issue so we could discuss it. And please feel free to open other issues in the future. I value your interest in and use of the tools.

I'll close this now but feel free to comment again here. I get all the notifications. :)

rncole commented 7 years ago

Nope, spoke too soon. I was using the -o option previously, and had removed it, and that tripped me up.

Here’s the modified output now showing the output of “pwd” in the log: iMac:~/bin rncole$ cat tmp/cron-transcode-mkv.log Tue Nov 21 23:03:00 EST 2017 path: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE Working Directory: /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE MP4 Found, checking durations...

MKV Length: Duration: 01:37:51

MP4 Length: Duration: 00:00:04 Length Mismatch; deleting MP4. transcode-video --quick --mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mkv -o /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 /Users/rncole/Movies/Rips/How_To_Train_Your_Dragon_SE/How_To_Train_Your_Dragon_SE_t00.mp4 Does Not Exist

On Nov 21, 2017, at 10:55 PM, Robert Cole rncole@gmail.com wrote:

I was JUST about to email you. I just noticed that when manually run here the output file is being put in the bin folder where I’m invoking it.

I had understood your documentation that the output file would be placed in the same folder as the input file, and couldn’t find a way to specify the output file. I added a cd $path command to my script and it appears to be working correctly.

Thanks again for your help.

On Nov 21, 2017, at 10:51 PM, Don Melton <notifications@github.com mailto:notifications@github.com> wrote:

@rncole https://github.com/rncole Is your current working directory somehow different in the two cases?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/donmelton/video_transcoding/issues/178#issuecomment-346235646, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8Tr4ydb_Gv4L93rwg59NKlDhPqczMZks5s45o5gaJpZM4Qmztj.

rncole commented 7 years ago

Finally for the script working via scheduling. Your first hunch (permissions) looks to be the right one. It appears 10.13’s crontab has very limited permissions with regard to creating files.

I switched over to using launchd (eek! New!) and it works perfectly.

Thanks again for your help, and especially thanks for your tools. I very much appreciate your work. If there’s a way for me to buy you a beer or similar let me know.

Regards, Robert Cole

On Nov 21, 2017, at 23:03, Don Melton notifications@github.com wrote:

@rncole https://github.com/rncole The built-in --help and the README document do say that output, by default, is placed "in current working directory." But maybe I should make that more obvious?

Anyway, I'm glad your problem is solved! Thank you so much for opening this issue so we could discuss it. And please feel free to open other issues in the future. I value your interest in and use of the tools.

I'll close this now but feel free to comment again here. I get all the notifications. :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/donmelton/video_transcoding/issues/178#issuecomment-346237211, or mute the thread https://github.com/notifications/unsubscribe-auth/AD8TryS5unSjon9HJCo1dEnGMuVjMHmRks5s450mgaJpZM4Qmztj .

lisamelton commented 7 years ago

@rncole You are very welcome! And so is beer. And it's funny that launchd fixed it. :)