MLT messing up the orientation of video - mlt

MLT is automatically changing the orientation of a portrait video to landscape. Is there a way to prevent it?

The real problem is that it is NOT auto-rotating your video. On a smartphone, the video is actually recorded in landscape mode, and then it sets metadata in the file to describe the orientation. If software does not read this and apply some transformation to rotate the video, then it appears incorrect. FFmpeg and then MLT only recently started to support this metadata and automatically do transformations. Obviously, FFmpeg came first, but it took a while for MLT, which only recently added support for it as of v6.2.0. If you have that version and built against recent enough FFmpeg, then it will work automatically. If you run melt some-video -consumer xml then you will see some metadata like
<property name="meta.media.0.codec.rotate">90</property>
In case you want to prevent automatic orientation, set the autorotate property to 0:
melt myvideo autorotate=0

Related

MediaElement plays video, but no video shows

I can open a video, play it and get position and set position, but nothing shows up in the video window on one pc. The code works fine a on a couple of PCs, but doesn't work on another. Does any one know or can refer me to what files I need to properly run MediaElement on XP pro.
Thanks,
Rob
You need at least Windows Media Player 10 or above to be able to use MediaElement properly. A default installation of Win XP doesn't include that. Vista and Win 7 does, however.
What media files you are trying to playback? To play the non just wmv files in WPF you need to have a codecs installed.
Your behavior is very strange and I have similar problem but only when WPF player have been played for a many hours and video renderer stops render the video w/o any error reporting.
I could advise you to install the codecs (or re-install, if you have them already installed). Try to use ffdshow + Haali Media Splitter. This combination allows me to play any media type. And do not install the K-Lite Codec Pack, seems I have my own problem with freezing media because of using it.

Getting Bitmap for First Frame of AVI in Silverlight

I was wondering if there was a way to programmatically retrieve the first frame of an AVI and get a bitmap image to show the user a preview. The MediaControl in Silverlight shows a preview for Silverlight supported video files but not AVI. Because I'm in a Silverlight environment I cannot use unmanaged code or libraries to do so. I only have access to the filestream.
The Silverlight runtime doesn't have support for AVI files natively so you won't be able to use those with the MediaElement.
What you would need to do is actually parse the AVI file by hand and pull out frames from that file. Once you get to the point where you are parsing frames, it potentially gets a little trickier.
If you plan on having this work on Silverlight 2, your AVI file would need to contain WMV frames or frames in one of Silverlight's supported image formats(JPG or PNG). If you were working with WMV, I would set up a MediaStreamSource and pass in the desired video frame to the MediaStreamSource as my first sample. If you are working with one of the image formats you should use Image and set its source to a stream. You can see an example where Joe Stegman has used this to help Silverlight 2 support non-native image formats.
If you were doing this in Silverlight 3 (it's in Beta right now) the techniques are generally the same but the media format support grows a bit to include (in addition to WMV): H264, Raw YV12, or Raw ARGB frames. Similarly on the imaging front, you now have the WriteableBitmap which you could use to draw your frame.
If your video is something like Theora, Divx, Xvid, VP6, etc. You would need to find a way to decode that frame so you could display it in Silverlight.
Similar question has been posted on the Silverlight forum. The forum thread includes code samples.
You might want to pick a frame further into the video since the first few frames might fade in, or not be very representative of the video.
Depending on the encoding, your AVI files might not be readable by the MediaPlayer class. (See here for compatible encodings). You might need to transcode the video to do this with managed code. Unless you find/write your own decoder.

Need example of Flex or silverlight application that enables interactive drawing on a video

I am trying to evaluate which technology is best for my needs.
I need to display a video I get from some remote device, and let a user
interactively draw on it lines, polygons etc.
I searched and couldn't find any existing applications with this ability
(all the flash applications only displayed video).
Could anyone point me to such an application?
I haven't seen a specific app that allows you to do that, but I can tell you it would be fairly trivial to build it in Flex. You would simply create a transparent Sprite over the video clip, then use the Drawing API bound to various mouse events to do your drawing.
The final image can be saved by using BitmapData.draw() over the container that holds both the video and the canvas, and you can pass a bytearray encoded as PNG or JPG to a server-side script to save it.
I can't speak to Silverlight as I've never used it - but a Flex dev could build a basic sample of this for you in Flex in about 20 mins just as a proof of concept.
Where does your expertise lie?
Silverlight you could knock up a proof of concept rather easily and as Myk points out you could do the same in Flex. So your best bet is really whichever technology your current expertise lies in.
In Silverlight you could use a InkPresenter control above a MediaElement control in about 2 minutes up and running with a video file.
I think the hard part is finding a way to display realtime video from your specific device.
Silverlight supports streaming video so having that device talk with Windows Media Server or Silverlight Streaming sounds like the best bet.
Julie Lerman wrote an Silverlight app that you can draw on Images:
http://thedatafarm.com/blog/tablet/drawing-in-silverlight-article-in-msdn-magazine/
the article was presented at a magazine:
http://msdn.microsoft.com/en-us/magazine/cc721604.aspx
Hopes this helps.

Issue using WPF MediaElement with HD (H.264, 720P) Video

I am using media element to render video in WPF. All videos are working fine except H.264 videos. They have some stuttering problem while they are rendered on screen. My machine configuration is much more than the recommended requirement to play for this video. Another surprising fact is that the video renders perfectly fine when I play this in Window Media Player or any other player.
Any solution or any alternative to MediaElement?
You can try my MediaUriElement from my open source project here: http://wpfmediakit.codeplex.com
It has better media compatibility than MediaElement, but if it's a decoder filter problem or a performance problem, my project won't be able to help. What h264 codec are you using. You may want to try out ffdshow from http://ffdshow-tryout.sourceforge.net/.
-Jer
WPF does not support H.264 videos

How to transform a XAML/WPF file to a video (AVI, WMV, etc.)

I have a simple WPF (XAML) file that has some animated shapes and text. The animation has no interactive behavior. I want to record this animation as a video file that I later intend to use as the "intro" screen to a screencast.
What I think I need: C# code that takes an input XAML file and spits out a high quality WMV at (for example at 24fps).
Possible alternatives I have investigated already
Record with screen recording software like Camtasia Studio. This works but the animations are not as smooth especially when the animation has a lot of transitions or movement
Use hardware like DVI2USB by Epiphan Systems. Costs too much; haven't tried it.
Record TV output (S-Video, etc.) using a DVR Card - Low quality and low-resolution.
Update on Oct 28 2008 - working source code
This blog post has a full working source code example of exporting WPF/XAML as an AVI. It's not as fast as I would like but it works for my needs:
link to MSDN blog bost
Render frames with RenderTargetBitmap, then encode with codec of your choice. Not very fast, but 24 fps are achievable on regular PC. We use similar technique to feed video stream from new WPF indicators to legacy bitmap system. There might be a better solution, but it works.
I also heard of a solution with pulling rendered frame from DirectX buffers which WPF uses internally which works much faster than RenderTargetBitmap, but it seemed too unreliable to use in a production system
Update: it seems you don't need real-time, so RenderTargetBitmap should works without any problems.

Resources