Giter Site home page Giter Site logo

ti.ios.trim's Introduction


This project is not actively maintained. Proceed at your own risk!

(If you're willing to take over, please leave a message at #5)


ti.ios.trim Module

Description

This module extends the Appcelerator Titanium Mobile framework and allows trimming and compressing videos on iOS. This is currently not possible using Titanium's VideoPlayer:

[#TIMOB-1816] iOS: Phone > Record Video, edit/trimming is not shown in playback - Appcelerator JIRA [#TIMOB-4200] iOS - Edit mode on record video returns entire video - Appcelerator JIRA

Getting the module

Find the newest version in the dist folder.

Referencing the module

Simply add the following lines to your tiapp.xml file:

<modules>
    <module platform="iphone" version="0.2">ti.ios.trim</module>
</modules>

Accessing the module

To access this module from JavaScript, you would do the following:

var trimmer = require('ti.ios.trim');

The trimmer variable is a reference to the Module object. a

Reference

trimVideo({Object} options)

options can have the following keys:

  • input
    • the path to video file to be trimmed
    • this has to be either an absolute file path (via file.resolve()) or a path to an object inside the asset library (e.g. using the TiAssetsLibrary Module)
  • quality (optional)
    • the quality of the output video (1 = low, 2 = medium, 3 = high)
    • as an orientation: the example .mp4 file has a size of 15.3 MB and the output file (no trimming, only compression) sizes are the following: 1.12 MB (low), 6.12 MB (medium), 15.26 (high)
  • startTime (optional, default: 0)
    • beginning of the trimmed movie (in seconds)
  • endTime (optional, default: duration of the video file)
    • end of the trimmed movie (in seconds)
  • success
    • callback to be invoked after successful trimming
    • the callback is passed an object that has the following properties:
      • thumbnail: the thumbnail of the video as an image blob
      • videoURL: the path to the trimmed video file
  • error
    • callback to be invoked in case of an error
var inputFile = Ti.Filesystem.getFile('path/to/videoFile');
trimmer.trimVideo({
    input: inputFile.resolve(),
    quality: 1,
    startTime: 0,
    endTime: 10,
    success: function(e) {
        Ti.API.info('SUCCESS:');
        Ti.API.info('path to trimmed file: '+ e.videoURL);
    },
    error: function(e) {
        Ti.API.error('ERROR:');
        Ti.API.info(JSON.stringify(e));
    }
});

Changelog

  • 0.3:
    • adds the thumbnail of the trimmed video to the success callback
  • 0.2:
    • adds an optional quality parameter to compress videos
    • adds support for video files inside the asset library
    • makes startTime and endTime optional
  • 0.1: Initial version

Author

Martin Tietz web: http://www.martin-tietz.com email: [email protected]

License

Copyright (c) 2013 Martin Tietz

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

ti.ios.trim's People

Contributors

inakiabt avatar ludolphus avatar martintietz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ti.ios.trim's Issues

Add a callback for thumbnail creation

Would be very useful if the module could have a callback to get the video thumbnail asynchronously, before the video compression finishes.

For instance, I want to show the thumbnail first and compress a video on background (maybe showing a progress bar).

Could be something like this:

    startProgressBar();

    var trimmer = require('ti.ios.trim');
    trimmer.trimVideo({
        input: temp_file.resolve(),
        quality: 1,
        onThumbnail: function(e){
            showThumbnail(e.thumbnail);
        },
        success: function(e){
            stopProgressBar();
        }
    });

Error trying to trim a video at a length > 10s

I'm trying to get a video from the media gallery, save it to a file and pass that file to the module.

Trimming it from 0 to 10s works, however if I try to put 0-30s it dies with

<Warning>: Error: Error Domain=AVFoundationErrorDomain Code=-11832 "Cannot Open" UserInfo=0x16fc9d30 {NSLocalizedDescription=Cannot Open, NSUnderlyingError=0x180cc410 "The operation couldn’t be completed. (OSStatus error -12431.)", NSLocalizedFailureReason=This media cannot be used.}

Any idea what it could be?
Thank you.

Crash issue - unable to relayout (xib/nib file issue maybe)

It fails to re-layout once the video compression starts.
It says -

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
[DEBUG] : (
[DEBUG] : "<NSLayoutConstraint:0x7a0f67f0 H:|-(34)-MPKnockoutButton:0x7a0f3f70 (Names: '|':_UIBackdropContentView:0x79f765d0 )>",
[DEBUG] : "<NSLayoutConstraint:0x7a0f6860 H:[MPKnockoutButton:0x7a0f3f70]-(34)-MPDetailSlider:0x79f77730>",
[DEBUG] : "<NSLayoutConstraint:0x7a0f6890 H:[MPDetailSlider:0x79f77730]-(34)-UIView:0x79f76a30>",
[DEBUG] : "<NSLayoutConstraint:0x7a0f6820 UIView:0x79f76a30.right == _UIBackdropView:0x79f69530.right>",
[DEBUG] : "<NSLayoutConstraint:0x79f77130 H:|-(0)-[_UIBackdropView:0x79f69530] (Names: '|':MPVideoPlaybackOverlayView:0x79f6a1e0 )>",
[DEBUG] : "<NSLayoutConstraint:0x79f77180 H:[_UIBackdropView:0x79f69530]-(0)-| (Names: '|':MPVideoPlaybackOverlayView:0x79f6a1e0 )>",
[DEBUG] : "<NSLayoutConstraint:0x7a0fa890 H:[MPVideoPlaybackOverlayView:0x79f6a1e0(0)]>",
[DEBUG] : "<NSAutoresizingMaskLayoutConstraint:0x7a0fbd10 h=-&- v=-&- _UIBackdropContentView:0x79f765d0.midX == _UIBackdropView:0x79f69530.midX>",
[DEBUG] : "<NSAutoresizingMaskLayoutConstraint:0x7a0fbd40 h=-&- v=-&- _UIBackdropContentView:0x79f765d0.width == _UIBackdropView:0x79f69530.width>"
[DEBUG] : )
[DEBUG] :
[DEBUG] : Will attempt to recover by breaking constraint
[DEBUG] : <NSLayoutConstraint:0x7a0f6860 H:[MPKnockoutButton:0x7a0f3f70]-(34)-MPDetailSlider:0x79f77730>
[DEBUG] :
[DEBUG] : Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
[DEBUG] : The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
[DEBUG] : 2015-03-12 00:28:10.794 Test1[96568:746442] Unable to simultaneously satisfy constraints.

Looking for a new Maintainer

I won't be able to continue working on ti.ios.trim as I quit using Titanium a while ago.
If anyone wants to take over, just let me know.

Repeated warning log on trimVideo using XCode 6 (iOS 8)

Once I call:

    require('ti.ios.trim').trimVideo({
        input: temp_file.resolve(),
        quality: 2,
        success: options.success,
        error: options.error
    });

the app starts to repeatedly log this:

[INFO]  2014-09-25 15:56:38.143 XXXXXXXXX[24767:224398] Unable to simultaneously satisfy constraints.
[INFO]          Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
[INFO]  (
[INFO]      "<NSLayoutConstraint:0x7fea9710 H:|-(34)-[MPKnockoutButton:0x7feab8d0](LTR)   (Names: '|':_UIBackdropContentView:0x80a0fdf0 )>",
[INFO]      "<NSLayoutConstraint:0x7fea9740 H:[MPKnockoutButton:0x7feab8d0]-(34)-[TrackPosition](LTR)   (Names: TrackPosition:0x80a10610 )>",
[INFO]      "<NSLayoutConstraint:0x7fea9770 H:[TrackPosition]-(34)-[UIView:0x80a10030](LTR)   (Names: TrackPosition:0x80a10610 )>",
[INFO]      "<NSLayoutConstraint:0x7fea93a0 UIView:0x80a10030.right == _UIBackdropView:0x80a0f400.right>",
[INFO]      "<NSLayoutConstraint:0x80a102f0 H:|-(0)-[_UIBackdropView:0x80a0f400]   (Names: '|':MPVideoPlaybackOverlayView:0x80a0f1d0 )>",
[INFO]      "<NSLayoutConstraint:0x80a10360 H:[_UIBackdropView:0x80a0f400]-(0)-|   (Names: '|':MPVideoPlaybackOverlayView:0x80a0f1d0 )>",
[INFO]      "<NSLayoutConstraint:0x7fea2620 H:[MPVideoPlaybackOverlayView:0x80a0f1d0(0)]>",
[INFO]      "<NSAutoresizingMaskLayoutConstraint:0x7fea06e0 h=-&- v=-&- _UIBackdropContentView:0x80a0fdf0.midX == _UIBackdropView:0x80a0f400.midX>",
[INFO]      "<NSAutoresizingMaskLayoutConstraint:0x7fea0710 h=-&- v=-&- _UIBackdropContentView:0x80a0fdf0.width == _UIBackdropView:0x80a0f400.width>"
[INFO]  )
[INFO]
[INFO]  Will attempt to recover by breaking constraint
[INFO]  <NSLayoutConstraint:0x7fea9740 H:[MPKnockoutButton:0x7feab8d0]-(34)-[TrackPosition](LTR)   (Names: TrackPosition:0x80a10610 )>
[INFO]
[INFO]  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
[INFO]  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

My environment:

Titanium SDK
  ✓  latest sdk         installed (v3.4.0.v20140922135716)
  ✓  selected sdk       up-to-date (v3.4.0.v20140922135716)

Mac OS X Environment
  ✓  CLI Tools          installed

iOS Environment
  ✓  Xcode              installed (5.1.1, 6.0.1)
  ✓  iOS SDK            installed (7.1, 8.0)
  ✓  WWDR cert          installed
  ✓  developer cert     installed (4 found)
  ✓  distribution cert  installed (2 found)
  ✓  dev provisioning   installed (12 found)
  ✓  dist provisioning  installed (9 found)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.