diff --git a/src/examples/ExampleHtml.cpp b/src/examples/ExampleHtml.cpp index 298d52b4..f315e252 100644 --- a/src/examples/ExampleHtml.cpp +++ b/src/examples/ExampleHtml.cpp @@ -43,18 +43,23 @@ int main(int argc, char* argv[]) { QGuiApplication app(argc, argv); - std::string html_code = "Check out this Text!"; + std::string html_code = R"html(
Check out this HTML!
)html"; - // Create a reader to generate an openshot::Frame containing text - QtHtmlReader r(720, // width - 480, // height - 5, // x_offset - 5, // y_offset - GRAVITY_CENTER, // gravity - html_code, // html - "b { color: #ff0000; }", - "#000000" // background_color - ); + std::string css_code = R"css( + * {font-family:sans-serif; font-size:18pt; color:#ffffff;} + #red {color: #ff0000;} + )css"; + +// Create a reader to generate an openshot::Frame containing text +QtHtmlReader r(1280, // width + 720, // height + -16, // x_offset + -16, // y_offset + GRAVITY_BOTTOM_RIGHT, // gravity + html_code, // html + css_code, // css + "#000000" // background_color + ); r.Open(); // Open the reader @@ -65,7 +70,7 @@ int main(int argc, char* argv[]) { // Set options //w.SetAudioOptions(true, "libmp3lame", r.info.sample_rate, r.info.channels, r.info.channel_layout, 128000); - w.SetVideoOptions(true, "libx264", Fraction(30000, 1000), 720, 480, Fraction(1, 1), false, false, 3000000); + w.SetVideoOptions(true, "libx264", Fraction(30000, 1000), 1280, 720, Fraction(1, 1), false, false, 3000000); w.info.metadata["title"] = "testtest"; w.info.metadata["artist"] = "aaa"; @@ -79,7 +84,7 @@ int main(int argc, char* argv[]) { // Open writer w.Open(); - for (long int frame = 1; frame <= 30; ++frame) + for (long int frame = 1; frame <= 100; ++frame) { std::shared_ptr f = r.GetFrame(frame); // Same frame every time w.WriteFrame(f); diff --git a/src/examples/ExampleHtml.py b/src/examples/ExampleHtml.py index 610176f5..1938f2fe 100755 --- a/src/examples/ExampleHtml.py +++ b/src/examples/ExampleHtml.py @@ -37,17 +37,22 @@ import openshot app = QGuiApplication(sys.argv) -html_code = "Check out this Text!" +html_code = """Check out this HTML!
""" + +css_code = """ + * {font-family:sans-serif; font-size:18pt; color:#ffffff;} + #red {color: #ff0000;} +""" # Create a QtHtmlReader -r = openshot.QtHtmlReader(720, - 480, - 5, - 5, - openshot.GRAVITY_CENTER, +r = openshot.QtHtmlReader(1280, # width + 720, # height + -16, # x offset + -16, # y offset + openshot.GRAVITY_BOTTOM_RIGHT, html_code, - "b { color: #ff0000; }", - "#000000" + css_code, + "#000000" # background color ) r.Open() # Open the reader @@ -57,7 +62,7 @@ r.DisplayInfo() # Display metadata # Set up Writer w = openshot.FFmpegWriter("pyHtmlExample.mp4") -w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 720, 480, +w.SetVideoOptions(True, "libx264", openshot.Fraction(30000, 1000), 1280, 720, openshot.Fraction(1, 1), False, False, 3000000) w.info.metadata["title"] = "testtest" @@ -73,7 +78,7 @@ w.info.metadata["copyright"] = "copyright OpenShot!" w.Open() # Grab 30 frames from Reader and encode to Writer -for frame in range(30): +for frame in range(100): f = r.GetFrame(frame) w.WriteFrame(f)