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);
Related
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);
}
I am new to Flutter and coding. I followed the guide here for how to add a watermark to an image. However, I am not using image picker, but using an image stored within Firebase, and a watermark that is an asset.
The code builds fine, but when I press the button to generate the watermarked image and eventually share it, I get the following error
Unhandled Exception: FileSystemException: Cannot open file, path = 'firebase url path' (OS Error: No such file or directory, errno = 2)
It is recognizing the path to the image in Firebase, but for some reason is saying the file isn't available. The error is being thrown on the 'decodeImage' portion of the code below.
Code snippet below
import '../backend/image_share/image_share.dart';
import 'package:image/image.dart' as ui;
import 'dart:io';
onPressed: () async {
//first image is a firebase path
final pickedFile = File('firebae path');
//second image is watermark and an asset
final watermark = File('assets/images/Share-small.png');
ui.Image originalImage = ui.decodeImage(pickedFile.readAsBytesSync());
ui.Image watermarkImage = ui.decodeImage(watermark.readAsBytesSync());
ui.drawImage(originalImage, watermarkImage);
ui.drawString(originalImage, ui.arial_24, 100, 120, 'Test!');
List<int> wmImage = ui.encodePng(originalImage);
final uploadUrl = await uploadData('new firebase data', wmImage);
final 'new firebase data' = FB collection(sharedImage: uploadUrl);
I am having trouble figuring out how to read/upload the image file before manipulating them.
The File class can only read/write files that are on the local system. It does not have any knowledge of files in Cloud Storage.
You will need to:
download the file from Cloud Storage,
add the watermark on the device, and then
write the resulting file back to Cloud Storage.
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.
I'm using the flutter camera package to record videos and save videos to a temporary directory after which I use flutter's ffmpeg package to do some transformation. However, to achieved this, I first had to make a copy of the recorded video to create the output file path.
The challenge comes in when I'm trying to load the asset from the device. The block of code below does the copying and renaming of the file.
static Future<File> copyFileAssets(String assetName, String localName) async {
ByteData assetByteData = await rootBundle.load(assetName);
final List<int> byteList = assetByteData.buffer
.asUint8List(assetByteData.offsetInBytes, assetByteData.lengthInBytes);
final String fullTemporaryPath =
join((await tempDirectory).path, localName);
return new File(fullTemporaryPath)
.writeAsBytes(byteList, mode: FileMode.writeOnly, flush: true);
}
The issue lies with this line ByteData assetByteData = await rootBundle.load(assetName);
I get this error message Unable to load asset: /storage/emulated/0/Android/data/com.timz/files/timz/1585820950555.mp4, but the weird thing is, this only happens when I run the build for the first. Everything else works fine on subsequent hot restarts.
I later got this fix by myself rootBundle is meant for loading only assets you've declared their paths on your pubspec.yaml but somehow, it miraculously loads the saved file when hot restart was applied.
Reading the file as bytes gave what I wanted as load it with root bundle. Here's the code below.
Uint8List assetByteData = await File(assetName).readAsBytes();
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 :)