Friday 7 December 2018

Slice2Video for ChituBox and Shuffle

Download.  (Shuffle Version)
Download. (Selectable X and Y size version)

Usage: Extract the Chitubox zip to a folder, select your compression ratio (lower = less quality, higher = bigger filesize), and FPS (higher FPS = faster playback), click GO, navigate into your extracted folder and give the video file a name. Software will loop through each frame in the preview window, when its done, its done.

Compiled against .net4.5 so old win7 users (why the hell you still on win7?!?!) can use it.

Output Sample Video:

Usage Video:

Code: (compile with reference to sharpavi)
using SharpAvi.Codecs;
using SharpAvi.Output;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Slice2video
{
    public partial class ShuffleSlice2Video : Form
    {
        int X = 2560,
            Y = 1440,
            framerate = 15,
            Quality = 70;

        private void FrameRateBar_Scroll(object sender, EventArgs e)
        {
            framerate = (int)FrameRateBar.Value;
            Flabel.Text = "FrameRate " + framerate + "FPS";
        }

        private void QualityBar_Scroll(object sender, EventArgs e)
        {
            Quality = (int)QualityBar.Value;
            Qlabel.Text = "Quality " + Quality + "%";
        }

        public ShuffleSlice2Video()
        {InitializeComponent();}

        private void button1_Click_1(object sender, EventArgs e)
        {
            string file_name, srcdirectory;         
            var size = new Size(X, Y);
            var file_dialog = new SaveFileDialog()
            {
                Title = "Pick folder with the PNG's, name the output.",
                Filter = "Video Files (*.avi)|*.avi",
                InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
            };

            if (file_dialog.ShowDialog() == DialogResult.OK)
            {
                file_name = file_dialog.FileName;
                srcdirectory = Path.GetDirectoryName(file_name);
                var FileList = Directory.GetFiles(srcdirectory, "*.png", SearchOption.TopDirectoryOnly).ToList();
                var writer = new AviWriter(file_name){FramesPerSecond = framerate,EmitIndex1 = true};
                var encoder = new MotionJpegVideoEncoderWpf(X, Y, Quality);
                var stream = writer.AddEncodingVideoStream(encoder, width: X, height: Y);
                for(int i= 1;i<FileList.Count-2;i++)
                {
                    Bitmap img_save = new Bitmap(srcdirectory+@"\\"+i+".png");
                    img_save.RotateFlip(RotateFlipType.Rotate90FlipNone);
                    pictureBox1.Image = img_save;
                    Application.DoEvents();
                    var buffer = new byte[X * Y * 4];
                    var bits = img_save.LockBits(new Rectangle(0, 0, X, Y), ImageLockMode.ReadOnly, PixelFormat.Format32bppRgb);
                    Marshal.Copy(bits.Scan0, buffer, 0, buffer.Length);
                    img_save.UnlockBits(bits);
                    stream.WriteFrame(true, buffer, 0, buffer.Length);
                    bits = null;
                    img_save.Dispose();
                } 
                writer.Close();
            };
        }
    }
}

1 comment:

  1. Thanks for the cool little software! I try download but the link doesn't works :(

    ReplyDelete