Add random repeat option to ffmpeg movie player

Fix pause/play state tracking bugs in ffmpeg movie player config dialog.
Properly reset the "is_ready" flag when closing a ffmpeg movie item
Fix potential div0 error in Downmixer
Provide default needsSetup method for compressors
This commit is contained in:
Zakk 2020-04-11 18:22:17 -04:00
parent 55c111f92e
commit ae02cd7d16
8 changed files with 67 additions and 38 deletions

View file

@ -271,15 +271,20 @@
[CATransaction commit];
}];
}
self.durationString = [self timeToString:item.duration];
self.currentMovieDuration = item.duration;
[self generateUniqueID];
self.captureName = item.shortName;
if (self.pcmPlayer)
if (item)
{
self.pcmPlayer.name = item.shortName;
self.durationString = [self timeToString:item.duration];
self.currentMovieDuration = item.duration;
[self generateUniqueID];
self.captureName = item.shortName;
if (self.pcmPlayer)
{
self.pcmPlayer.name = item.shortName;
}
[self changeAttachedAudioInputName:self.uuid withName:item.shortName];
} else {
self.currentTimeString = [self timeToString:0.0f];
}
[self changeAttachedAudioInputName:self.uuid withName:item.shortName];
});
}

View file

@ -20,6 +20,7 @@
// Do view setup here.
if (self.captureObj && self.captureObj.player)
{
[self pauseStateChanged];
self.captureObj.player.pauseStateChanged = ^{
[self pauseStateChanged];
};
@ -220,7 +221,7 @@
-(void)pauseStateChanged
{
dispatch_async(dispatch_get_main_queue(), ^{
if (self.captureObj.player.paused)
if (self.captureObj.player.paused || !self.captureObj.player.playing)
{
NSImage *playImage = [[NSBundle bundleForClass:[self class]] imageForResource:@"play"];

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15400" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15400"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15505"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
@ -23,7 +23,7 @@
<textField verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="vOl-es-UsB">
<rect key="frame" x="35" y="285" width="286" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="aCx-uQ-Hyw">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -46,12 +46,12 @@
<tableColumns>
<tableColumn width="513" minWidth="40" maxWidth="1000" id="Nwb-J9-jgx">
<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
</tableHeaderCell>
<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" title="Text Cell" id="w0V-n1-Avc">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -64,7 +64,7 @@
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="D02-lA-vKn">
<rect key="frame" x="0.0" y="3" width="475" height="14"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" sendsActionOnEndEditing="YES" title="Table View Cell" id="InC-Ai-kHU">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -107,7 +107,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SXP-7Z-utT">
<rect key="frame" x="-2" y="62" width="52" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="4Uo-PT-atT">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -121,7 +121,7 @@
<constraint firstAttribute="width" constant="52" id="dWY-0y-GBb"/>
</constraints>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="geK-QL-6Yn">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -145,15 +145,9 @@
<segments>
<segment image="NSRemoveTemplate"/>
<segment image="rewind" tag="1"/>
<segment image="play">
<nil key="label"/>
</segment>
<segment image="fastforward">
<nil key="label"/>
</segment>
<segment width="268" enabled="NO" tag="4">
<nil key="label"/>
</segment>
<segment image="play"/>
<segment image="fastforward"/>
<segment width="268" enabled="NO" tag="4"/>
</segments>
</segmentedCell>
<connections>
@ -166,7 +160,7 @@
<constraint firstAttribute="width" constant="28" id="Lsw-A7-SMg"/>
</constraints>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Add:" id="p7M-Xi-1dn">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -177,7 +171,7 @@
<constraint firstAttribute="width" constant="48" id="9j3-Jz-aMG"/>
</constraints>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Playing:" id="b9z-O4-d9f">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -185,7 +179,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Taf-5T-FT6">
<rect key="frame" x="54" y="326" width="466" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Label" id="jIY-LY-9hI">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -197,7 +191,7 @@
<rect key="frame" x="324" y="279" width="47" height="27"/>
<buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="VLP-Wp-4UT">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
</buttonCell>
<connections>
<action selector="manualAddItem:" target="-2" id="b7q-4K-5mv"/>
@ -207,7 +201,7 @@
<rect key="frame" x="369" y="279" width="65" height="27"/>
<buttonCell key="cell" type="push" title="Browse" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Vlz-7L-vXD">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
</buttonCell>
<connections>
<action selector="chooseFile:" target="-2" id="upc-a7-d92"/>
@ -217,7 +211,7 @@
<rect key="frame" x="-3" y="37" width="96" height="20"/>
<buttonCell key="cell" type="check" title="Play when live" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="meK-YV-QDR">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
</buttonCell>
<connections>
<binding destination="oEH-Pr-eH8" name="value" keyPath="selection.playWhenLive" id="SP5-JY-yC1"/>
@ -230,7 +224,7 @@
</constraints>
<buttonCell key="cell" type="check" title="Use current position" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="c7q-Ze-6Qj">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
</buttonCell>
<connections>
<binding destination="oEH-Pr-eH8" name="value" keyPath="selection.useCurrentPosition" id="gTJ-ii-Wob"/>
@ -239,7 +233,7 @@
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="IEf-UH-Kgb">
<rect key="frame" x="242" y="39" width="41" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Repeat" id="rDX-h9-STO">
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
@ -251,12 +245,15 @@
</constraints>
<popUpButtonCell key="cell" type="push" title="None" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="UbH-Gg-9jj" id="sQk-jw-qzF">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
<menu key="menu" id="lru-RP-mX3">
<items>
<menuItem title="None" state="on" id="UbH-Gg-9jj"/>
<menuItem title="All" tag="2" id="cg5-NZ-cE9"/>
<menuItem title="Current" tag="1" id="x9J-aD-GCG"/>
<menuItem title="Random" tag="3" id="hyQ-vC-rp9" userLabel="Random">
<modifierMask key="keyEquivalentModifierMask"/>
</menuItem>
</items>
</menu>
</popUpButtonCell>
@ -268,7 +265,7 @@
<rect key="frame" x="-3" y="17" width="139" height="20"/>
<buttonCell key="cell" type="check" title="Deactivate when done" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="13y-lB-coZ">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="controlContent" size="11"/>
<font key="font" metaFont="label" size="11"/>
</buttonCell>
<connections>
<binding destination="oEH-Pr-eH8" name="value" keyPath="selection.deactivateWhenDone" id="NSA-6h-jfT"/>

View file

@ -705,7 +705,7 @@
{
@synchronized (self) {
_stop_request = YES;
_is_ready = NO;
dispatch_semaphore_signal(_read_loop_semaphore);
av_thread_message_queue_set_err_send(_video_message_queue, AVERROR_EOF);

View file

@ -16,7 +16,8 @@
typedef enum ff_movie_repeat_t {
kCSFFMovieRepeatNone = 0,
kCSFFMovieRepeatOne = 1,
kCSFFMovieRepeatAll = 2
kCSFFMovieRepeatAll = 2,
kCSFFMovieRepeatRandom = 3
} ff_movie_repeat;

View file

@ -172,6 +172,8 @@
if (self.repeat == kCSFFMovieRepeatNone || self.repeat == kCSFFMovieRepeatAll)
{
currentIdx++;
} else if (self.repeat == kCSFFMovieRepeatRandom) {
currentIdx = arc4random_uniform(_inputQueue.count);
}
}
@ -638,8 +640,17 @@
CSFFMpegInput *willPlay = nil;
CSFFMpegInput *wasPlaying = self.currentlyPlaying;
if (_audio_done && _video_done)
{
if (wasPlaying)
{
[wasPlaying seek:0.0f];
}
//[self.currentlyPlaying stop];
@ -657,8 +668,17 @@
if (!willPlay && (willPlay != wasPlaying))
{
self.playing = NO;
if (self.pauseStateChanged)
{
dispatch_async(dispatch_get_main_queue(), ^{
self.pauseStateChanged();
});
}
if (self.itemStarted)
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ self.itemStarted(nil);});
}

View file

@ -364,7 +364,7 @@
NSLog(@"Failed to set output volume for channel %d on %@ with status %d", chan, self, err);
}
if (_inputChannels < self.graph.audioFormat.channelCount)
if ((_inputChannels > 0) && _inputChannels < self.graph.audioFormat.channelCount)
{
UInt32 inChan = chan % _inputChannels;
[self setVolume:1.0f forChannel:inChan outChannel:chan];

View file

@ -227,6 +227,11 @@
}
-(bool)needsSetup
{
return NO;
}
-(void)reconfigureCompressor
{