diff --git a/CocoaSplit/Compressor/x264Compressor.m b/CocoaSplit/Compressor/x264Compressor.m index 896aa776..b6579c89 100644 --- a/CocoaSplit/Compressor/x264Compressor.m +++ b/CocoaSplit/Compressor/x264Compressor.m @@ -8,6 +8,8 @@ #import "x264Compressor.h" #import "OutputDestination.h" +#import + @implementation x264Compressor @@ -203,6 +205,9 @@ } + + [self reconfigureCompressor]; + if (frameData.videoFrame) { CVPixelBufferRetain(frameData.videoFrame); @@ -347,12 +352,37 @@ +-(void)reconfigureCompressor +{ + + if (!_av_codec_ctx) + { + return; + } + + _av_codec_ctx->rc_max_rate = self.vbv_maxrate*1000; + + if (!self.use_cbr) + { + _av_codec_ctx->rc_buffer_size = self.vbv_buffer*1000; + + av_opt_set(_av_codec_ctx->priv_data, "crf", [[NSString stringWithFormat:@"%d", self.crf] UTF8String], 0); + + } else { + _av_codec_ctx->rc_buffer_size = self.vbv_buffer*1000; + + _av_codec_ctx->bit_rate = self.vbv_maxrate*1000; + } + +} + -(bool)setupCompressor:(CVPixelBufferRef)videoFrame { avcodec_register_all(); + NSLog(@"IN COMPRESSOR SETUP"); if (!self.settingsController) @@ -361,6 +391,9 @@ } + NSString *useAdvancedSettings = self.advancedSettings.copy; + + [self setupResolution:videoFrame]; _compressor_queue = dispatch_queue_create("x264 encoder queue", NULL); @@ -413,10 +446,17 @@ //what did we learn today? Don't believe shit you read in forum posts... //_av_codec_ctx->rc_buffer_size = ((1/self.settingsController.captureFPS)*self.settingsController.captureVideoAverageBitrate)*1000; - _av_codec_ctx->rc_buffer_size = self.vbv_maxrate*1000; + _av_codec_ctx->rc_buffer_size = self.vbv_buffer*1000; _av_codec_ctx->bit_rate = self.vbv_maxrate*1000; - av_dict_set(&opts, "nal-hrd", "cbr", 0); + + if (!useAdvancedSettings) + { + useAdvancedSettings = [NSString stringWithFormat:@"filler=1"]; + } else { + useAdvancedSettings = [useAdvancedSettings stringByAppendingString:@":filler=1"]; + } + //av_dict_set(&opts, "nal-hrd", "cbr", 0); } _av_codec_ctx->flags |= CODEC_FLAG_GLOBAL_HEADER; @@ -452,11 +492,10 @@ } - id advancedSettings = self.advancedSettings; - if (advancedSettings) + if (useAdvancedSettings) { - av_dict_set(&opts, "x264opts", [advancedSettings UTF8String], 0); + av_dict_set(&opts, "x264opts", [useAdvancedSettings UTF8String], 0); } diff --git a/CocoaSplit/FFMpegTask.m b/CocoaSplit/FFMpegTask.m index cbcb600f..b6005c14 100644 --- a/CocoaSplit/FFMpegTask.m +++ b/CocoaSplit/FFMpegTask.m @@ -320,7 +320,6 @@ void getAudioExtradata(char *cookie, char **buffer, size_t *size) _av_video_stream->time_base.den = self.framerate*1000000; - NSLog(@"FRAMERATE FFMP %d SAMPLE %d BITRATE %d", self.framerate, _samplerate, _audio_bitrate); _av_audio_stream = avformat_new_stream(_av_fmt_ctx, 0); diff --git a/CocoaSplit/Interface/CompressionSettingsPanel.xib b/CocoaSplit/Interface/CompressionSettingsPanel.xib index dbbda923..604e707c 100644 --- a/CocoaSplit/Interface/CompressionSettingsPanel.xib +++ b/CocoaSplit/Interface/CompressionSettingsPanel.xib @@ -161,15 +161,16 @@ Gw - + - + + - + @@ -254,6 +255,11 @@ Gw + + + NSNegateBoolean + + @@ -392,6 +398,11 @@ Gw + + + NSNegateBoolean + + diff --git a/CocoaSplit/en.lproj/MainMenu.xib b/CocoaSplit/en.lproj/MainMenu.xib index 25b09585..5cf5c392 100644 --- a/CocoaSplit/en.lproj/MainMenu.xib +++ b/CocoaSplit/en.lproj/MainMenu.xib @@ -1158,11 +1158,6 @@ - - - NSNegateBoolean - -