// File: Lut99[P]RayTracer/src/lib/Frames.cpp
// Function: RayTracer::Frames::to_mp4(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void Frames::to_mp4(string path) {
    // If we haven't, write all images to file
    if (!this->dynamic_writing) {
        for (std::size_t i = 0; i <= this->frame_index; i++) {
            this->frames[i]->to_png(this->temp_dir + "/out" + to_string(i) + ".png");
        }
    }

    // Release ffmpeg on the files
    string command = "ffmpeg ";
    command += "-r " + to_string(this->fps);
    command += " -f image2";
    command += " -s " + to_string(this->width) + "x" + to_string(this->height);
    command += " -i \"" + this->temp_dir + "/out%d.png\"";
    command += " -vcodec libx264";
    command += " -crf 25";
    command += " -pix_fmt yuv420p";
    command += " \"" + path + "\"";

    cout << "Running ffmpeg with command: '" + command + "'" << endl;

    int res = system(command.c_str());
    if (res != 0) {
        cerr << "WARNING: ffmpeg run failed." << endl;
    }
}

// Assembly:
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rsi, 0x30(%rsp)
movq %rdi, 0x2b0(%rsp)
movq %rsi, 0x2a8(%rsp)
movq 0x2b0(%rsp), %rax
movq %rax, 0x38(%rsp)
testb $0x1, 0x38(%rax)
jne 0x13a85e
movq $0x0, 0x2a0(%rsp)
movq 0x38(%rsp), %rcx
movq 0x2a0(%rsp), %rax
cmpq 0x10(%rcx), %rax
ja 0x13a85c
movq 0x38(%rsp), %rsi
movq 0x8(%rsi), %rax
movq 0x2a0(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x28(%rsp)
addq $0x18, %rsi
leaq 0x3b8b7(%rip), %rdx     # 0x175fc2
leaq 0x240(%rsp), %rdi
callq 0x13ae30
movq 0x2a0(%rsp), %rsi
leaq 0x220(%rsp), %rdi
callq 0x12e250
jmp 0x13a72f
leaq 0x260(%rsp), %rdi
leaq 0x240(%rsp), %rsi
leaq 0x220(%rsp), %rdx
callq 0x122650
jmp 0x13a74e
leaq 0x3b823(%rip), %rdx     # 0x175f78
leaq 0x280(%rsp), %rdi
leaq 0x260(%rsp), %rsi
callq 0xe6bb0
jmp 0x13a76c
movq 0x28(%rsp), %rdi
leaq 0x280(%rsp), %rsi
callq 0x13bb50
jmp 0x13a780
leaq 0x280(%rsp), %rdi
callq 0xd0b38
leaq 0x260(%rsp), %rdi
callq 0xd0b38
leaq 0x220(%rsp), %rdi
callq 0xd0b38
leaq 0x240(%rsp), %rdi
callq 0xd0b38
movq 0x2a0(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x2a0(%rsp)
jmp 0x13a6cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13a84a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13a83d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13a830
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x280(%rsp), %rdi
callq 0xd0b38
leaq 0x260(%rsp), %rdi
callq 0xd0b38
leaq 0x220(%rsp), %rdi
callq 0xd0b38
leaq 0x240(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae0f
jmp 0x13a85e
leaq 0x1ef(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0xd0a20
movq 0x20(%rsp), %rdx
leaq 0x3b74b(%rip), %rsi     # 0x175fc7
leaq 0x1f0(%rsp), %rdi
callq 0xd8b80
jmp 0x13a88b
leaq 0x1ef(%rsp), %rdi
callq 0xd0630
movq 0x38(%rsp), %rax
movl 0x48(%rax), %esi
leaq 0x1a8(%rsp), %rdi
callq 0x139a70
jmp 0x13a8af
leaq 0x3b6b9(%rip), %rsi     # 0x175f6f
leaq 0x1c8(%rsp), %rdi
leaq 0x1a8(%rsp), %rdx
callq 0x12d820
jmp 0x13a8cd
leaq 0x1f0(%rsp), %rdi
leaq 0x1c8(%rsp), %rsi
callq 0xd0740
jmp 0x13a8e4
leaq 0x1c8(%rsp), %rdi
callq 0xd0b38
leaq 0x1a8(%rsp), %rdi
callq 0xd0b38
leaq 0x3b6ca(%rip), %rsi     # 0x175fcf
leaq 0x1f0(%rsp), %rdi
callq 0xd05a0
jmp 0x13a914
movq 0x38(%rsp), %rax
movl 0x3c(%rax), %esi
leaq 0x128(%rsp), %rdi
callq 0x139a70
jmp 0x13a92b
leaq 0x3b6a8(%rip), %rsi     # 0x175fda
leaq 0x148(%rsp), %rdi
leaq 0x128(%rsp), %rdx
callq 0x12d820
jmp 0x13a949
leaq 0x36bf8(%rip), %rdx     # 0x171548
leaq 0x168(%rsp), %rdi
leaq 0x148(%rsp), %rsi
callq 0xe6bb0
jmp 0x13a967
movq 0x38(%rsp), %rax
movl 0x40(%rax), %esi
leaq 0x108(%rsp), %rdi
callq 0x139a70
jmp 0x13a97e
leaq 0x188(%rsp), %rdi
leaq 0x168(%rsp), %rsi
leaq 0x108(%rsp), %rdx
callq 0x122650
jmp 0x13a99d
leaq 0x1f0(%rsp), %rdi
leaq 0x188(%rsp), %rsi
callq 0xd0740
jmp 0x13a9b4
leaq 0x188(%rsp), %rdi
callq 0xd0b38
leaq 0x108(%rsp), %rdi
callq 0xd0b38
leaq 0x168(%rsp), %rdi
callq 0xd0b38
leaq 0x148(%rsp), %rdi
callq 0xd0b38
leaq 0x128(%rsp), %rdi
callq 0xd0b38
movq 0x38(%rsp), %rdx
addq $0x18, %rdx
leaq 0x3b5da(%rip), %rsi     # 0x175fdf
leaq 0xc8(%rsp), %rdi
callq 0xe3ed0
jmp 0x13aa14
leaq 0x3b5ca(%rip), %rdx     # 0x175fe5
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0xe6bb0
jmp 0x13aa32
leaq 0x1f0(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0xd0740
jmp 0x13aa49
leaq 0xe8(%rsp), %rdi
callq 0xd0b38
leaq 0xc8(%rsp), %rdi
callq 0xd0b38
leaq 0x3b587(%rip), %rsi     # 0x175ff1
leaq 0x1f0(%rsp), %rdi
callq 0xd05a0
jmp 0x13aa79
leaq 0x3b582(%rip), %rsi     # 0x176002
leaq 0x1f0(%rsp), %rdi
callq 0xd05a0
jmp 0x13aa8f
leaq 0x3b575(%rip), %rsi     # 0x17600b
leaq 0x1f0(%rsp), %rdi
callq 0xd05a0
jmp 0x13aaa5
movq 0x30(%rsp), %rdx
leaq 0x3686d(%rip), %rsi     # 0x17131e
leaq 0x88(%rsp), %rdi
callq 0xe3ed0
jmp 0x13aac0
leaq 0x36858(%rip), %rdx     # 0x17131f
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
callq 0xe6bb0
jmp 0x13aade
leaq 0x1f0(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0xd0740
jmp 0x13aaf5
leaq 0xa8(%rsp), %rdi
callq 0xd0b38
leaq 0x88(%rsp), %rdi
callq 0xd0b38
leaq 0x3b507(%rip), %rsi     # 0x17601d
leaq 0x48(%rsp), %rdi
leaq 0x1f0(%rsp), %rdx
callq 0xe3ed0
jmp 0x13ab2a
leaq 0x398fb(%rip), %rdx     # 0x17442c
leaq 0x68(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0xe6bb0
jmp 0x13ab42
movq 0x7143f(%rip), %rdi     # 0x1abf88
leaq 0x68(%rsp), %rsi
callq 0xd0540
movq %rax, 0x18(%rsp)
jmp 0x13ab5a
movq 0x18(%rsp), %rdi
movq 0x713d2(%rip), %rsi     # 0x1abf38
callq 0xd0610
jmp 0x13ab6d
leaq 0x68(%rsp), %rdi
callq 0xd0b38
leaq 0x48(%rsp), %rdi
callq 0xd0b38
leaq 0x1f0(%rsp), %rdi
callq 0xd0220
movq %rax, %rdi
callq 0xd04f0
movl %eax, 0x14(%rsp)
jmp 0x13ab9c
movl 0x14(%rsp), %eax
movl %eax, 0x44(%rsp)
cmpl $0x0, 0x44(%rsp)
je 0x13aded
movq 0x7142a(%rip), %rdi     # 0x1abfe0
leaq 0x3b47f(%rip), %rsi     # 0x17603c
callq 0xd05b0
movq %rax, 0x8(%rsp)
jmp 0x13abc9
movq 0x8(%rsp), %rdi
movq 0x71363(%rip), %rsi     # 0x1abf38
callq 0xd0610
jmp 0x13abdc
jmp 0x13aded
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x1ef(%rsp), %rdi
callq 0xd0630
jmp 0x13ae0f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ae02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ac57
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x1c8(%rsp), %rdi
callq 0xd0b38
leaq 0x1a8(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ad0c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13acff
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13acf2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ace5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x188(%rsp), %rdi
callq 0xd0b38
leaq 0x108(%rsp), %rdi
callq 0xd0b38
leaq 0x168(%rsp), %rdi
callq 0xd0b38
leaq 0x148(%rsp), %rdi
callq 0xd0b38
leaq 0x128(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ad55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0xe8(%rsp), %rdi
callq 0xd0b38
leaq 0xc8(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ad9e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0xa8(%rsp), %rdi
callq 0xd0b38
leaq 0x88(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
jmp 0x13ade1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x218(%rsp)
movl %eax, 0x214(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd0b38
leaq 0x48(%rsp), %rdi
callq 0xd0b38
jmp 0x13ae02
leaq 0x1f0(%rsp), %rdi
callq 0xd0b38
addq $0x2b8, %rsp            # imm = 0x2B8
retq
leaq 0x1f0(%rsp), %rdi
callq 0xd0b38
movq 0x218(%rsp), %rdi
callq 0xd0a10
nopl (%rax)