🙂by Dave™


Vector video player

What's that? Vector player have huge advantige. Ordinary players play videos raster way but this in vectors. It's big difference in video quality! Result video can be viewed in bigger resolution and with smaller memory space. I ended developing a prototype and find some problems on him. Anyway it's just prototype. All problems will be romoved in another version with name 2.0. Anyway let's see how this prototype works. Video file is Java binary file (video file is called .Vvid). This is how class for this file looks:


package net.byDave.VectorVideoPlayer;

import java.io.Serializable;

public class VideoData implements Serializable{
    public byte[] preview;

    public byte[][] images; //all images data
    public String[] imageType; //image type (.svg)
    public byte[] sounds; //sound data
    public String soundType; // .mp3, .wav, etc.
    public int[] times; //time between frames
    public int[] frames; //position of images
}

This file will be extracted to cache and .html file will be created. This .html file will be seen like video in webview. Comunication with webview is via Javacript and from webview to app via Java.

Raster video converting to vecotor video

Firstly is needed to have video extracted to frames. When are you ready, run following C++ source code (you have to change key word video-name with name of video frames). For right working is reqired to have Linux with via terminal installed Autotrace! Now just compile and run but you have to write behind compiled file while starting mount of frames.


#include<cstdlib>
#include<sstream>
#include<iostream>
#include<iomanip>

using namespace std;

int main(int argc, char* argv[]){
	//starting
	int sum = atol(argv[1]);
	//cout << "sum is: " << sum;

	//info about starting
	system("echo 'Action started!'");

	//variables
	int i = 0;
	//stringstream ss;
	//cout << "ss is: " << ss.str();

	//while loop
	while(i < sum){
		//int i work
		i++;
		stringstream ss;
		ss /*<< setfill('0') << setw(5)*/ << i;

		//actual frame info
		string posinfo = "echo " + ss.str();
		system(&ss.str()[0u]);

		//convert to png
		//string inTerm; inTerm = "convert video-name" + ss.str() + ".jpg" + " video-name" + ss.str() + ".png";
		//system(&inTerm[0u]);

		//convert to svg
		string convert; convert = "autotrace -output-file output" + ss.str() + ".svg -output-format svg --color-count 32 video-name" + ss.str() + ".jpg";
		system(&convert[0u]);

	}//end of loop

	//end program
	system("echo 'Ended!'");
	return 0;
}

Next put all these .svg files put to folder Vvid-Frames. There we have following Java source code to put it all to .Vvid file. You can download it like .jar.


package net.byDave.VectorVideoPlayer;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;

public class main {
	public static void main(String[] args) throws IOException{
		System.out.println("Hello world!");
		ArrayList result = new ArrayList(); //ArrayList cause you don't know how many files there is
        File folder = new File("Vvid-Frames"); //This is just to cast to a File type since you pass it as a String
        File[] filesInFolder = folder.listFiles((File pathname) -> pathname.getName().endsWith(".svg")); // This returns all the folders and files in your path
        for (File file : filesInFolder) { //For each of the entries do:
            if (!file.isDirectory()) { //check that it's not a dir
                result.add(new String(file.getName())); //push the filename as a string
            }
        }
        //System.out.print(result);
        
        //adds images
        VideoData data = new VideoData();
        data.images = new byte[0][0];
        for(int i = 0; i < result.size(); i++){
        	data.images = Arrays.copyOf(data.images, data.images.length+1);
        	data.images[i] = Files.readAllBytes(filesInFolder[i].toPath());
        }
        
        //adds image types
        data.imageType = new String[0];
        for(int i = 0; i < data.images.length; i++){
        	data.imageType = Arrays.copyOf(data.imageType, data.imageType.length+1);
        	data.imageType[i] = ".svg";
        }
        
        //adds sounds
        data.sounds = Files.readAllBytes(Paths.get("Vvid-Frames/sounds.mp3"));
        data.soundType = ".mp3";
        
        //gets framerate
        System.out.print("What's the time between frames? ");
        String framerate = System.console().readLine();
        System.out.print("Selected framerate is: "); System.out.print(framerate); System.out.println("");
        
        //adds framerate
        data.times = new int[0];
        for(int i = 0; i < data.imageType.length; i++){
        	data.times = Arrays.copyOf(data.times, data.times.length+1);
        	data.times[i] = Integer.parseInt(framerate);
        }
        
        //adds order
        data.frames = new int[0];
        for(int i = 0; i < data.times.length; i++){
        	data.frames = Arrays.copyOf(data.frames, data.frames.length+1);
        	data.frames[i] = i;
        }
        
        FileOutputStream fos = new FileOutputStream("out.Vvid");
        ObjectOutputStream os = new ObjectOutputStream(fos);
        os.writeObject(data);
        os.close();
        
        System.out.println(data.images.length);
        System.out.println(data.images[0].length);
        System.out.println(data.images[1].length);
        System.out.println(data.imageType[1]);
        //byte[] btArr = Files.readAllBytes(Paths.get("Vvid-Frames/test.svg"));
        //System.out.println(btArr[1]);
	}
}

Prototype problems

File have to be extracted to chache in uncompressed form and in this form it have incredible size and this will be in RAM too (something about 20GB for 10 min. video).

Version 2.0

Due to problems the developing of prototype have been canceled but in version 2.0 will be everything fixed. Version 2.0 doesn't indicates version of prototype but version of projects itself. Version 2.0 will be done absolutly different way and there will not be any resemblance with this prototype.

Not done things

Compression support (.zVvid)

Video rewinding support

The video progress indicator

Files to download

Player source codeJAR for generating

Copyright for source code on this site and downloadable content

Copyright (c) 2017, David Husička
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
    * Redistributions of source code must retain the above copyright
      notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright
      notice, this list of conditions and the following disclaimer in the
      documentation and/or other materials provided with the distribution.
    * Neither the name of the  nor the
      names of its contributors may be used to endorse or promote products
      derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
(License text source)