Duration too long, maximum:30000

codebird

#1

My Code(PHP) for uploading video on Twitter:

$reply = $cb->media_upload([
‘command’ => ‘INIT’,
‘media_type’ => ‘video/mp4’,
‘total_bytes’ => $mediaSize,
]);
print_r($reply);

$media_id = $reply->media_id_string;

// APPEND data to the upload
$segment_id = 0;

while (!feof($fp)) {
$chunk = fread($fp, 1048576); // 1MB per chunk for this sample
$reply = $cb->media_upload([
‘command’ => ‘APPEND’,
‘media_id’ => $media_id,
‘segment_index’ => $segment_id,
‘media’ => $chunk,
‘media_category’ => “TWEET_VIDEO”,
]);
print_r([$reply, $segment_id]);
$segment_id++;
}

fclose($fp);

// FINALIZE the upload
$reply = $cb->media_upload([
‘command’ => ‘FINALIZE’,
‘media_id’ => $media_id,
‘media_category’ => “TWEET_VIDEO”,
]);
print_r($reply);

// Now use the media_id in a Tweet
$reply = $cb->statuses_update([
‘status’ => $postDescription,
‘media_ids’ => $media_id,
]);

Output:

-------- INIT ---------
(
[media_id] => 1104959576267358209
[media_id_string] => 1104959576267358209
[expires_after_secs] => 86400
[httpstatus] => 202
[rate] => stdClass Object
(
[limit] => 200
[remaining] => 196
[reset] => 1552280658
)

)

-------- APPEND ---------
stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19967
[reset] => 1552280664
)
)

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19966
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19965
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19964
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19963
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19962
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19961
[reset] => 1552280664
)

    )

stdClass Object
(
[httpstatus] => 204
[rate] => stdClass Object
(
[limit] => 20000
[remaining] => 19960
[reset] => 1552280664
)

    )

----------- FINALIZE -----------
stdClass Object
(
[media_id] => 1104959576267358209
[media_id_string] => 1104959576267358209
[size] => 7687982
[expires_after_secs] => 86400
[video] => stdClass Object
(
[video_type] => video/mp4
)

[httpstatus] => 201
[rate] => stdClass Object
    (
        [limit] => 615
        [remaining] => 610
        [reset] => 1552280693
    )

)

stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[code] => 324
[message] => Duration too long, maximum:30000, actual:77276 (MediaId: snf:1104959576267358209)
)

    )

[httpstatus] => 400
[rate] => 

)


#2

It seems as though you are attempting to upload a video that is too long to meet Twitter specifications.


#3

Hello Andy,

Can you specify the video size, duration resolution while upload or share.

Attached my test video information which are I tried to upload in tweet.

Thanks,


#4

Hello Andy,

I Posted my video information, is there any issues in video size and duration?


#5

Are you able to provide a copy of the test video for someone to try to reproduce this error?

Have you tried running our large video upload sample to see whether that works?