Code Monkey home page Code Monkey logo

csvideoreverse's Introduction

CSVideoReverse

A simple Objective-C class for creating a reversed (silent) version of a video file. Reversal occurs in its own thread, input frames are read in passes to reduce memory usage, and a delegate can be called upon completion or error.

Input video

Output video

Usage Example

Create an instance of the class, set any custom reader settings, and call the main method with the inputPath of the video to be reversed, and the outputPath where the finished result will reside:

NSString *inputPath = [[NSBundle mainBundle] pathForResource:@"input" ofType:@"mov"];

// create a path for our reversed output video
NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
outputPath = [documentsPath stringByAppendingFormat:@"/reversed.mov"];

// get instance of our reverse video class
CSVideoReverse *reverser = [[CSVideoReverse alloc] init];
reverser.delegate = self;

// if custom reader settings are desired
reverser.readerOutputSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange], kCVPixelBufferPixelFormatTypeKey, nil];

// now start the reversal process
[reverser reverseVideoAtPath:inputPath outputPath:outputPath];

Then implement the delegate method of the class to get the result:

#pragma mark CSVideoReverseDelegate Methods
- (void)didFinishReverse:(bool)success withError:(NSError *)error {
	if (!success) {
		NSLog(@"%s error: %@", __FUNCTION__, error.localizedDescription);
	}
	else {
		// show the reversed video located at outputPath
	}
}

Example Project

Build the XCode project at example/CSVideoReverse.xcodeproj to see it in action with reverse video playback - you may want to sub in your own .mov or .mp4 file in example/CSVideoReverse/ViewController.m. At some point, I'll add a UIImagePickerController so you can simply choose from Camera Roll instead of having to reference an asset within the app bundle itself.

Licenses

All source code is licensed under the MIT-License.

csvideoreverse's People

Contributors

chrissung avatar jawngee avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.