Thumbnail upload from remote url (s3 bucket)

I would like to have the thumbnail to a video uploaded with the source being a remote https url. For example, I am creating a video using the python api.video client in my aws lamda function and right after the uplaod I have to upload the thumbnail to that video, according to the documentation the thumbnail can only be uploaded as a local disk file path. Can this feature be implemented? It is available in some competitors like JWplayer. Or the file content can be uploaded if not via the remote url?

1 Like

Hi - I asked about this today and I will update you when I have a response! :slight_smile:

1 Like

Same question here :slight_smile:

You can always use urllib.request.urlretrieve(url, filename)

to download the thumbnail temporarily OR

from urllib.request import urlopen 
import base64

base64.b64encode(urlopen("http://xxx/yyy/abc.jpg").read())

then pass

data:image/png;name=somefilename.png;base64, + what was encoded 

as your file.

Last option is to pick a timecode if you know that…

video_id = "vi4k0jvEUuaTdRAEjQ4Jfrgz" # str | Unique identifier of the video you want to add a thumbnail to, where you use a section of your video as the thumbnail.
    video_thumbnail_pick_payload = VideoThumbnailPickPayload(
        timecode="04:80:72",
    )
1 Like

Thanks @ronald for your response.

In my Firebase Function (Node), I tried two different ways and both returns “must be a readable source file”

const url = "***.jpg""
let image = await axios.get(myImageUrl, { responseType: "arraybuffer" });
let returnedData = Buffer.from(image.data).toString();
const file = Readable.from(returnedData);
await apiVideoClient.liveStreams
  .uploadThumbnail(result.liveStreamId, file)
  .then((res) => {
    console.log(res);
  })
  .catch((error) => {
    throw new functions.https.HttpsError("aborted", error.message);
  });

const url = "***.jpg""
const fileName = data.image.split("/").slice(-1)[0];
let image = await axios.get(myUrl, { responseType: "arraybuffer" });
let returnedB64 = Buffer.from(image.data).toString("base64");
const file =
  "data:@file/jpeg;name=myfilename.jpg;base64," + returnedB64;
await apiVideoClient.liveStreams
  .uploadThumbnail(result.liveStreamId, file)
  .then((res) => {
    console.log(res);
  })
  .catch((error) => {
    throw new functions.https.HttpsError("aborted", error.message);
  });

thanks, my issue has been fixed.

thanks my issue has been fixed.