Skip to content

Commit

Permalink
continous fps textview updating, metadata experiments
Browse files Browse the repository at this point in the history
  • Loading branch information
mortenjust authored and Morten Just Petersen committed Oct 10, 2015
1 parent 2774657 commit b97806c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
14 changes: 9 additions & 5 deletions droptogif/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,21 @@ class AppDelegate: NSObject, NSApplicationDelegate, FolderWatcherDelegate {
// https://ffmpeg.org/ffmpeg-filters.html#Video-Filters
// of interest, scale (done), fade (esp. alpha? fade=in:0:25:alpha=1,), 9.86 palettegen, paletteuse, 9.124 trim, vignette, zoompan

var filterString = "-vf "
var filters = [String]()
var filterString = ""

// scale
if let p = Preferences().getScalePercentagePref(){ // 55
let r = p/100 // 0.55
let scaleFilter = "scale=iw*\(r):-1"
filterString = "\(filterString) \(scaleFilter)"
filters.append(scaleFilter)
}


return filterString;

for filter in filters {
filterString = "\(filter)" // todo: prepare this for multiple filters
}

return "-vf \(filterString)";
}

func convertFiles(filenames: [String]){
Expand Down
2 changes: 1 addition & 1 deletion droptogif/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@
</slider>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jsy-RR-Q5e">
<rect key="frame" x="270" y="155" width="48" height="22"/>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="24" drawsBackground="YES" id="pNj-JU-YIE">
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" continuous="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="24" drawsBackground="YES" id="pNj-JU-YIE">
<font key="font" metaFont="system"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
Expand Down
5 changes: 3 additions & 2 deletions droptogif/DragReceiverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Cocoa

protocol CircleDropDelegate{
func circleDropDragEntered()
func circleDropDragEntered(filePath:String)
func circleDropDragPerformed(filePath:String)
func circleDropDragExited()
func circleDropUpdated(mouseAt:NSPoint)
Expand All @@ -20,7 +20,8 @@ class DragReceiverView: NSImageView {

override func draggingEntered(sender: NSDraggingInfo) -> NSDragOperation {
Swift.print("HELLO \(getPathFromBoard(sender.draggingPasteboard()))")
delegate?.circleDropDragEntered()
let path = getPathFromBoard(sender.draggingPasteboard())
delegate?.circleDropDragEntered(path)
return NSDragOperation.Copy
}

Expand Down
14 changes: 12 additions & 2 deletions droptogif/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Cocoa
import AVFoundation
import SpriteKit

class ViewController: NSViewController, NSOpenSavePanelDelegate, NSTextViewDelegate, CircleDropDelegate {
Expand Down Expand Up @@ -72,7 +73,6 @@ class ViewController: NSViewController, NSOpenSavePanelDelegate, NSTextViewDeleg


func animateDropInvitationIn(){

waitForDrop.wantsLayer = true
let fadeAnim = CABasicAnimation(keyPath: "opacity")
fadeAnim.duration = 0.3
Expand Down Expand Up @@ -147,13 +147,23 @@ class ViewController: NSViewController, NSOpenSavePanelDelegate, NSTextViewDeleg
scene.hideDragInvite()
}

func circleDropDragEntered() {
func circleDropDragEntered(filePath: String) {
//
print("drag entered vc")
animateDropInvitationOut()
getMetadata(filePath)
scene.showDragInvite()
}

func getMetadata(filePath:String){
let asset = AVURLAsset(URL: NSURL(fileURLWithPath: filePath))
print("##dumping meta:")
for t in asset.tracksWithMediaType(AVMediaTypeVideo) {
print(t.metadata)
}
}


func circleDropDragPerformed(filePath: String) {
// PASSITON
print("drag performed vc, filepath:\(filePath)")
Expand Down
4 changes: 4 additions & 0 deletions droptogif/gifify
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,12 @@ echo "Calling ffmpeg for filename: $filename to temp: $temp with filter: $filter
$ffmpeg -loglevel panic -i "$filename" $filter -r $fps -f image2pipe -vcodec ppm - >> $temp

echo "Calling Convert"
#cat $temp | $convert xc:none -draw "circle 100,100 100,1" -fill +dither -layers Optimize -delay $delay - "${output}.gif"
# cat $temp | $convert +dither -draw "circle 100,100 100,1" -layers Optimize -delay $delay - "${output}.gif"
# cat $temp | $convert +dither -layers Optimize -delay $delay - "${output}.gif"
cat $temp | $convert +dither -layers Optimize -delay $delay - "${output}.gif"


if [ $noupload -ne 1 ]; then
# open -a CloudApp "${output}.gif"

Expand Down

0 comments on commit b97806c

Please sign in to comment.