How do decode base64 video and play the video using flutter? - flutter

am recording the video using camera plugin and saved the video in internal storage path then i have encoded video using base64.Now i need to decode the encoded value and play the decoded value in flutter application.If any one can help me. thanks in advance.
_fileConvert(String path) {
File file = File(path);
List<int> fileInByte = file.readAsBytesSync();
String fileInBase64 = base64Encode(fileInByte);
print("fileInBase64............");
print(fileInBase64);
}

Related

How to read PCM audio data from Swift Data variable type into AVAudioPCMBuffer?

I'm working on a project where I'd like to play raw PCM data for IOS using swift. So far I've been able to load the PCM data from a local file into a swift Data variable like so
let audioData = try Data(contentsOf: fileURL) //Read data into data var
where fileURL contains the path to a PCM file.
Next, I'd like to play the audioData somehow; currently my ideas are to either
add a WAV header onto the audioData, write the data to file, then play it using AVAudioPlayer
somehow copy the data over to a AVAudioPCMBuffer and play it from the buffer using AVAudioEngine
Unfortunately, since I'm very new to swift and audio in general I'm pretty lost on how to actually program either of these routes

Flutter videoplayer end to end

I'm trying to make a flutter videoplayer with an encrypted video, how can I do to decrypt the file with an algorithm made by me?
is there a way to have access to the buffer before giving it to the videoplayer?
If you're using the video_player package, it accepts File as inputs.
So instead of giving the encrypted video from the web as the source for the controller:
_videoController = VideoPlayerController.network(videoUrl)
What you can do instead is get your video from the web yourself, and decrypt it (I assume that at the end of this process you'd have a Uint8List). Then, convert it into a File and give it to the video player as the source:
import 'dart:io';
...
final video = fetchVideo(videoUrl);
final Uint8List decryptedVideoBytes = decryptVideo(video);
final File videoFile = File.fromRawPath(Uint8List uint8List);
_videoController = VideoPlayerController.file(videoFile);

Convert byte[] to Video (mp4 or any other palyable format)

I am creating a bot that will record the Microsoft team live sessions. Audio recording is working fine but facing problems in generating the video file. The process I am following is that I am converting the video data into a byte array and then writing the data to a video format file.
I am adding some code snippets, I have examined so far.
1. Stream videoStream = new FileStream(videoFilePath, FileMode.Create);
BinaryWriter videoStreamWriter = new BinaryWriter(videoStream);
videoStreamWriter.Write(videoBytesArray, 0, videoBytesArray.Length);
videoStreamWriter.Close();
2. System.IO.File.WriteAllBytes(videoFilePath, videoBytesArray);
The generated files from the above code snippets are of an unsupported format.
It may be because of the data receiving from the session.
I am receiving the data through the Local media session's Video Socket on VideoMediaReceived Event (ICall.ILocalMediaSession.VideoSockets). The Video Color Format of the data that the socket is receiving is of H264 Format.
A similar problem I encountered when creating the audio file. For that, I utilized the WaveFormat package for creating an audio file.
So, Is there any library/method to convert the byte array to a video file of any format?
#Murtaza, you can try this and see if it helps. If the byte array is already a video stream then, simply you can serialize it to the disk with the extension mp4. (If it's an MP4 encoded stream).
Stream t = new FileStream("video.mp4", FileMode.Create);
BinaryWriter b = new BinaryWriter(t);
b.Write(videoData);
t.Close();

How to convert Audio bytes to String in flutter

I'm getting List<int> as RAW data from recorder plugin for Android and iOS, I want to display Actual text from the bytes, The data is stream of system mic.
Any way to get text from bytes?
Raw data detail:
SampleRate: 44100,
ChannelConfig: MONO-16,
AudioSource: SYSTEM-MIC
Note: I'm already using SpeechToText plugin and aware about it, But I fill that at some-point which is dropping words hence I want to try something else.
Any help will be appreciated.
import 'package:mime/mime.dart';
String? lookupMimeType(String path, {List<int>? headerBytes})
You can use ı think.
var mimeString = lookupMimeType();İf you fill the parameter it works. You can use directly your audio file's path.

Storing images in windows phone 8

I have been really cracking my head trying to write and read png files into a folder in Windows Phone 8. From few blogs sites and codeplex i found that the there is an extension to the WritableBitmap Class which provides few extra functionalities. ImageTools has PNG encoder and decoder. But I really cant find examples to use them.
What Im trying to achieve here is to create a folder called page and then in it a file called Ink File. I want to convert the bitmap to a PNG and store it there. The bitmap is created from the strokes drawn on a canvas. The class ImageTools provides a function called ToImage to convert the strokes from the canvas to image.
For storing
ExtendedImage myImage = InkCanvas.ToImage();
var encoder = new PngEncoder();
var dataFolder = await local.CreateFolderAsync("Page", CreationCollisionOption.OpenIfExists);
StorageFile Ink_File = await dataFolder.CreateFileAsync("InkFile", CreationCollisionOption.ReplaceExisting);
using (var stream = await Ink_File.OpenAsync(Windows.Storage.FileAccessMode.ReadWrite))
{
using (var s = await Ink_File.OpenStreamForWriteAsync())
{
encoder.Encode(myImage, s);
await s.FlushAsync();
s.Close();
}
}
Is this a correct method? I receive some null exceptions for this. How do i find if the image is saved as png. How is this image saved? Is it encoded and saved in a file or is it saved as a png itsef. And how do we read this back?
I have checked out this, this , this and lot more like this.
I'm developing app for WP8
I have used the PNG Writer Library found in ToolStack and it works :)