22
$\begingroup$

I'd like to take some little videos I made in Mathematica and put them on YouTube. Is there a way to do this?

$\endgroup$

1 Answer 1

30
+100
$\begingroup$

I built a service connection for this and blogged about it here: Playing with YouTube from Mathematica

Here's an example of how this works.

Connect to YouTube

First install the paclet:

PacletInstall["ServiceConnection_YouTube",
  "Site"->
    "http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer/"
  ]

post22-8529256040837869960
(source: wolframcloud.com)

Then connect:

$so = ServiceConnect["YouTube"]

post22-6049558537553480280
(source: wolframcloud.com)

Upload Video

anim =
  Export[
    FileNameJoin@{$TemporaryDirectory, "plot3d.flv"},
    Manipulate[
      Plot3D[Sin[n x y], 
        {x, 0, 3}, {y, 0, 3}, 
        ViewPoint -> Dynamic[{2, v, 2}], SphericalRegion -> True, Ticks -> None,
        PerformanceGoal->"Quality"
        ], 
      {n, 1, 4}, 
      {v, -2, 2}
      ]
    ];

upload = $so["UploadVideo", "part"->"id", "BodyContent"->anim];

Add Metadata

Because of how I built it you have to add the metadata after the upload. You do it like this:

$so["UpdateVideo", "id" -> upload["id"],
 "part" -> "snippet",
  "Title" -> "Mathematica Examples: Plot 3D",
 "CategoryID" -> "22"
 ]

Get an IFrame for Embedding

$so["EmbedIFrame", "id"->upload["id"]]

<iframe id="ytplayer" type="text/html" width="640" height="360"
src="https://www.youtube.com/embed/Quzcr4Vuq_Q?autoplay=0"
  frameborder="0"></iframe>

Here's the raw URL: https://www.youtube.com/watch/?v=Quzcr4Vuq_Q

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.