MediaEncodingProfile.CreateWmv gives "No suitable transform was found to encode or decode the content." error - video-capture

I am creating a Windows Phone app (XAML/C#) that uploads audio and video to a server. Using VideoCaptureDevice on Windows Phone 8.0 works fine, but it only allows resolutions supported by the device (on a Nokia 625 the smallest is 640 x 480). To get the size down I have upgraded the app to Windows Phone 8.1 Silverlight (Developer Preview) to use the Windows.Media.Capture.MediaCapture libraries. This works and the generic Qvga format:
MediaEncodingProfile profile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);
Works on both the Nokia 625 and 520 and gets the resolution down to 320 x 240, but the file size is still ~24MB for 4 minutes of video. If I set a custom resolution like this:
MediaEncodingProfile profile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
profile.Video.Width = 480;
profile.Video.Height = 320;
I get a much smaller file size (4 min == ~6MB, which is odd) but it is corrupted on the 625.
I would like to try it out with other file types, eg .wmv, but:
MediaEncodingProfile profile = MediaEncodingProfile.CreateWmv(Windows.Media.MediaProperties.VideoEncodingQuality.Auto);
Gives a System.Exception "No suitable transform was found to encode or decode the content."
I'm also going to need to do this for audio, ie:
MediaEncodingProfile profile = MediaEncodingProfile.CreateMp3(Windows.Media.MediaProperties.AudioEncodingQuality.Auto);
But I get the same error.
I suppose I'm asking lots of questions here, but I'm really asking:
What's the best way to reduce video size in Windows Phone 8.1 Silverlight?
Can anyone help me apply a suitable transform for .wmv and/or .mp3 recording?
Does anyone know why setting the video resolution manually causes instability?
I have also tried setting the audio properties manually to see if that will get the size down:
MediaEncodingProfile profile = MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.Qvga);
profile.Audio.Subtype = "PCM";
profile.Audio.ChannelCount = 2;
profile.Audio.BitsPerSample = 8;
profile.Audio.SampleRate = 22050;
But this also leads to a corrupted file.
Any help greatly appreciated - have hunted around but found very little on the subject...

Maybe it is related to this IoT:
https://ms-iot.github.io/content/en-US/win10/ReleaseNotesRTM.htm
Release Notes for Windows 10 IoT Core Build Number 10586. December 2015
Known Issues
A MediaEncodingProfile.CreateWma( Windows.Media.MediaProperties. AudioEncodingQuality.Auto) method call may fail on the Raspberry Pi 2 with the error message No suitable transform was found to encode or decode the content. (Exception from HRESULT: 0xC00D5212). (4510128) WORKAROUND: None.

Related

Cannot find the exact eror sometimes showing Adapter not attached sometimes cannot find memetrack [duplicate]

I'm running Ubuntu 16.04. And on Android Studio when I try to run my application in the emulator I get the following error:
FATAL EXCEPTION: main
Process: project name here, PID: 2528
java.lang.RuntimeException: Canvas: trying to draw too large(216090000bytes) bitmap.
at android.view.DisplayListCanvas.throwIfCannotDraw(DisplayListCanvas.java:260)
at android.graphics.Canvas.drawBitmap(Canvas.java:1415)
at android.graphics.drawable.BitmapDrawable.draw(BitmapDrawable.java:528)
at android.widget.ImageView.onDraw(ImageView.java:1316)
at android.view.View.draw(View.java:17185)
at android.view.View.updateDisplayListIfDirty(View.java:16167)
at android.view.View.draw(View.java:16951)
at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513)
at android.view.View.updateDisplayListIfDirty(View.java:16162)
at android.view.View.draw(View.java:16951)
at android.view.ViewGroup.drawChild(ViewGroup.java:3727)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3513) at
etc...
I did have to run through some hoops to get my emulator working however, needed to create a sym-link so I can run the emulator on AMD. Not sure if this is part of the problem. And for the life of me I cannot figure why it continues to do this. In my group there are others who emulate the project just fine on the same emulated phone and SDK.
Move your image in the (hi-res) drawable to drawable-xxhdpi. But in app development, you do not need to use large image. It will increase your APK file size.
The solution is to move the image from drawable/ folder to drawable-xxhdpi/ folder, as also others have mentioned.
But it is important to also understand why this somewhat weird suggestion actually helps:
The reason is that the drawable/ folder exists from early versions of android and is equivalent to drawable-mdpi. When an image that is only in drawable/ folder is used on xxhdpi device, the potentially already big image is upscaled by a factor of 3, which can then in some cases cause the image's memory footprint to explode.
This solution worked for me.
Add these lines in your Manifest application tag
android:largeHeap="true"
android:hardwareAccelerated="false"
I had the same problem.
If you try to upload an image that is too large on some low resolution devices, the app will collapse.
You can make several images of different sizes (hdpi, xxdpi and more) or simply use an external library to load images that solve the problem quickly and efficiently.
I used Glide library (you can use another library like Picasso).
panel_IMG_back = (ImageView) findViewById(R.id.panel_IMG_back);
Glide
.with(this)
.load(MyViewUtils.getImage(R.drawable.wallpaper)
.into(panel_IMG_back);
This issue can be resolved by 3 methods as follows:
Method 1:
By adding image into a res/drawable-nodpi folder (By doing this it will not pre-scale your image).
Method 2:
Generate all dpi(hdpi,ldpi,mdpi,xhdpi,xxhdpi,xxxhdpi) of image and add to drawable folder. (This process will increase APK size).
Method 3:
Add image to drawable/drawable-xxhdpi folder.
All these methods are verified.
Turns out the problem was the main image that we used on our app at the time. The actual size of the image was too large, so we compressed it. Then it worked like a charm, no loss in quality and the app ran fine on the emulator.
For this error was like others said a big image(1800px X 900px) which was in drawable directory, I edited the image and reduced the size proportionally using photoshop and it worked...!!
If you don't want your image to be pre-scaled you can move it to the res/drawable-nodpi/ folder.
More info: https://developer.android.com/training/multiscreen/screendensities#DensityConsiderations
if you use Picasso change to Glide like this.
Remove picasso
Picasso.get().load(Uri.parse("url")).into(imageView)
Change Glide
Glide.with(context).load("url").into(imageView)
More efficient Glide than Picasso draw to large bitmap
I also had this issue when i was trying to add a splash screen to the android app through the launch_backgrgound.xml . the issue was the resolution. it was too high so the images memory footprint exploded and caused the app to crash hence the reason for this error. so just resize your image using a site called nativescript image builder so i got the ldpi,mdpi and all the rest and it worked fine for me.
I just created directory drawable-xhdpi(You can change it according to your need) and copy pasted all the images to that directory.
This can be an issue with Glide. Use this while you are trying to load to many images and some of them are very large:
Glide.load("your image path")
.transform(
new MultiTransformation<>(
new CenterCrop(),
new RoundedCorners(
holder.imgCompanyLogo.getResources()
.getDimensionPixelSize(R.dimen._2sdp)
)
)
)
.error(R.drawable.ic_nfs_default)
.into(holder.imgCompanyLogo);
}
Try using an xml or a vector asset instead of a jpg or png.
The reason is quite obvious in the exception name itself i.e. the resolution of the resource is too large to render.
You can png to xml using online tools like https://svg2vector.com/ OR add your image to drawable-xxhdpi folder.
Solution for Picasso is add Transformation for resize image.
class ResizeTransformation(private val maxSize: Int) : Transformation {
override fun transform(source: Bitmap?): Bitmap? {
var result:Bitmap? = null
if (source != null) {
var width = source.width
var height = source.height
val bitmapRatio = width.toFloat() / height.toFloat()
if (bitmapRatio > 1) {
width = maxSize;
height = (width / bitmapRatio).toInt()
} else {
height = maxSize;
width = (height * bitmapRatio).toInt()
}
result = Bitmap.createScaledBitmap(source, width, height, true)
source.recycle()
}
return result
}
override fun key() = "resize()"
}
Use:
Picasso.get()
.load(url)
.transform(ResizeTransformation(2400)) //FHD+ resolution
.into(view)
Convert your all png formats into webs format. You can do it by Android Studio.

Hololens application stopping at splash screen

I'm working on a Unity project for Hololens, that uses the camera to capture pictures, send them to a photo recognition API and displays the result. The project works perfectly fine in unity, but not on the emulator/Hololens.
Unfortunately, I wrote a lot of code at once, so i don't know at what point this problem started. The problem show's up after building the project and running it on the Hololens/emulator in Debug mode. On the Hololens, I see the starting window (the one you see after you open any application). After i place it, i see End showing splash screen. on the Output window in Visual Studio, and it just doesn't go any further (but doesn't freeze either, just does nothing).
I don't know where it's coming from, since no exceptions are thrown, but i suspect the camera is the cause. Earlier, i had to comment this line of code:
transform.position = Camera.main.ScreenToWorldPoint(new Vector3((CameraManager.Resolution.width * .5f), (CameraManager.Resolution.height * .5f), 10));
because the function ScreenToWorldPoint was throwing the following exception:
Screen position out of view frustum (screen pos 0.000000, 0.000000, 10.000000) (Camera rect 0 0 0 0)
As you see it says that the Camera rect's size is 0. I even tried directly logging the camera's dimensions to make sure (Debug.Log(Camera.main.pixelWidth + ", " + Camera.main.pixelHeight)), and sure enough, they were (0, 0) on the Hololens/emulator.
I made sure that webcam is supported, and that my camera settings are all set, but that didn't help either.
So i'm not sure if that's the cause of the problem or simply a symptom. And I can't start anywhere since neither the Output nor the Error window show anything wrong. Any help or suggestions would be greatly appreciated.
Thanks for reading!
Edit: Here's the entire output log from beginning to end.
Edit2: I don't know if this is significant, but if I paused execution (in Visual Studio), it always seem to be at Build/ProjectName/App.css => Line 78:
[MTAThread]
static void Main(string[] args)
{
var app = new App();
CoreApplication.Run(app); //<===== Here
}
You might want to check any of your Start() methods. You might have some code that is CPU intensive. Even if it runs smoothly in Unity, doesn't mean it will run easily on HoloLens since their CPU is not powerful.
Also, to avoid any Camera problems, make sur to use the Camera prefab from this
repository :
https://github.com/Microsoft/MixedRealityToolkit-Unity
Those are just some thoughts, hope it helps!
Turns out i didn't enable "Virtual Reality Supported" under Other settings in PlayerSettings. It's really dumb, but i hope this helps someone.

What is correct "Path" usage for startRecordingVideo in distriqt camera ANE?

I'm trying to record a short video using the camera ANE from Distriqt and one of the params for startRecordingVideo() is "path".
I can't figure out what a valid path would be when saving on iOS (and probably Android when I get to it)
Unfortunately the documentation is somewhat lacking...
http://docs.airnativeextensions.com/camera/docs/com/distriqt/extension/camera/Camera.html#startRecordingVideo%28%29
An invalid path stops the device from even starting to record.
OK that was me just having a stupid 5 min...
var file:File = File.applicationStorageDirectory.resolvePath("sample.mp4");
Camera.instance.startRecordingVideo(file.nativePath);

Setting sound output/input

I've been looking all over the web, but I don't know if it is possible: can a Cocoa Mac OS X app change the sound input/output device? If so, how come?
can a Cocoa Mac OS X app change the sound input/output device?
Yes, by setting the relevant Audio System Object property.
If so, how come?
Probably because the user might want to change the default input or output device from within an application, rather than having to jump over to the Sound prefpane before and after or use the Sound menu extra.
I know this is an old post but I've been struggling these days trying to find a way of changing the sound input/output device using code and I finally found how to do it. In case someone else runs into the same problem, here's the answer!
There's a command line utility called SwitchAudio-OSX (https://code.google.com/p/switchaudio-osx/) that allows you to switch the audio source from the terminal. It is open-source and you can find the latest version here: https://github.com/deweller/switchaudio-osx.
Anyway, you can use these lines to change the sound input/output device:
UInt32 propertySize = sizeof(UInt32);
AudioHardwareSetProperty(kAudioHardwarePropertyDefaultInputDevice, propertySize, &newDeviceID); // To change the input device
AudioHardwareSetProperty(kAudioHardwarePropertyDefaultOutputDevice, propertySize, &newDeviceID); // To change the output device
AudioHardwareSetProperty(kAudioHardwarePropertyDefaultSystemOutputDevice, propertySize, &newDeviceID); // To change the system output device
Where newDeviceID is an instance of AudioDeviceID and represents the id of the device you want to select. Also, a list of all available devices can be obtained using this code:
AudioDeviceID dev_array[64];
AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, dev_array);
int numberOfDevices = (propertySize / sizeof(AudioDeviceID));

Adobe Flex 3: can I get TTF/OTF system fonts and embed at runtime?

Adobe Flex 3: can I get TTF/OTF system fonts and embed at runtime?
Hi,
I'm a Stack Overflow noob so please go easy on me.
I've searched all day and found dozens of tutorial/examples on how to use [Embed] metadata or
Flash SWF files but they all tell me to either use a path in the source attrib or a text string in the systemFont attrib. What I want to do is; at runtime get all installed fonts on a given machine, determine which are TTF/OTF, embed them all and offer them in a comboBox. Something along these lines;
public function embedFonts():void{
try{
//get all device and embedded fonts
availableFonts = Font.enumerateFonts(true);
availableFonts.sortOn("fontName", Array.CASEINSENSITIVE);
for each(var thisFont:Font in availableFonts)
{
[Embed(systemFont=thisFont.fontName,
fontName=thisFont.fontName,
mimeType='application/x-font')]
//this bit need to create a unique variable name on each loop
var thisfont:Class;
}
}
catch(error:Error){
//if cant embed it's likely not to be TTF or OTF
//so move on to the next font.
}
}
Does anyone know a way?
Many, many thanks
You can't embed fonts at runtime.
And what would be the point?
Your swf runs on my machine, enumerates fonts on my machine, then embeds them
and offer them back to me? They are installed, use them directly, no need to embed.
So not only that is it not possible, but probably nobody will ever implement such a feature.