Skip to content

Instantly share code, notes, and snippets.

@DusanBrejka
DusanBrejka / ffmpeg-format-to-mimetype.js
Last active Oct 19, 2021
FFMPEG - map of formats to default mime types
View ffmpeg-format-to-mimetype.js
// 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 / ffmpeg-muxers-to-mimetype.js
Last active Aug 12, 2020
FFMPEG - map of muxers to default mime types
View ffmpeg-muxers-to-mimetype.js
// 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",
View Reseach Livestream.md

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 / fluent-ffmpeg-custom-args.js
Last active Sep 20, 2021
node-fluent-ffmpeg - Execute Custom FFMPEG arguments hack
View fluent-ffmpeg-custom-args.js
/*
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
@DusanBrejka
DusanBrejka / mysql-str_split.sql
Last active Apr 26, 2016
MySQL - split string to json array (PHP explode equivalent)
View mysql-str_split.sql
# 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
View gist:71ed100c67c77f213830
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
View phalcon-events.list
dispatch:beforeDispatchLoop
dispatch:beforeDispatch
dispatch:beforeNotFoundAction
dispatch:beforeExecuteRoute
dispatch:afterInitialize
dispatch:afterExecuteRoute
dispatch:afterDispatch
dispatch:afterDispatchLoop
dispatch:beforeException