I'll explain my situation : I have a UI image, of fixed size, and if clicked it shows a video (like Live Photos). The video could be of every possible resolution and with an AspectRatioFitter and a mask I make the video fill the entire image. In this way only a portion of the video (that match the image resolution) is visible, the rest of it is "cropped", hides. I was wondering if it's possible to actually save to the disk only the visible section of the video, cropping the parts not visible. In the end the goal would be to have the image and the video of the same resolution. Is it possible to do this in Unity?
You can use C# to get video files on your system and crop them at your preferred times and then save them to your preferred folder. I have linked a google search for you that should help you find what you're looking for, try using the videos if you need something visual. Crop a video using C#
Related
The basic Idea is this.
I am writing a text in top of a paused video and I want to take a snapshot of it
but the RenderTargetBitmap api doesnt work with video content and only renders the text with black backround. and the Screencapture api only works with the mobile device family and only renders the video and not the text.
Are there any other way to do this using pure c#?
It is very simple. Draw a text on top of a paused media element and take a screenshot of it and save it to a file, why is it so hard to do this?
It is possible to participate in any manner of data manipulation associated with a MediaElement provided you have a Component that is wired into the Media Extensions video pipeline.
Examples are given in the following links:
https://github.com/mmaitre314/MediaReader
https://code.msdn.microsoft.com/windowsapps/media-extensions-sample-7b466096
The first link provides a fully functional solution.
Hi I answered a similar question here for a similar problem that I encountere writing an UWP app. In my case I needed a snapshot of the UI where could possibily be more than one MediaElement dinamically loaded with a bunch of other elements (Images, texts, ...).
The solution I came up with is not so linear but still working. When I need the snapshot:
I extract the video frame and saved on disk for the time I needed it (you can find how in the other answer I wrote);
I create a new dynamic Image with the saved framed e put on top of the MediaElement in the UI;
Here you can create another "layer" with your text
At this point you can use RenderTargetBitmap to take your snapshot and dispose the Image on the UI. Don't forget to delete the file from disk like I do the first time....
My question is easy: Is it possible to create an animated GIF file from a Windows Phone app (7.8 or 8, or both) using C# ?
I searched on the internet for this and I found these tutorials:
http://bloggingabout.net/blogs/rick/archive/2005/05/10/3830.aspx
http://www.codeproject.com/Articles/11505/NGif-Animated-GIF-Encoder-for-NET
They are really cool and work perfectly for desktop app, but I can't make them work on a Windows Phone app, many classes are unavailable and I can't find a workaround. Is it really impossible to create a GIF file from images on a Windows Phone ? Is it due to the devices limitations ?
Thanks
Ok i don't know how far Ill be able to help. But if you are facing limitations in displaying a gif Image then you can use a nuget package named image tools
Blog for Image tools
And on the other hand if you want to display a number of images then I can suggest a work around. But it will be app specific.
use storyboards or timers to continiously animate an Image object or a Grid back ground.
Creating an image I guess is not possible due to device limitation
still if you have a sprite image
then you can use
<ImageBrush.Transform>
<TranslateTransform X="-380" Y="200" x:Name="tfDieImage"></TranslateTransform>
</ImageBrush.Transform>
Transforms to animate the image at regular intervals by changing the X and Y :)
In fact there is a very interesting way to create animated GIF. It is from VB6 days.
Just create every frame as separate GIF file with same color palette (this is the tricky part). strip GIF header from files except first file and then concatenate them with following magic 0x0021F9.
Animated GIF format is actually an extension to the GIF format so, application does not understand animated GIF can still be able to display first frame. As far as I remember that each frame can have its own color table, but I do not remember how.
The real trick is to create series of images sharing same color palette, which I haven't done it before. I just used this to load animated GIFs.
Why don't you try to do it by yourself? GIF format now is free, so if you need only to create GIF files, you can just implement specification or only part of it.
http://www.w3.org/Graphics/GIF/spec-gif89a.txt
Ok.
I will suggest you one post that shows that how to display a GIF formatted pictures or Animated pictures in windows phone.
Please Refer this link.
Show OR Create the GIF kind Images in windows phone.
This shows that there is like a GIF image but actually there is not a GIF but its a multiple jpeg files Array.
I hope you get the Solution.
Good Luck.
I have tried to approach this problem several ways.
I have a web application that will load a sprite (which is a large jpeg that 'holds' 100 frames. Using the offset of div properties I am able to 'move' the image along so it looks like a movie clip.
This works well.
I need to produce the same on mobile devices.
I have to support Windows Mobile 6.5.
I was using jQuery/ajax to move the sprite image along to stop any flickering of the image within the browser.
Windows mobile 6.5 does not support this.
So, i decided to do a native app using C# Framework 2.0.
I thought about converting the sprite to a mp4 file and playing within a web browser control. but IE on the device will not support html5.
I have been told there is a CAB file from adobe so that I can play flash videos on the IE. But, apart from using ffmpeg to convert these images to a flv there is not much control as to adding menu like pause,stop,play etc when playing the flv file. I have not started any of this by the way i assume that would be the case.
So.. I thought if I download the sprite to the device i could use the graphics object of a picture box and render the rectangle of interest from large sprite to picture box.
I could not download the Sprite and save it to an image though. I get 'out of memory exception'.
I used the OpenNetCF.Drawing as it is supposed to support large files. I still get the error message. I have reduced the size of the image and it will work on about 20 frames.
I would then have to 'stack' these images containing 20 frames and load them up when necessary.
I am beginning to wonder now whether i am doing the right thing?
Is there a different way of trying to achieve what i am trying to achieve that is quicker and more efficient as I have run out of ideas.
If I am OK doing it this way then what is the best way to render images in a picturebox like a video. Memory efficiency says load the image from the file on the device when needed and dispose of it but that would cause 'flickering'. What IS the best way to handle multitude of images on a device?
i have plenty of code I can upload but I was worried the question would look 'messy' as I have tried so many things. I will of course edit/upload the code as required.
Thanks.
I know it is possible to update a live tile in Windows 8 with image and text. But, I wanted to update the tile with a video.
Is it possible? If a video cannot be sent directly, can we break the video into many images and then update?
You cannot add video to the live tiles neither the gif images (you can add gif's but they won't work as intended). Adding video is not allowed since it'll consume lot's of system recourses in the background task. The purpose of live tile's are to show information not content itself so that user can just glance on it and take action if needed.
I've been using DirectShow.NET to interface with a webcam in C# and so far everything has been going smoothly. However, right now I'm working on trying to set up a method to "crop" an image (while it's still being displayed as a webcam preview).
Basically, I'm trying to show some kind of a mostly transparent image on top of the IVideoWindow object. Dealing with transparency in C#, however, has been pretty far from a cakewalk.
So, how can I layer an Image object on top of an IVideoWindow? Thanks!
There are two approaches how to achieve this:
to use a video transformation filter and deliver mixed video to the renderer (that is, picture + your overlay)
or, use VMR's 'mixerbitmap` feature to overlay at presentation time
DirectShow.NET has a sample for the second mentioned above:
Samples\VMR9\BitMapMixer
BitmapMixer is an example of how to draw things over a video using VMR9.
Another sample there:
Samples\Players\DxText
A sample application showing how to superimpose text strings on a datastream. The stream is read from an avi file.
Also discussed many times on MSDN Forums.