Skip to content

Commit 6089ac4

Browse files
authored
Fix MKV hw encode issue (#150)
* Fix MKV hw encode issue * Set global header using C++ API instead of C
1 parent f2de920 commit 6089ac4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

example/api2-samples/api2-hw-encode.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
*
44
* Thanks to https://github.com/mojie126, for more-less complete sample.
55
*
6-
* Known issues: error on the Matroska header writing.
7-
*
86
*/
97

108

@@ -155,6 +153,11 @@ int main(int argc, char **argv) {
155153
encoder.setTimeBase(Rational{1, 1000});
156154
encoder.setBitRate(vdec.bitRate());
157155

156+
// MKV format wants global header, so
157+
// this fixes the issue with MKV container
158+
if (ofrmt.flags() & AVFMT_GLOBALHEADER)
159+
encoder.addFlags(AV_CODEC_FLAG_GLOBAL_HEADER);
160+
158161
encoder.open(Codec(), ec);
159162
if (ec) {
160163
cerr << "Can't opent encodec\n";

0 commit comments

Comments
 (0)