|
|
@@ -311,6 +311,15 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) { |
|
|
encoder->video->flags |= CODEC_FLAG_GLOBAL_HEADER;
|
|
|
#endif
|
|
|
}
|
|
|
+
|
|
|
+ if (encoder->video->codec->id == AV_CODEC_ID_H264 &&
|
|
|
+ (strcasecmp(encoder->containerFormat, "mp4") ||
|
|
|
+ strcasecmp(encoder->containerFormat, "m4v") ||
|
|
|
+ strcasecmp(encoder->containerFormat, "mov"))) {
|
|
|
+ // QuickTime and a few other things require YUV420
|
|
|
+ encoder->video->pix_fmt = AV_PIX_FMT_YUV420P;
|
|
|
+ }
|
|
|
+
|
|
|
if (strcmp(vcodec->name, "libx264") == 0) {
|
|
|
// Try to adaptively figure out when you can use a slower encoder
|
|
|
if (encoder->width * encoder->height > 1000000) {
|
|
|
@@ -320,16 +329,12 @@ bool FFmpegEncoderOpen(struct FFmpegEncoder* encoder, const char* outfile) { |
|
|
} else {
|
|
|
av_opt_set(encoder->video->priv_data, "preset", "faster", 0);
|
|
|
}
|
|
|
- av_opt_set(encoder->video->priv_data, "tune", "zerolatency", 0);
|
|
|
+ if (encoder->videoBitrate == 0) {
|
|
|
+ av_opt_set(encoder->video->priv_data, "crf", "0", 0);
|
|
|
+ encoder->video->pix_fmt = AV_PIX_FMT_YUV444P;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (encoder->video->codec->id == AV_CODEC_ID_H264 &&
|
|
|
- (strcasecmp(encoder->containerFormat, "mp4") ||
|
|
|
- strcasecmp(encoder->containerFormat, "m4v") ||
|
|
|
- strcasecmp(encoder->containerFormat, "mov"))) {
|
|
|
- // QuickTime and a few other things require YUV420
|
|
|
- encoder->video->pix_fmt = AV_PIX_FMT_YUV420P;
|
|
|
- }
|
|
|
avcodec_open2(encoder->video, vcodec, 0);
|
|
|
#if LIBAVCODEC_VERSION_MAJOR >= 55
|
|
|
encoder->videoFrame = av_frame_alloc();
|
|
|
|
0 comments on commit
d6e5bfb