FFmpeg: Support lossless h.264 encoding
Vicki Pfau vi@endrift.com
Sun, 08 Jul 2018 22:44:57 -0700
4 files changed,
17 insertions(+),
19 deletions(-)
M
CHANGES
→
CHANGES
@@ -68,6 +68,7 @@ - GB, GBA Audio: Increase max audio volume
- GB: Fix VRAM/palette locking (fixes mgba.io/i/1109) - GB Video: Darken colors in GBA mode - FFmpeg: Support libswresample (fixes mgba.io/i/1120, mgba.io/b/123) + - FFmpeg: Support lossless h.264 encoding 0.6.3: (2017-04-14) Bugfixes:
M
src/feature/ffmpeg/ffmpeg-encoder.c
→
src/feature/ffmpeg/ffmpeg-encoder.c
@@ -311,6 +311,15 @@ #else
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 @@ av_opt_set(encoder->video->priv_data, "preset", "veryfast", 0);
} 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();
M
src/platform/qt/VideoView.cpp
→
src/platform/qt/VideoView.cpp
@@ -99,7 +99,7 @@ updatePresets();
setPreset({ .container = "MKV", - .vcodec = "PNG", + .vcodec = "h.264", .acodec = "FLAC", .vbr = 0, .abr = 0,@@ -179,7 +179,7 @@
if (m_nativeWidth && m_nativeHeight) { addPreset(m_ui.presetLossless, { .container = "MKV", - .vcodec = "PNG", + .vcodec = "h.264", .acodec = "FLAC", .vbr = 0, .abr = 0,
M
src/platform/qt/VideoView.ui
→
src/platform/qt/VideoView.ui
@@ -256,11 +256,6 @@ <bool>true</bool>
</property> <item> <property name="text"> - <string>PNG</string> - </property> - </item> - <item> - <property name="text"> <string>h.264</string> </property> </item>@@ -352,9 +347,6 @@ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> <property name="suffix"> <string/> - </property> - <property name="minimum"> - <number>200</number> </property> <property name="maximum"> <number>10000</number>@@ -523,7 +515,7 @@ </tabstops>
<resources/> <connections/> <buttongroups> - <buttongroup name="presets"/> <buttongroup name="resolutions"/> + <buttongroup name="presets"/> </buttongroups> </ui>