How do you convert mts video to something Blender can use?

Im currently trying to use Handbrake to convert the mts file to .mkv and then VirtualDub to covert it to an image sequence. Problem is, Virtualdub doesnt allow me to import the format.
How do people use to convert HD .mts files into image sequences that can be imported into blender?

ffmpeg -i "input.mts" -an -f image2 "output_%05d.png"

Does blender not like the .MTS files directly? If not then using ffmpeg to do the conversion probably won’t work as blender also uses ffmpeg and isn’t a particularly good way of doing it.

I don’t understand why you are remuxing to mkv for this but you could use Avisynth with Virtualdub and a DirectShow codec on your Windows machine.

Avisynth will give you better control over levels and interpolation going to RGB image sequences than using ffmpeg on the CLI.

Theres some stuff on the blog in my sig below.

Blender does import mts, but the video is really bad (loads of horizontal streaks) and trying to deinterlace and save as png sequence with the Fields option activated doesnt do much difference.
Hence why Im trying to do this outside Blender. Am I doing something wrong in Blender?

Im not sure how to use:
ffmpeg -i “input.mts” -an -f image2 “output_%05d.png”

But Ill try avisynth in the mean time

So your source is interlaced or is it a bad import by blender? If you deinterlace in the VSE then don’t use fields when rendering out, fields is for rendering out as interlaced not deinterlacing.

Hmm now Im a little confused, when I play the .mts file through a media player, it looks perfect. But when I import it into the sequence editor in Blender is looks interlaced (am I using the right word? there are loads of horizontal stripes that look like the next frame in the video). So it must be a problem with Blender?

Ive looked into avisynth, but I dont understand how to use it.

I cant seem to be able to use virtualdub either with the mts file even though ive installed the directshow plugin, it shows an error:
“Unable to set filename on media detector: hr = 80040200”
Ive managed to covert the file using another software but the quality is much too low and the colours are washed out, so Im at a loss as to what to do.

your media player is almost certainly deinterlacing at playback blender however is probably not, no problem. the decision is whether you want to keep it interlaced and encode back out interlaced for your player to do the deinterlacing at playback which is generally the best approach, or to deinterlace in the vse, its not a problem necessarily with blender other than confusing playback ie not deinterlacing for playback.

Probably best approach is to use the vse, toggle on deinterlace for each strip you add and playback should look ok. Then encode out as progressive, which blender will do for you.

If this still doesnt do it I’m more than happy to give you a step by step with vdub and avisynth. vdub is vfw not directshow, as ffmpeg is working for you then ffmpegsource2 would be a better approach with avisynth but best not confuse with all that if its not really necessay, your washed out levels color is as a result of incorrect conversion

Oh wow! I cant believe that was so easy. I was under the impression there was more to it than that. So basically I didnt realise there was an option window collapsed on the right of the screen which had the de interlace option! Now it makes more sense. Thanks for the help.

I just have another question. I seem to have lost a few pixels at the bottom of the image and the whole thing somtimes becomes a little blurry. Is there a way to fix that?

Make sure your render settings resolution reflect your source files resolution.

If you’re unsure as to exactly what your source files resolution, pixel aspect res and aspect res are, a free application called mediainfo will help.

Blurry could be due to motion, fast panning etc or the fact you’ve lost half the vertical resolution deinterlacing.

Interlaced sources will generally look smoother than progressive created by deinterlacing. Basically interlaced is twice as many ‘frames’ per second 60i instead of 30p for example, but each ‘frame’ or more accurately each ‘field’ displays every other horizontal line, which is why you see regular horizontal gaps on a paused frame in blender as it hadn’t deinterlaced at playback.

This is why I mentioned choice between staying interlaced and letting your player do it or deinterlacing in Blender. The quality of deinterlacing varies with the method used, blenders deinterlacing method is generally reasonable.

This is where using Avisynth could be more beneficial offering a wider choice of methods but they vary in speed and encoding out of an app like virtualdub, or using an avisynth enabled build of ffmpeg with blender importing directly into the VSE or Nodes. Again a little more involved.

Ah I see. Problem is, I dont think the interlaced video is much use for editing/tracking purposes. Im getting problems tracking at the moment because its quite blurry (probably because of the loss in resolution) but it would be worse if there were horizontal gaps everywhere.
How would I use ffmpeg with avisynth to get a better quality progressive footage? I would be grateful if you could give me a step by step.

ok, I’ve always used a deinterlacing plugin for Avisynth called TempGaussBeta2, it was slow but good quality, it’s been updated regularly for over a year now.

You already have Virtualdub installed, next install Avisynth 2.5.8.

Download the QTGMC stuff here http://forum.doom9.org/showthread.php?t=156028 that is the QTGMC script and the plugins pack. Unzip them into your Avisynth plugins directory inside your Avisynth folder wherever that was installed. Make sure all the .dll’s and associated .avsi etc are copied directly in to the avisynth plugins folder rather than sub folders.

Next download ffmpegsource2 plugin beta version r578.7z to decode your MTS files. http://code.google.com/p/ffmpegsource/downloads/list and put the contents in your Avisynth plugins folder and windows ssytem folder as per the instructions within the plugins download.

If you’re not familiar with 7zip archives then you can get it here: http://www.7-zip.org/

Then download and install ffdshowtryouts beta7, http://ffdshow-tryout.sourceforge.net/ and install, choosing to configure each when asked but just except defaults for now, pressing ‘ok’ to each.

The open your favorite text editor and copy paste this in:

FFmpegSource2(“name of your MTS file”)
QTGMC( Preset=“Slow” )

The QTGMC.html file gives further details, if you find ‘Slow’ too slow there are faster presets, but quality will vary obviously.

Save it as an .avs file, example test.avs in the same folder as your source .MTS

Open up Virtualdub and drag/drop or open the .avs file, your video should appear. :slight_smile: Change Vdub to Fast Recompress rather than full processing, choose compression from the menu, choose ffdshow codec (installed earlier) and then lossless h264, then file save .avi.

Hopefully you’ll get a deinterlaced lossless h264 avi out for import into blender.

This may seem like a long winded approach but half of the above installs like ffdshow etc are useful to have period, if all this works for you and the test file is decent quality then it’s quite easy to automate / batch for multiple MTS files etc later.

Hope it works out for you, any problems, shout. :slight_smile:

Thanks for taking the time to explain this. Im having a little trouble though. I couldnt find a folder named Plugins in the avisynth directory so I made one. I followed all the steps but I get this error:

"Avi synth failed to open. script error there is no function named “ffmpegsource2” "

ffmpegsource2 plugin beta version r578.7z had no instructions in it so I just put it all in avisynth plugins folder. Im running windows 64 btw, could there be something thats incompatible?

When you installed Avisynth from the exe it will have made the folder, so say you installed to c program files avisynth 2.5 the plugins folder will be in there, the avisynth script error is probably due to a problem with the path to that plugins folder, try reinstalling Avisynth first, go for the 32bit non MT versions of avisynth and plugins for the time being, they all run fine on 64bit windows.

Most plugins require a LoadPlugin(“path to file”) added to the top of any script but as were using avsi files for ffms2.dll and qtmg then no need. make sure all plugin . dlls are directly in the plugins folder along with any .avsi, or other files bundled in the zips, for the time being anyway, tidy up after.

Great! Avisynth was being weird and not creating a plugins directory. Just reinstalled and now it works. The resulting file is ridiculously large though! 1.3gb from a 21mb file. Ill see how well it will track now.

Haha, modern compression is a wonderfull thing. I think that we have all been fooled into thinkking that HD video = small files. To do any serious work on video clips you need it decompressed as much as you can afford. And the price is space on the HDD.

It seems that Blender is leaving interlace further behind, that is sad. I wonder if you could de-interlace to a a longer frame rate say 30i to 60p fps, so all that temporal information is retained. You would loose the vertical resolution still. Hmmm, it would probably still bounce to much between frames.

Ive come across a strange problem. The frame sequence seems to “jump”. Every few frames, the frames seem to zoom in/jumps to a few frames back, and then suddenly jump forward to the frame it should be on it should normally be on. It does that throughout the footage.
I cant tell whether its simply misplacing frames or if its doing something else.

I cant test the video itself because ive converted it to an image sequence, but looking at the frames and playing them one by one I cant imagine the video being any good if the frames are jumping all over the place.
HD video seems to be one hell of a beast to tame.
Any ideas?

Super high compression is the beast, HD is fine if not so compressed. Sadly you broke the video converting it to I frames (image sequence). It would seem that you have serious decoder issues. I ended up taking my MTS files to Windows Movie Maker (no really). And it worked flawlesly.

@gordon13, ok great to here you’re getting somewhere, yes lossless h264 will be large, thing to establish is the frame jumping a playback problem or a problem with conversion. So in Blender generate proxies for the file at 25%, set timecode to free run. then preview window to 25% you can generate proxies in either the movie editor or on the VSE.

Then see how well it plays. Going image sequences would involve even more disk space. :slight_smile:

We’ve already established that blender / ffmpeg can decode your file, we’re using ffmpeg with Avisynth to decode, if it did turn out an issue with decoding we can simply use DirectShow codec using DirectShowSource in Avisynth and a system codec to decode instead something blender can’t do.

btw lossless h264 decodes fine in blender for me including 10bit which is now supported in ffmpeg.

However utcodec has just been committed to libav so will become available soon as an alternative. :slight_smile:

Hmm Blender doesnt play the avi file :confused: I built proxies but the file doesnt play at all.Yesterday I thought my pc was being slow and not playing the huge file, but now it seems that Blender just doesnt like it.

Ive also tried Movie Maker, it gives relatively good results extremely quickly but when you compare the MTS and the WMV, you can tell the WMV colours look too flat and all the nice things you get from HD video is lost.