This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ~/Documents/kotlin/kotlinc/bin/kotlinc -script dedupe.kts -- -d /media/pi | |
import java.io.File | |
require(args.isNotEmpty()) { "kotlinc dedupe.kts [-d] [ROOT FILE PATH]" } | |
val delete: Boolean = args[0] == "-d" | |
val root: File = File(args.last()).canonicalFile | |
require(root.exists() && root.isDirectory) { "Root must exist and be a directory: '$root'" } | |
println("Starting in '$root'") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find ./ -iname '*.VOB' -exec bash -c 'ffmpeg -f mpeg -i "{}" -c:a copy -c:v libx264 -crf 18 "{}".mp4' \; | |
find ./ -iname '*.VOB.mp4' -exec bash -c 'scenedetect -i "{}" -o ./out detect-content -m 120 -t 40 split-video -c' \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ExperimentalCoroutinesApi | |
fun CollectionReference.toFlow(): Flow<DocumentChange> = callbackFlow { | |
val snapshotListener = [email protected] { snapshots, e -> | |
if (e != null) { | |
logger.error { "${[email protected]} listen:error:$e" } | |
cancel(CancellationException("Collection Listener Error in ${[email protected]}", e)) | |
return@addSnapshotListener | |
} | |
for (dc in snapshots!!.documentChanges) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
brew update && brew upgrade | |
pip install --upgrade pip | |
pip install scenedetect[opencv,progress_bar] | |
mkdir out | |
# Optionally tune the threshold, using the content_val column | |
scenedetect -i clip1.mov -o ./out --stats my_video.stats.csv detect-content | |
# Write the files | |
scenedetect -i clip1.mov [...-i clip2.mov] -o ./out detect-content split-video --copy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.benjaminhill.basicbot2 | |
import java.util.concurrent.ThreadLocalRandom | |
/** | |
* From https://geekprompt.github.io/Java-implementation-for-Double-Exponential-Smoothing-for-time-series-with-linear-trend/ | |
* | |
* Performs double exponential smoothing for given time series. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Benjamin Hill [email protected] | |
*/ | |
import mu.KotlinLogging | |
import net.coobird.thumbnailator.Thumbnails | |
import org.bytedeco.javacpp.avutil | |
import org.bytedeco.javacpp.avutil.av_log_set_level | |
import org.bytedeco.javacv.FFmpegFrameGrabber | |
import org.bytedeco.javacv.FFmpegFrameRecorder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.image.BufferedImage | |
import java.awt.image.DataBufferByte | |
import java.awt.image.DataBufferInt | |
/** Lots of alpha blurs looks bad using regular images */ | |
class ManualImage(private val width: Int, private val height: Int) { | |
private val red = IntArray(width * height) | |
private val green = IntArray(width * height) | |
private val blue = IntArray(width * height) | |
private var numAdded = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple 4x speedup, force to 60fps. | |
/c/bin/ffmpeg/bin/ffmpeg.exe -r 60 -i thefile.mkv -vf "tblend=average,framestep=2,tblend=average,framestep=2,setpts=0.25*PTS" -r 60 -c:v mpeg4 -q:v 1 -an thefile_4x.mp4 | |
# Force input to 60fps. blend 16, and pick 1 of each 16. (do we do extra work for the other 15?) Set PTS to 1/16th of "original". Encode very high quality. | |
ffmpeg -r 60 -i molt.mp4 \ | |
-vf "crop=in_h:in_h,tmix=frames=16:weights='1',select='not(mod(n\,16))',setpts=0.0625*PTS" \ | |
-c:v libx265 -crf 18 -an molt16.mp4 | |
# I still like the original. Match the "-r NN" to the source frame rate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.benjaminhill.cameratest | |
import android.Manifest | |
import android.annotation.SuppressLint | |
import android.app.Activity | |
import android.content.Context | |
import android.content.pm.PackageManager | |
import android.graphics.ImageFormat | |
import android.graphics.SurfaceTexture | |
import android.hardware.camera2.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package info.benjaminhill.snailfps | |
import android.content.pm.PackageManager | |
import android.os.Bundle | |
import android.support.v4.app.ActivityCompat | |
import android.support.v4.content.ContextCompat | |
import android.support.v7.app.AppCompatActivity | |
import android.util.Log | |
import android.widget.Toast |
NewerOlder