Video upload results "InvalidContent" error

video
ios

#1

Hi,
I upload video (dropbox) in 3 steps. And at FINALIZE step I got “InvalidContent” error.

When I’m uploading this video via web - all works https://twitter.com/NikiTiki6/status/860477980006649856.

– mediaID 860471838882844672, expiresAfterSecs 86399
– SEGMENT INDEX 0, SUBDATA {0, 931767}, DATALENGTH 931767
– POST 0
success
Written 8192 totalWritten 8192 ExpectedToWrite 931767
success
Written 229376 totalWritten 237568 ExpectedToWrite 931767
success
Written 694693 totalWritten 932261 ExpectedToWrite 931767
– POST OK 0
– POST finished
error InvalidContent.


#2

It seems like something must be wrong with your code. I’ve just used our large-video-upload sample app to post this same video with no issues. Are you using the chunked upload method?


#3

Yes, as i said - 3step method.


#4

Yes, apologies you did say that! :no_mouth:

Are you able to try the sample code? I’m not sure what might be different to the way you’re uploading the file.

It looks like these final values do not match -> totalWritten **932261** ExpectedToWrite **931767** so maybe there’s a miscalculation somewhere.


#5

Added 'media_category': 'tweet_video' to INIT method - and finalization became successful.


#6

But then, whn I’m trying to post it I got -"Not valid video"


#7

Are you using the media_id, or media_id_string to attach to the Tweet?

Is there any other error code or message aside from Not valid video?


#8

I cant reproduce “Not valid video” error any more. It appears only first time I managed upload video. After that - none.

So, thanks for you link to large-video-upload sample. Than source code give me a hint about 'media_category': 'tweet_video' in INIT step.


#9

After several successful tweets, it started to send error again.

I use media_id_string.

Error Domain=STTwitterTwitterErrorDomain Code=324 "Not valid video" UserInfo={NSLocalizedDescription=Not valid video, NSUnderlyingError=0x174c4a470 {Error Domain=STHTTPRequest Code=400 "HTTP Status 400: Bad Request" UserInfo={headers=<CFBasicHash 0x175a7d280 [0x1a73c3bb8]>{type = immutable dict, count = 20,
entries =>
	0 : Content-Encoding = gzip
	1 : Set-Cookie = <CFString 0x1744247e0 [0x1a73c3bb8]>{contents = "lang=ru; Path=/, guest_id=v1%3A149399413578354278; Domain=.twitter.com; Path=/; Expires=Sun, 05-May-2019 14:22:15 UTC"}
	2 : Last-Modified = <CFString 0x170859e90 [0x1a73c3bb8]>{contents = "Fri, 05 May 2017 14:22:15 GMT"}
	3 : Server = tsa_o
	4 : Cache-Control = <CFString 0x17049c700 [0x1a73c3bb8]>{contents = "no-cache, no-store, must-revalidate, pre-check=0, post-check=0"}
	5 : Strict-Transport-Security = <CFString 0x1708582d0 [0x1a73c3bb8]>{contents = "max-age=631138519"}
	6 : Status = <CFString 0x170858180 [0x1a73c3bb8]>{contents = "400 Bad Request"}
	8 : x-transaction = <CFString 0x17085b210 [0x1a73c3bb8]>{contents = "006c538100e45902"}
	9 : x-tsa-request-body-time = 1
	10 : x-response-time = 155
	12 : Pragma = no-cache
	21 : Content-Disposition = <CFString 0x170855c00 [0x1a73c3bb8]>{contents = "attachment; filename=json.json"}
	23 : x-xss-protection = <CFString 0x17042d3e0 [0x1a73c3bb8]>{contents = "1; mode=block"}
	24 : Date = <CFString 0x17085a130 [0x1a73c3bb8]>{contents = "Fri, 05 May 2017 14:22:15 GMT"}
	29 : Expires = <CFString 0x170858120 [0x1a73c3bb8]>{contents = "Tue, 31 Mar 1981 05:00:00 GMT"}
	33 : x-frame-options = <CFString 0x17043c4e0 [0x1a73c3bb8]>{contents = "SAMEORIGIN"}
	35 : x-twitter-response-tags = <CFString 0x170858030 [0x1a73c3bb8]>{contents = "BouncerCompliant"}
	36 : Content-Type = <CFString 0x1714613c0 [0x1a73c3bb8]>{contents = "application/json; charset=utf-8"}
	39 : x-connection-hash = <CFString 0x171473740 [0x1a73c3bb8]>{contents = "8230738f227c47ccfae17247c7183637"}
	40 : x-content-type-options = nosniff
}
, NSLocalizedDescription=HTTP Status 400: Bad Request, body={"errors":[{"code":324,"message":"Not valid video"}]}}}}

#10

Is this the same video file, or a different one? Are the encoding parameters the same?


#11

File is another. But all of them taken using one app. Encoding parameters for all of them are the same.

small Hint:

  • if i do small delay between finishing uploading video and posting it - everything works perfectly. Why?

#12

Are you checking that the video has finished encoding, using the STATUS command, after FINALIZE?


#13

No. I’ll try.


#14

I didnt found how to check STATUS with STTwitter framework so i just put an delay there :no_mouth: . Thanks for you time and helpful advices.


#15

No problem. I’d strongly recommend getting STATUS to work - it is documented here and will help you to understand why uploads may fail in some cases. Maybe worth raising a ticket with STTwitter folks to seek assistance with that.