x264 encoder properly sets errored state and stops trying to process frames if codec setup fails.

Added a 'nil' setting for x264 profile. Encoder also skips profile setup if CBR is off and CRF is zero (lossless doesn't support profiles)
This commit is contained in:
Zakk 2015-02-15 18:03:04 -05:00
parent 96455ca5b0
commit 1c1ce046c5
2 changed files with 47 additions and 29 deletions

View file

@ -187,7 +187,7 @@
}
if (!_av_codec)
if (!_av_codec && !self.errored)
{
BOOL setupOK;
@ -198,6 +198,8 @@
self.errored = YES;
return NO;
}
} else if (!_av_codec) {
return NO;
}
@ -426,8 +428,17 @@
av_dict_set(&opts, "preset", [x264preset UTF8String], 0);
}
id x264profile = self.profile;
id x264profile = nil;
if (self.use_cbr)
{
x264profile = self.profile;
} else if (self.crf > 0) {
x264profile = self.profile;
}
if (x264profile)
{
av_dict_set(&opts, "profile", [x264profile UTF8String], 0);
@ -451,6 +462,9 @@
if (avcodec_open2(_av_codec_ctx, _av_codec, &opts) < 0)
{
_av_codec_ctx = NULL;
_av_codec = NULL;
NSLog(@"CODEC SETUP FAILED!");
return NO;
}

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14A389" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6250" systemVersion="14C109" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6250"/>
@ -170,11 +170,11 @@ Gw
</tabViewItem>
<tabViewItem label="x264" identifier="1" id="I6I-nX-nIi">
<view key="view" id="AiJ-YZ-cX2">
<rect key="frame" x="10" y="25" width="534" height="241"/>
<rect key="frame" x="0.0" y="0.0" width="554" height="279"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="pTs-Nw-pDR">
<rect key="frame" x="15" y="194" width="42" height="14"/>
<rect key="frame" x="15" y="232" width="42" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Preset" id="7Pv-xf-f1B">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -182,7 +182,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9Lo-yP-Gxg">
<rect key="frame" x="15" y="169" width="35" height="14"/>
<rect key="frame" x="15" y="207" width="35" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Tune" id="Wde-Y8-yjc">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -190,7 +190,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VfV-tz-qXn">
<rect key="frame" x="15" y="144" width="44" height="14"/>
<rect key="frame" x="15" y="182" width="44" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Profile" id="Y3A-cg-eIq">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -198,7 +198,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="6AI-RQ-Ci6">
<rect key="frame" x="15" y="119" width="83" height="14"/>
<rect key="frame" x="15" y="157" width="83" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="VBV Maxrate" id="mA7-EM-qSX">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -206,7 +206,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Lvr-jo-frR">
<rect key="frame" x="15" y="94" width="70" height="14"/>
<rect key="frame" x="15" y="132" width="70" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="VBV Buffer" id="pf5-D9-DXk">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -214,7 +214,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9Ii-DO-WXh">
<rect key="frame" x="15" y="69" width="101" height="14"/>
<rect key="frame" x="15" y="107" width="101" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Keyframe every" id="bG3-Uh-UIG">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -222,7 +222,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2Dp-w8-B2f">
<rect key="frame" x="15" y="44" width="29" height="14"/>
<rect key="frame" x="15" y="82" width="29" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="CRF" id="V2K-4U-Y1S">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -230,7 +230,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="C8M-ea-3sm">
<rect key="frame" x="122" y="66" width="46" height="19"/>
<rect key="frame" x="122" y="104" width="46" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="8kd-R7-qc4">
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" negativeFormat="#" numberStyle="decimal" allowsFloats="NO" usesGroupingSeparator="NO" paddingCharacter="*" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" decimalSeparator="." groupingSeparator="," currencyDecimalSeparator="." plusSign="+" minusSign="-" notANumberSymbol="NaN" perMillSymbol="‰" percentSymbol="%" exponentSymbol="E" positivePrefix="" positiveSuffix="" negativePrefix="-" negativeSuffix="" id="ATI-2b-lju"/>
<font key="font" metaFont="smallSystem"/>
@ -246,7 +246,7 @@ Gw
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Mrd-j9-Vau">
<rect key="frame" x="122" y="41" width="46" height="19"/>
<rect key="frame" x="122" y="79" width="46" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="5ZU-gJ-Hdm">
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" negativeFormat="#" numberStyle="decimal" allowsFloats="NO" usesGroupingSeparator="NO" paddingCharacter="*" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" decimalSeparator="." groupingSeparator="," currencyDecimalSeparator="." plusSign="+" minusSign="-" notANumberSymbol="NaN" perMillSymbol="‰" percentSymbol="%" exponentSymbol="E" positivePrefix="" positiveSuffix="" negativePrefix="-" negativeSuffix="" id="Q6D-l0-e9y"/>
<font key="font" metaFont="smallSystem"/>
@ -263,7 +263,7 @@ Gw
</connections>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hnh-Ur-lnw">
<rect key="frame" x="122" y="91" width="46" height="19"/>
<rect key="frame" x="122" y="129" width="46" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="U2r-Dm-H5f">
<numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" negativeFormat="#" numberStyle="decimal" allowsFloats="NO" usesGroupingSeparator="NO" paddingCharacter="*" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="309" decimalSeparator="." groupingSeparator="," currencyDecimalSeparator="." plusSign="+" minusSign="-" notANumberSymbol="NaN" perMillSymbol="‰" percentSymbol="%" exponentSymbol="E" positivePrefix="" positiveSuffix="" negativePrefix="-" negativeSuffix="" id="WJJ-ij-OI8"/>
<font key="font" metaFont="smallSystem"/>
@ -279,7 +279,7 @@ Gw
</connections>
</textField>
<textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="bVx-zD-QAw">
<rect key="frame" x="122" y="116" width="46" height="19"/>
<rect key="frame" x="122" y="154" width="46" height="19"/>
<constraints>
<constraint firstAttribute="width" constant="46" id="xHh-9V-Yds"/>
</constraints>
@ -298,21 +298,25 @@ Gw
</connections>
</textField>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9TP-kQ-Qdg">
<rect key="frame" x="119" y="139" width="101" height="22"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="hhd-hw-xpk" id="zr8-iK-sWw">
<rect key="frame" x="119" y="177" width="101" height="22"/>
<popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="zr8-iK-sWw">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
<menu key="menu" title="OtherViews" id="w20-Ph-Imn">
<items>
<menuItem title="Item 1" state="on" id="hhd-hw-xpk"/>
<menuItem title="Item 1" id="hhd-hw-xpk"/>
<menuItem title="Item 2" id="tq1-Cf-OmP"/>
<menuItem title="Item 3" id="ttf-nX-Tqt"/>
</items>
</menu>
</popUpButtonCell>
<connections>
<binding destination="8jM-xj-6eG" name="content" keyPath="arrangedObjects" id="pHT-lW-Kwo"/>
<binding destination="TZe-4D-nmN" name="selectedObject" keyPath="selection.profile" previousBinding="pHT-lW-Kwo" id="Uqz-5Y-CvX">
<binding destination="8jM-xj-6eG" name="content" keyPath="arrangedObjects" id="grA-Ik-mBv">
<dictionary key="options">
<bool key="NSInsertsNullPlaceholder" value="YES"/>
</dictionary>
</binding>
<binding destination="TZe-4D-nmN" name="selectedObject" keyPath="selection.profile" previousBinding="grA-Ik-mBv" id="mNL-it-lep">
<dictionary key="options">
<bool key="NSRaisesForNotApplicableKeys" value="NO"/>
</dictionary>
@ -320,7 +324,7 @@ Gw
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="LdZ-gp-IPX">
<rect key="frame" x="119" y="164" width="101" height="22"/>
<rect key="frame" x="119" y="202" width="101" height="22"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Aay-q2-fLb" id="JEa-Kb-0eq">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -347,7 +351,7 @@ Gw
</connections>
</popUpButton>
<popUpButton verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="HRX-AI-IV1">
<rect key="frame" x="119" y="189" width="101" height="22"/>
<rect key="frame" x="119" y="227" width="101" height="22"/>
<popUpButtonCell key="cell" type="push" title="Item 1" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" selectedItem="Hh2-0H-T1O" id="u2T-nK-ZHa">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -374,7 +378,7 @@ Gw
</connections>
</popUpButton>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="zcL-cj-J2t">
<rect key="frame" x="174" y="69" width="55" height="14"/>
<rect key="frame" x="174" y="107" width="55" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="seconds" id="66F-gX-HKW">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -382,7 +386,7 @@ Gw
</textFieldCell>
</textField>
<button fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="BJS-Ym-qhX">
<rect key="frame" x="14" y="19" width="113" height="20"/>
<rect key="frame" x="14" y="57" width="113" height="20"/>
<buttonCell key="cell" type="check" title="Use CBR Mode" bezelStyle="regularSquare" imagePosition="left" controlSize="small" state="on" inset="2" id="8hA-E7-5Qr">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="smallSystem"/>
@ -396,14 +400,14 @@ Gw
</connections>
</button>
<button toolTip="Bitrate is set to value of 'VBV Maxrate'. 'VBV Buffer' is ignored and calculated based on fps and Maxrate. CRF is ignored." horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7JK-UJ-uXM">
<rect key="frame" x="135" y="19" width="25" height="25"/>
<rect key="frame" x="135" y="57" width="25" height="25"/>
<buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" controlSize="small" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="0yh-VG-kgz">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="smallSystem"/>
</buttonCell>
</button>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j1E-1Z-43E">
<rect key="frame" x="15" y="219" width="41" height="14"/>
<rect key="frame" x="15" y="257" width="41" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Name" id="h7S-GC-LRO">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -411,7 +415,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dCi-HU-R17">
<rect key="frame" x="121" y="216" width="96" height="19"/>
<rect key="frame" x="121" y="254" width="96" height="19"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="yAP-a1-yWl">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
@ -426,7 +430,7 @@ Gw
</connections>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="mkc-Ve-Fm7">
<rect key="frame" x="361" y="94" width="66" height="14"/>
<rect key="frame" x="361" y="132" width="66" height="14"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Advanced" id="g2O-hw-6od">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
@ -434,7 +438,7 @@ Gw
</textFieldCell>
</textField>
<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="ESX-nq-ivO">
<rect key="frame" x="271" y="8" width="246" height="78"/>
<rect key="frame" x="271" y="46" width="246" height="78"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="JUv-0t-wCP">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>