-
Notifications
You must be signed in to change notification settings - Fork 0
/
FFmpegController.m
136 lines (116 loc) · 4 KB
/
FFmpegController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
//
// FFmpegController.m
// ffmpegGui
//
// Created by Sebastian on 17.09.10.
// Copyright 2010 ICQ: 171680864. All rights reserved.
//
#import "FFmpegController.h"
@implementation FFmpegController
//@synthesize widthFieldIn,heightFieldIn, vBitRateFieldIn, aBitRateFieldIn, aChanFieldIn;
- (id) init {
if (self = [super init]){
self->ffmpeggui = [[FFmpegGui alloc] init];
// Register callback to model
[ffmpeggui setController:self];
}
return self;
}
- (IBAction)transcode:(id)sender {
[ffmpeggui setVideoWidthNew:[widthField intValue]];
[ffmpeggui setVideoHeightNew:[heightField intValue]];
[ffmpeggui setVideoBitRate:[vBitRateField intValue]];
[ffmpeggui setAudioBitRate:[aBitRateField intValue]];
[ffmpeggui setAudioChannel:[aChanField intValue]];
[ffmpeggui startTranscode];
}
//- (IBAction) getVideoPar:(id)sender {
// [ffmpeggui getVideoPar];
//}
- (IBAction)loadFileOpenPanel:(id)sender {
int result;
NSArray *fileTypes = [NSArray arrayWithObjects:
@"mov",@"avi",@"wmv",@"flv",@"mpeg", nil];
NSOpenPanel *oPanel = [NSOpenPanel openPanel];
NSArray *filesToOpen;
NSString *theFileName;
[oPanel setAllowsMultipleSelection:NO];
[oPanel setTitle:@"Choose Video File"];
result = [oPanel runModalForDirectory:NSHomeDirectory() file:nil types:fileTypes];
if (result == NSFileHandlingPanelOKButton) {
filesToOpen = [oPanel filenames];
theFileName = [filesToOpen objectAtIndex:0];
NSLog(@"Open Panel Returned: %@.\n", theFileName);
[ffmpeggui setInVFile:theFileName];
[ffmpeggui getVideoPar];
[self textViewPrint:[NSString stringWithFormat:@"%@\n",theFileName]];
// Display opened filepath
[filenameField setStringValue:theFileName];
}
}
- (IBAction)saveFileSavePanel:(id)sender {
int result;
NSOpenPanel *sPanel = [NSOpenPanel openPanel];
NSString * theFolderName;
[sPanel setAllowsMultipleSelection:NO];
[sPanel setCanChooseFiles:NO];
[sPanel setCanChooseDirectories:YES];
[sPanel setTitle:@"Choose output directory"];
[sPanel setDirectoryURL:[NSURL URLWithString:[NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"]]];
result = [sPanel runModal];
if (result == NSFileHandlingPanelOKButton) {
theFolderName = [[[sPanel URLs] objectAtIndex:0] path];
NSLog(@"Save Panel Returned: %@.\n", theFolderName);
[ffmpeggui setOutVFile:theFolderName];
[self textViewPrint:[NSString stringWithFormat:@"Output folder: %@\n",theFolderName]];
// Display opened filepath
[folderNameField setStringValue:theFolderName];
[pathControlPath setURL:[[sPanel URLs] objectAtIndex:0]];
}
}
- (IBAction) interruptTranscode:(id)sender {
[ffmpeggui terminateTransTask];
}
- (void) awakeFromNib {
NSString* theFolderName = [NSHomeDirectory() stringByAppendingPathComponent:@"Desktop"];
NSCalendarDate *now = [NSCalendarDate calendarDate];
[self textViewPrint:[NSString stringWithFormat:@"%@\n",now]];
[widthField setIntegerValue:[ffmpeggui videoWidthStd]];
[heightField setIntegerValue:[ffmpeggui videoHeightStd]];
[vBitRateField setIntegerValue:512];
[aBitRateField setIntegerValue:96];
[aChanField setIntegerValue:2];
// Set default output directory
[pathControlPath setURL:[NSURL URLWithString:theFolderName]];
[ffmpeggui setOutVFile:theFolderName];
}
- (void) textViewPrint:(NSString*) string {
[textView setEditable:YES];
[textView setContinuousSpellCheckingEnabled:NO];
[textView insertText:string];
[textView setEditable:NO];
}
- (void) taskStarted {
[progressBar startAnimation:self];
}
- (void) taskFinished {
[progressBar stopAnimation:self];
}
- (IBAction) openPreferences:(id)sender {
;
}
- (IBAction) openAbout:(id)sender {
;
}
- (void) setFormatProperties:(NSArray*)propertyArray {
NSMutableString *trackFormatStr = [NSMutableString string];
NSEnumerator *enumerator = [propertyArray objectEnumerator];
id anStringObject;
while (anStringObject = [enumerator nextObject]) {
[trackFormatStr appendFormat:@"%@", anStringObject];
}
[inFileProperties setEditable:YES];
[inFileProperties setStringValue:trackFormatStr];
[inFileProperties setEditable:NO];
}
@end