Skip to content

Instantly share code, notes, and snippets.

@joncloud
joncloud / ffmpeg_mkv_mp4_conversion.md
Created June 21, 2020 15:56 — forked from jamesmacwhite/ffmpeg_mkv_mp4_conversion.md
Easy way to convert MKV to MP4 with ffmpeg

Converting mkv to mp4 with ffmpeg

Essentially just copy the existing video and audio stream as is into a new container, no funny business!

The easiest way to "convert" MKV to MP4, is to copy the existing video and audio streams and place them into a new container. This avoids any encoding task and hence no quality will be lost, it is also a fairly quick process and requires very little CPU power. The main factor is disk read/write speed.

With ffmpeg this can be achieved with -c copy. Older examples may use -vcodec copy -acodec copy which does the same thing.

These examples assume ffmpeg is in your PATH. If not just substitute with the full path to your ffmpeg binary.

Single file conversion example

using Microsoft.Xna.Framework.Graphics;
public static class GraphicsDeviceExtensions
{
public static Resolution GetScreenResolution(this GraphicsDevice graphicsDevice)
{
var pp = graphicsDevice.PresentationParameters;
return new Resolution(pp.BackBufferWidth, pp.BackBufferHeight);
}
}
using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.File;
using System;
class Program
{
const string ConnectionString = "UseDevelopmentStorage=true";
const string ShareReferenceName = "something";
static void Main(string[] args)
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Threading.Tasks;
namespace ConsoleApp92
{
class Program
{
static void Main(string[] args)
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net48</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1" />
</ItemGroup>
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp66
{
class Program
{
@joncloud
joncloud / 01Results.md
Created January 3, 2020 15:39
ValueType GetHashCode
BenchmarkDotNet=v0.12.0, OS=Windows 10.0.18363
Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=3.1.100
  [Host]     : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT
  DefaultJob : .NET Core 3.1.0 (CoreCLR 4.700.19.56402, CoreFX 4.700.19.56404), X64 RyuJIT

@joncloud
joncloud / ConsoleApp30.csproj
Created December 8, 2019 22:57
MonoGame Console
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
@joncloud
joncloud / Install-AppGetPackage.ps1
Created November 22, 2019 04:33
Sideload Install AppGet Packages
$AppGetCommand = Get-Command -ErrorAction Ignore appget.exe
If ($null -eq $AppGetCommand) {
Throw "AppGet is not installed. Install from https://appget.net/"
}
# PowerShell hack to load the exe as a dll
$DllPath = ($AppGetCommand.Path.Replace('.exe', '.dll'))
If (-not (Test-Path $DllPath)) {
Copy-Item $AppGetCommand.Path $DllPath
}