Media Best Practices | Docs | Twitter Developer Platform
文章推薦指數: 80 %
Supported image media types: JPG, PNG, GIF, WEBP; Image size <= 5 MB, animated GIF size <= 15 MB. The file size limit above is enforced by the media upload ... Uploadmedia Overview Guides APIreference Guidescontents MediaBestPractices Chunkedmediaupload ThereareafewimportantconceptstounderstandwhenusingthePOSTmedia/uploadendpoint.UploadingmediawithOAuthcanbeabittricky,sowe’veoutlinedsomethingstokeepinmind,aswellasaworkingsampleofhowtousethisendpointhere. Keepinmind BecausethemethodusesmultipartPOST,OAuthishandleddifferently.POSTorquerystringparametersarenotusedwhencalculatinganOAuthsignaturebasestringorsignature.Onlytheoauth_*parametersareused. Youmayattachupto4photos,1animatedGIFor1videoinaTweet. Theimagepassedshouldbetherawbinaryoftheimageorbinarybase64encoded,noneedtootherwiseencodeorescapethecontentsaslongastheContent-Typeissetappropriately(whenindoubt:application/octet-stream). Whenpostingbase64encodedimages,besuretosetthe“Content-Transfer-Encoding:base64”ontheimagepartofthemessage. Multi-partmessageboundariesmustbeontheirownlineandterminatedbyaCRLF. ForworkingexamplesofhowtoPOSTusingthisendpoint,werecommendtestingwithtwurl.Also,takealookattheTwitterLibrariesavailable,includingthelarge-video-upload-python codesample. Usethemedia_id_stringprovidedintheAPIresponseforJavascriptandanyotherlanguagesthatcannotaccuratelyrepresentalonginteger. MediaCategories TheMediaCategoryparameterdefinestheusecaseofthemediafiletobeuploaded,andcanaffectfilesizelimitsorotherconstraintsenforcedformediauploads.It’simportanttousethecorrectmediacategorywhenuploadingmediatoavoidproblemswhentryingtousethemedia.ItisanoptionalvaluepassedintheINITrequestaspartoftheuploadflow.Ifmediacategoryisnotspecified,theuploadedmediaisassumedtobeaTweetmedia(image,video,orGIF),dependingonthecontenttype. Themostcommonmediacategoriesareasfollows: TweetImage TweetVideo TweetGif DmImage DmVideo DmGif Subtitles IfyouareanAdsAPIpartnerpleaserefertothesedocsformoreinformationonrecommendedmediacategoryforpromotedvideo. Imagespecificationsandrecommendations Imagefilesmustmeetallofthefollowingcriteria: Supportedimagemediatypes:JPG,PNG,GIF,WEBP Imagesize<=5MB,animatedGIFsize<=15MB Thefilesizelimitaboveisenforcedbythemediauploadendpoint.Inaddition,thereisaseparateproductentityspecificfilesizelimitwhichisappliedwhencallingtheTweetcreation(orsimilar)endpointswithmedia_id.Thefilesizelimitandotherconstraintsmayvarydependingonthemedia_categoryparameter. AnimatedGIFrecommendations AGIFmayfailduringTweetcreationevenifitiswithinthefilesizelimit.Adheretothefollowingconstraintstoimprovesuccessrates. Resolutionshouldbe<=1280x1080(widthxheight) Numberofframes<=350 Numberofpixels(width*height*num_frames)<=300million Filesize<=15Mb InordertoprocesslargerGIFs,usethechunkeduploadendpointwiththemedia_categoryparameter.ThisallowstheservertoprocesstheGIFfileasynchronously,whichisarequirementforprocessinglargerfiles.Passmedia_category=tweet_giftoenableasyncuploadbehaviorforTweetswithananimatedGIF. Videospecificationsandrecommendations PleaseusetheAsyncPathformediauploads. Recommended: RecommendedVideoCodec:H264HighProfile RecommendedFrameRates:30FPS,60FPS RecommendedVideoResolution:1280x720(landscape),720x1280(portrait),720x720(square) RecommendedMinimumVideoBitrate:5,000kbps RecommendedMinimumAudioBitrate:128kbps RecommendedAudioCodec:AACLC RecommendedAspectRatio:16:9(landscapeorportrait),1:1(square) Advanced: Frameratemustbe60FPSorless Dimensionsmustbebetween32x32and1280x1024 Filesizemustnotexceed512mb Durationmustbebetween0.5secondsand140seconds Aspectratiomustbebetween1:3and3:1 Musthave1:1pixelaspectratio OnlyYUV4:2:0pixelformatissupported AudiomustbeAACwithLowComplexityprofile.High-EfficiencyAACisnotsupported Audiomustbemonoorstereo,not5.1orgreater MustnothaveopenGOP Mustuseprogressivescan AdditionalInformation: Inthetablebeloweachrowrepresentsanuploadrecommendation,butisnotarequirement.Alluploadsareprocessedforoptimizationacrossmultipleplatforms. Orientation Width Height VideoBitrate AudioBitrate Landscape 1280 720 2048K 128K Landscape 640 360 768K 64K Landscape 320 180 256K 64K Portrait 720 1280 2048K 128K Portrait 360 640 768K 64K Portrait 180 320 256K 64K Square 720 720 2048K 128K Square 480 480 768K 64K Square 240 240 256K 32K Foranexampleofhowtouploadmedia,pleaseseethechunkedmediauploaddocumentation. Troubleshooting ForissueswiththeMediaAPIs,browsethe MediaAPIcategoryinthedeveloperforumsforananswer. ByusingTwitter’sservicesyouagreetoourCookiesUse.Weusecookiesforpurposesincludinganalytics,personalisation,andads. OK ThispageandcertainotherTwittersitesplaceandreadthirdpartycookiesonyourbrowserthatareusedfornon-essentialpurposesincludingtargetingofads. Throughthesecookies,Google,LinkedInandDemandbasecollectpersonaldataaboutyoufortheirownpurposes. Learnmore. Accept Decline
延伸文章資訊
- 1The Ultimate Twitter Image Size Guide for 2022 [Updated]
The ideal image size and aspect ratio are 1200px X 675px and 16:9, respectively. The maximum file...
- 2Have a GIF that is too large to post on Twitter? Try this solution
- 3Media Best Practices | Docs | Twitter Developer Platform
Supported image media types: JPG, PNG, GIF, WEBP; Image size <= 5 MB, animated GIF size <= 15 MB....
- 4GIF Creation Best Practices - GIPHY support
- 5Twitter Image Sizes & Dimensions 2020 - Publer's Blog
Recommended GIF's resolution is 1280×1080; Maximum GIF size is 15MB. Click to learn more about Li...