Skip to content

Instantly share code, notes, and snippets.

dispatch:beforeDispatchLoop
dispatch:beforeDispatch
dispatch:beforeNotFoundAction
dispatch:beforeExecuteRoute
dispatch:afterInitialize
dispatch:afterExecuteRoute
dispatch:afterDispatch
dispatch:afterDispatchLoop
dispatch:beforeException
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
@DusanBrejka
DusanBrejka / mysql-str_split.sql
Last active April 26, 2016 12:24
MySQL - split string to json array (PHP explode equivalent)
# MySQL 5.7.8 or later required
# https://dev.mysql.com/doc/refman/5.7/en/json.html
# Do not use it unless you know exactly what you're doing...
# For noobs - this function will not split your string to multiple rows
DELIMITER //
CREATE DEFINER=`root`@`localhost` FUNCTION `STR_SPLIT`(`delimiter` VARCHAR(255), `input` LONGTEXT) RETURNS text CHARSET utf8
DETERMINISTIC
BEGIN
@DusanBrejka
DusanBrejka / fluent-ffmpeg-custom-args.js
Last active September 21, 2023 06:45
node-fluent-ffmpeg - Execute Custom FFMPEG arguments hack
/*
As at the time of writing this Fluent ffmpeg-API for node.js has not been updated
for years and still does not support custom FFMPEG attributes, the only solutions
are either forking it or resorting to hacks like this one...
Please use it only when fluent does not support more complex arguments
(like generating multi-rendition HLS with all playlists in a single command)
NOTE: this does not support 'progress' event, but you can do it easily by
parsing 'stderr' event with extractProgress method from fluent-ffmpeg/lib/options.js

These are notes while researching a way to convert a browser/website to a stream. This could be used for Facebook Live or for webrecording. TL'DR:

  • I started with Phantomjs - but that didn't support the html5 video tag
  • SlimerJS supports it, but there is no way to record audio directly (though this might come from desktop audio)
  • So I moved to research ffmpeg/X11/XVFB to record it with linux which works
  • But ffmpeg has no easy way to mix streams/overlays to I moved on to OBS with overlay browser support
  • I started researching options OBS in docker and it needed best a GPU , so I move to nvidia-docker
  • And so came across building game servers on EC2/AWS using GPUs and managed to run OBS inside of GPU g2x.large machine
  • I tried streaming to twich , which works great and managed to restream 4K 60FPS youtube on an AWS instance
  • Remote control works through OBS-Remote but OBS has kinda limit in types of features
@DusanBrejka
DusanBrejka / ffmpeg-muxers-to-mimetype.js
Last active August 12, 2020 13:21
FFMPEG - map of muxers to default mime types
// This can generated by executing the command below:
// ffmpeg -muxers -hide_banner | tail -n +5 | cut -d' ' -f4 | xargs -i{} ffmpeg -hide_banner -h muxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parsing the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
const muxer2mime = {
"ac3": "audio/x-ac3",
"adts": "audio/aac",
"aiff": "audio/aiff",
@DusanBrejka
DusanBrejka / ffmpeg-format-to-mimetype.js
Last active November 28, 2023 05:12
FFMPEG - map of formats to default mime types
// INCOMPLETE
// This command will give you list of available FFMPEG formats and their default Mime types
// ffmpeg -formats -hide_banner | tail -n +5 | cut -c5- | cut -d' ' -f1 | xargs -i{} ffmpeg -hide_banner -h demuxer={} | pcregrep -o2 -o4 -M '(Muxer (\w+) )|(Mime type:( .*).)'
// And then parse the output with regex to JSON format in JavaScript for example:
// str.match(/(.*)\n (.*)/gm).map(m => `"${m.replace(/\n /, '": "')}"`).join(',\n');
// Combine the output with MDN - Common MIME types
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// And with IANA:
@DusanBrejka
DusanBrejka / h264-profile-level-id-map
Created February 28, 2023 07:28
H264 profile + level ID map
42000a 1 Baseline
42e00a 1 ConstrainedBaseline
640c0a 1 ConstrainedHigh
64000a 1 High
4d000a 1 Main
42000b 1.1 Baseline
42e00b 1.1 ConstrainedBaseline
640c0b 1.1 ConstrainedHigh
64000b 1.1 High
4d000b 1.1 Main