Save image, sound, clip (video), canvas in TinyDB. Extension Base 64. Download file from the web and convert it to string

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

1 Like

To be honest I just tried getting the basic code running before integrating it into my app. So I opened a new project with the code.
I didn´t change anything instead of the "file://".
I do find the the recorded video(s) in /storage/emulated/0/DCIM/100ANDRO/Name of Video.mp4
But I can´t play any video after recording.

use Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

You might want to replace your local variables temporarily by global variables to be able to use Do it until you found the bug...

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

2 Likes

Thanks so far! I managed to find two files for each video, that was recorded:

/storage/emulated/0/DCIM/100ANDRO/Name of Video.mp4
Size: depending of lenght

/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Name of Video.mp4
Size: always 9Byte and I can´t open it manually

Theses errors occure:

Companion Screen:

The file seems to be in ASD.

Error: The player can´t load the file in /storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/Name of Video.mp4

I´m not sure if this 9 Byte file is the right reference to open the Video, and I don´t get why it is created.

as already said

the message "the variable is not bound in the current context" does not help very much in debugging...

the video player might expect a full path, which starts with file:///storage/emuated/0/Android/data... or a relative path, which is /Android/data/...

Taifun

hi there!
i am currently working on my project i.e based on emotion detector in which i need to send my audio file from mit app inventor to my machine learning model via mqtt and my mentor suggested me that use base64 for this it makes easy for me, my doubt is we are converting the audio file into string, right? it is encoding i want to send the string to my machine learning model as audio file, can you please help me with this. By the way, it's a great work i observe keenly.

I have not tried to send files by MQTT, the usual thing is to send small information.
Do you need to use MQTT? Can you use FireBase or CloudDB? What is your "machine learning model"? What is your MQTT Broker?

https://community.appinventor.mit.edu/t/esp32-mqtt-broker-publish-subscribe-thingspeak/10490

https://community.appinventor.mit.edu/search?q=mqtt

How to set Base64 file to Horizontal/VerticalArrangement.Image or Button.Image ?

Try this extension:

hello i have question is the tiny db save videos?
i want to store 100 videos in tiny db

Would not recommend even trying.

Store the videos on your device, somewhere, and link to them using file paths in the tinydb instead.

Hello everyone
how can i save audio in Base64 extension?

Why ?

i want user to pick an audio file and play it and save it for next times
(something like music player)

You do not need to encode to base64 to do that...

Can the TinyDB save it?

Just save the filepath to the audio file?

hi, Im trying to get pictures and save them on drive. Im using the Takepicturestobase64 block to do it, and work, but the resolution and the scale of the picture is geting small. should I try another kaind of block to fix this?

Thank you so much in advance

If I remember correctly the block you are using gets a preview image not a full image from the camera.

It may be better for you to use the TakePicture block from the camera, then set the resulting image to an image component and convert this image to base64.

You should bear in mind that a base64 of an image is generally 1.3 times larger than the image size.