Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Why are files from Compressor empty?

Hey, guys! I'm getting started using Compressor and Final Cut Pro. One reason that we bought Compressor was that I had read it had FTP support. Then I read (after buying it) that was no longer the case. So, I've got this script in an Automator action attached to a folder called Transfer to rename and move files via FTP:


for f in "$@"

do

g="${f%.mpeg}.mpg"

mv "$f" "$g"

curl -T "$g" ftp://1.2.3.4/123456/MPEG/ --user me:secret

mv "$g" "/Users/me/Sent Stuff"

done


If I have Compressor output the file to some other folder and then copy to Transfer, everything is fine. If Compressor outputs directly to Transfer (what I'd really like!), the file gets renamed and uploaded, but the file on the server is 0 bytes -- empty. Does anyone know why the file would be happening? If I go look at the file locally after it's moved, it's the full video.


Thanks in advance. Let me know if that's at all confusing. I've been hammering at this all day and it's given me a bit of a headache. 🙂


Jeremy

MacBook Pro, OS X Mavericks (10.9.1)

Posted on Jan 28, 2014 1:03 PM

Reply
Question marked as Best reply

Posted on Jan 28, 2014 2:41 PM

I figured what's happening. I made a really long test video. The script starts trying to move it via FTP before Compressor finishes writing it. Any cool ideas about how to handle that?

10 replies

Jan 29, 2014 1:38 AM in response to Jeremy Coulson

HI Jeremy .. yeah this is some arkwardness from "folder actions" when Compressor.app or anything starts writing a new object to a trigger folder.


.. What you can do is simply add a bit of code that loops over (and waits) a 5 second interval (or what frequency) that simply checks for the absence of any file size differences.


we use this with SFTP for an output.


Automator:


Split your AUTOMATOR workflow into TWO nodes if you like

  1. run script: to wait until the file is fully written:
    • Simply get the OBJECT/ FILE SIZE from one from the many RELIABLE property sources and read and check it when your code gets control.
    • When before and now are the same.. you�ll be right to continue the FTP.
  2. execute FTP through the run node

HTH


Post your results for others to see.


Warwick

Hong Kong

Jan 29, 2014 7:07 AM in response to Warwick Teale

Okay, I know I'm about to get outside the scope of the question, but I need some help with the script to do this. Here's what I have:


for f in "$@"

do

# Get the file size, wait 30 seconds, and get it again.

filesize1=(stat -f%z "$f")

sleep 30

filesize2=(stat -f%z "$f")

# Until both file size values are the same, do nothing.

until [ "$filesize1" -eq "$filesize2" ]; do

# Get the file size, wait 30 seconds, and get it again.

filesize1=(stat -f%z "$f")

sleep 30

filesize2=(stat -f%z "$f")

done

# Rename the file to have the extension required by the Nexus.

g="${f%.mpeg}.mpg"

mv "$f" "$g"

# Send the file to the Nexus.

curl -T "$g" ftp://1.2.3.4/Vol123456-01/MPEG/ --user me:secret

# Move the file to the folder with completed items.

mv "$g" "/Users/jcoulson/Nexus Sent"

done


I guess I've created an infinite loop because my script runs forever and never gets anywhere.


Thanks in advance!

Jan 29, 2014 7:23 AM in response to Jeremy Coulson

Hi Jeremy, FWIW just a quick squizz.. it look ok... just shove a debug in there and tes the stat -f%z "$f" val on the way through (log it). It ought to yield a changing amount.


Speculation:

Make sure that the file you're looking at is NOT a place holder until the COMPRESSOR/QMASTER moves it from some other temp place. (/var/temp or elswere).


perform an lsof on the encoder task and see where it actually writing the file.


hth


w

Jan 29, 2014 9:36 AM in response to Warwick Teale

It appears that I'm not getting the value of the file size at all. I've taken this out of Automator altogether while I write it. Here's what I now have:


#!/bin/bash


function get_file_size {

# Get size, wait, get size.

filesize1=$(stat -f%z "$f")

sleep 20

filesize2=$(stat -f%z "$f")

echo $filesize1

echo $filesize2

perform_the_test

}

function perform_the_test {

if [[ $filesize1 -eq $filesize2 ]]

then

# move_the_file

echo "The same!"

else

echo "Not the same!"

get_file_size

fi

}

function move_the_file {

# Rename the file to have the extension required by the Nexus.

g="${f%.mpeg}.mpg"

mv "$f" "$g"

# Send the file to the Nexus.

curl -T "$g" ftp://1.2.3.4/Vol-01/MPEG/ --user me:secret

# Move the file to the folder with completed items.

# mv "$g" "/Users/jcoulson/Nexus Sent"

}

for f in "/Users/jcoulson/Nexus Transfer/"

do

get_file_size

done



If I run this, the value for filesize1 and filesize2 is 136. If I change stat -f%z "$f" so that $f is actually the path to the file ("/Users/jcoulson/Nexus Transfer/Test.mpeg"), I get a completely different number -- the actual size of the file.

Jan 29, 2014 12:06 PM in response to Jeremy Coulson

Final script. It works okay. Pretty frustrating mess. Now I've got it working, but it copies every file in the folder -- including that awful hidden .dsstore file. If Compressor used to perform FTP on its own or would support invoking an AppleScript at the end of processing, why would Apple have removed that feature? I've spent two days now trying to write this script and I think it's time to give up and just FTP the videos manually.


function get_file_size {

# Get size, wait, get size

filesize1=$(stat -f%z "$f")

sleep 20

filesize2=$(stat -f%z "$f")

echo $filesize1

echo $filesize2

perform_the_test

}

function perform_the_test {

if [[ $filesize1 -eq $filesize2 ]]

then

echo "The same!"

move_the_file

else

echo "Not the same!"

get_file_size

fi

}

function move_the_file {

# Rename the file to have the extension required by the Nexus.

g="${f%.mpeg}.mpg"

mv "$f" "$g"

# Send the file to the Nexus.

curl -T "$g" ftp://1.2.3.4/Vol-01/MPEG/ --user me:secret

# Move the file to the folder with completed items.

# mv "$g" "/Users/jcoulson/NexusSent"

}

for f in /Users/jcoulson/NexusTransfer/*

do

get_file_size

done

Why are files from Compressor empty?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.