Skip to content

Instantly share code, notes, and snippets.

View joe-oli's full-sized avatar
💭
what the flock? no status to report, i am not a facebook junkie.

joe-oli

💭
what the flock? no status to report, i am not a facebook junkie.
View GitHub Profile
@joe-oli
joe-oli / gist:9f110090d682353d3013ab31fa417dc3
Created July 3, 2022 09:26 — forked from eviltester/gist:7beef92896fdd8b638656f996fac38c0
Convert videos into subtitled sections using ffmpeg
# Create a new caption file
~~~~~~~~
ffmpeg -i captions.srt captions.ass
~~~~~~~~
# Add subtitles to main video without changing it
~~~~~~~~
ffmpeg -i video.mp4 -vf "subtitles=captions.ass:force_style='OutlineColour=&H80000000,BorderStyle=4,Outline=1,Shadow=0,MarginV=20'" subtitled-video.mp4
@joe-oli
joe-oli / promises.js
Created December 31, 2021 06:27 — forked from santisbon/promises.js
Promises example based on Mozilla Developer Network documentation
/*jslint devel: true, browser: true, es5: true */
/*global Promise */
var promiseCount = 0;
function testPromise() {
'use strict';
promiseCount += 1;
var thisPromiseCount = promiseCount;
@joe-oli
joe-oli / XMLHttpRequestPromise.js
Created December 31, 2021 06:27 — forked from santisbon/XMLHttpRequestPromise.js
Shows the implementation of a method which uses a Promise to report the success or failure of an XMLHttpRequest. Based on Mozilla Developer Network documentation.
/*jslint devel: true, browser: true, es5: true */
/*global Promise */
// $http function is implemented in order to follow the standard Adapter pattern
function $http(url) {
'use strict';
var core = {
// Method that performs the ajax request
ajax : function (method, url, args) {
@joe-oli
joe-oli / XMLHttpRequestLoadImagePromise.js
Created December 31, 2021 06:27 — forked from santisbon/XMLHttpRequestLoadImagePromise.js
Using XMLHttpRequest to load an image in a promise. Based on Mozilla Developer Network documentation.
/*jslint devel: true, browser: true, es5: true */
/*global Promise */
function imgLoad(url) {
'use strict';
// Create new promise with the Promise() constructor;
// This has as its argument a function with two parameters, resolve and reject
return new Promise(function (resolve, reject) {
// Standard XHR to load an image
var request = new XMLHttpRequest();
@joe-oli
joe-oli / search-own-gists.txt
Created December 31, 2021 06:12
Search my own gists (search by username)
user:joe-oli ffmpeg
@joe-oli
joe-oli / WaitForExitAsync.cs
Last active December 9, 2021 12:46
C# Process WaitForExit
/// <summary>
/// Waits asynchronously for the process to exit.
/// </summary>
/// <param name="process">The process to wait for cancellation.</param>
/// <param name="cancellationToken">A cancellation token. If invoked, the task will return
/// immediately as canceled.</param>
/// <returns>A Task representing waiting for the process to end.</returns>
public static Task WaitForExitAsync(this Process process,
CancellationToken cancellationToken = default(CancellationToken))
{
@joe-oli
joe-oli / ProcessHelper.cs
Created December 9, 2021 11:58 — forked from AlexMAS/ProcessHelper.cs
The right way to run external process in .NET
public static class ProcessHelper
{
public static ProcessResult ExecuteShellCommand(string command, string arguments, int timeout)
{
var result = new ProcessResult();
using (var process = new Process())
{
process.StartInfo.FileName = command;
process.StartInfo.Arguments = arguments;
@joe-oli
joe-oli / ProcessAsyncHelper.cs
Created December 9, 2021 11:56 — forked from AlexMAS/ProcessAsyncHelper.cs
The right way to run external process in .NET (async version)
using System;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
public static class ProcessAsyncHelper
{
public static async Task<ProcessResult> ExecuteShellCommand(string command, string arguments, int timeout)
{
var result = new ProcessResult();
----------------------------------------------------------------------------------------------------------------------------------
Converting a series of jpeg images to a mp4 video:
ffmpeg.exe -f image2 -r 3 -i %06d.jpeg -r 15 -vcodec mpeg4 -s 352x240 Camera-0.avi
-f image2 => input format
-r 3 => input framerate
-i %06d.jpeg => input mask (files must be named sequencially, with 6 digits. Ex: "000000.jpeg", "000001.jpeg", "000002.jpeg", etc)
-vcodec mpeg4 => video output codec
-s 352x240 => resolution
@joe-oli
joe-oli / break-command-multiple-lines.txt
Created December 5, 2021 17:24
Windows cmd or bat file - Break command across multiple lines
@REM bin\ffprobe -v quiet -print_format json -show_format -show_streams^
@REM "D:\path\to\myfile.mp4"
bin\ffprobe -v quiet -show_streams^
"D:\path\to\myfile.mp4"
@REM *** NOTE THE USE OF THE carret^ at the end of the line you wish to continue ***