SFTP upload breaks file

0

1

I run into a strange problem when uploading a .mov video file to a remote sftp location:

The problem is that although the local video1.mov is playable, the remote one throws a -2048 error while trying to play (and a log like "moov atom not found").

PREMISE: the local file and the remote one have exactly the same size. So what can be broken?

Mark

Posted 2012-03-18T23:29:45.447

Reputation: 55

Hi Minitech, did you moved the topic? Should I move it because as I see I had no luck yet here – Mark – 2012-03-19T21:07:25.610

Sorry, looks like not many people paid attention. I've flagged it for a moderator to move it now. – Ry- – 2012-03-19T21:32:31.593

Answers

2

Some video formats cannot be encoded from beginning to end like this; the encoder goes back to the beginning to modify some data fields (size, length, etc.). The piecewise copy was unable to handle this, and thus you now have a broken video file.

Ignacio Vazquez-Abrams

Posted 2012-03-18T23:29:45.447

Reputation: 100 516

you are right, the header gets modified, any ideea how I could update the header on the server with the bytes from the local header? – Mark – 2012-03-20T11:52:15.463

You could use dd to copy a few megabytes from the beginning of the complete file, transfer them over, then use dd to integrate them into the broken file. – Ignacio Vazquez-Abrams – 2012-03-20T13:47:18.637

the local machine can be windows or mac, so I cannot use dd to copy the header. Instead I could use java, but I don't find a way to transfer the information over http, and use it on the server side (for example on php) – Mark – 2012-03-20T14:38:59.903

There is dd for Windows – deed02392 – 2012-03-21T12:39:51.723

1

As far as I can tell (I couldn't really find any documentation describing, or even admitting the existance of it) SFTP resume assumes the part of the target file that already exists is identical to the first part of the source file, up to the size of the remote file. Then it appends the rest of the source file behind the existing target file, and assumes that the two files are now identical.

This fails if the part that was first transferred changes in either file before the transfer is resumed. I guess your .mov file has some kind of header in the very beginning of the file that is necessary to play it, and this is not written to the file until the encoding is finished. Then the remote file you have copied will miss this header, as it was not written yet when it was transferred.

Other tools like rsync have the capability to detect these things, and in some cases avoid retransferring the whole file, at least if the late change is merely overwriting and not insertion.

Eroen

Posted 2012-03-18T23:29:45.447

Reputation: 5 615

thanks man, I also had the same thought but you just confirmed – Mark – 2012-03-20T11:51:21.453