System.IO – Runtime uncompressed Video Import

Hey good day to all of you!

On a current school project I need to import a video (MJPEG Compressed) to Unity3D at runtime.
So I get a video to the “StreamAsset”-Folder in my Unity3D Folder (windows build) and need to import this to my current scene.

So I am not sure how to do this… One idea I think might work is to import the file via System.IO.File (I found via google^^) or the other idea via the WWW Class (www.movie)

But I am not sure how both of them work. The video is a video.avi (MJPEG Compressed) (and if possible I would love to get access to the video and the audio of the file).

So the question. Is it possible with one of those attempts ?

Thank you so much for your support !

using UnityEngine;
using System.Collections;
//http://commons.wikimedia.org/wiki/File:Pentagon_News_Sample.ogg
public class VideoTest : MonoBehaviour {
	public string fileName;
	public Material screen;
	public IEnumerator Start () {
		WWW loader = new WWW("file:///" + Application.dataPath + "/Pentagon_News_Sample.ogg");
		MovieTexture movieTexture = loader.movie;
		while (!movieTexture.isReadyToPlay) {
			yield return null;
		}
		screen.mainTexture = movieTexture;
		audio.clip = movieTexture.audioClip;
		movieTexture.Play();
		audio.Play();
	}
}

That won’t work since Unity only plays .ogg files, not MJPEG.

As for the question, while it would technically be possible to import MJPEG, it would involve writing a plugin to do it, which is of course not trivial. If you can use Ogg Vorbis instead, that will simplify things enormously.

–Eric