From e3b6478a0bcc7648cc8b749c3aedbab1600b9bd7 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 13 Sep 2019 07:43:46 -0400 Subject: [PATCH 1/4] FFmpegReader: Fix hardware device message - Don't precede with two blank lines - "Decodiing" was misspelled - Less cryptic text --- src/FFmpegReader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/FFmpegReader.cpp b/src/FFmpegReader.cpp index c9e21271..dbe49b37 100644 --- a/src/FFmpegReader.cpp +++ b/src/FFmpegReader.cpp @@ -309,7 +309,7 @@ void FFmpegReader::Open() { char *adapter_ptr = NULL; int adapter_num; adapter_num = openshot::Settings::Instance()->HW_DE_DEVICE_SET; - fprintf(stderr, "\n\nDecodiing Device Nr: %d\n", adapter_num); + fprintf(stderr, "Hardware decoding device number: %d\n", adapter_num); // Set hardware pix format (callback) pCodecCtx->get_format = get_hw_dec_format; From 7fc214d803335edf55e8d712f13cb14015886074 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 13 Sep 2019 07:48:57 -0400 Subject: [PATCH 2/4] openshot-example: Path fixes Instead of the hardcoded `/home/jonathan/...` input path, load the input file from TEST_MEDIA_PATH, defined as in `tests/CMakeLists.txt` --- src/CMakeLists.txt | 8 ++++++++ src/examples/Example.cpp | 9 ++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6980dbae..3c46fa97 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -372,6 +372,14 @@ target_link_libraries(openshot ${REQUIRED_LIBRARIES}) # Create test executable add_executable(openshot-example examples/Example.cpp) +# Define path to test input files +SET(TEST_MEDIA_PATH "${PROJECT_SOURCE_DIR}/src/examples/") +IF (WIN32) + STRING(REPLACE "/" "\\\\" TEST_MEDIA_PATH TEST_MEDIA_PATH) +ENDIF(WIN32) +target_compile_definitions(openshot-example PRIVATE + -DTEST_MEDIA_PATH="${TEST_MEDIA_PATH}" ) + # Link test executable to the new library target_link_libraries(openshot-example openshot) diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index eec8d00e..f532408a 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -43,12 +43,15 @@ int main(int argc, char* argv[]) { s->HARDWARE_DECODER = 2; // 1 VA-API, 2 NVDEC s->HW_DE_DEVICE_SET = 0; - FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-720p.mp4"); + std::string input_filepath = TEST_MEDIA_PATH; + input_filepath += "sintel_trailer-720p.mp4"; + + FFmpegReader r9(input_filepath); r9.Open(); r9.DisplayInfo(); /* WRITER ---------------- */ - FFmpegWriter w9("/home/jonathan/metadata.mp4"); + FFmpegWriter w9("metadata.mp4"); // Set options w9.SetAudioOptions(true, "libmp3lame", r9.info.sample_rate, r9.info.channels, r9.info.channel_layout, 128000); @@ -83,4 +86,4 @@ int main(int argc, char* argv[]) { cout << "Completed successfully!" << endl; return 0; -} \ No newline at end of file +} From 918122632cb395382b257e6edd7ad54d98056bf9 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 13 Sep 2019 08:24:15 -0400 Subject: [PATCH 3/4] FFmpegWriter: Source formatting --- src/FFmpegWriter.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/FFmpegWriter.cpp b/src/FFmpegWriter.cpp index 94d03e76..f85e09ad 100644 --- a/src/FFmpegWriter.cpp +++ b/src/FFmpegWriter.cpp @@ -172,7 +172,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i AVCodec *new_codec; // Check if the codec selected is a hardware accelerated codec #if IS_FFMPEG_3_2 - #if defined(__linux__) + #if defined(__linux__) if ( (strcmp(codec.c_str(),"h264_vaapi") == 0)) { new_codec = avcodec_find_encoder_by_name(codec.c_str()); hw_en_on = 1; @@ -194,7 +194,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i hw_en_supported = 0; } } -#elif defined(_WIN32) + #elif defined(_WIN32) if ( (strcmp(codec.c_str(),"h264_dxva2") == 0)) { new_codec = avcodec_find_encoder_by_name(codec.c_str()); hw_en_on = 1; @@ -216,7 +216,7 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i hw_en_supported = 0; } } -#elif defined(__APPLE__) + #elif defined(__APPLE__) if ( (strcmp(codec.c_str(),"h264_videotoolbox") == 0)) { new_codec = avcodec_find_encoder_by_name(codec.c_str()); hw_en_on = 1; @@ -229,9 +229,9 @@ void FFmpegWriter::SetVideoOptions(bool has_video, string codec, Fraction fps, i hw_en_on = 0; hw_en_supported = 0; } -#else // is FFmpeg 3 but not linux + #else // is FFmpeg 3 but not linux new_codec = avcodec_find_encoder_by_name(codec.c_str()); -#endif //__linux__ + #endif //__linux__ #else // not ffmpeg 3 new_codec = avcodec_find_encoder_by_name(codec.c_str()); #endif //IS_FFMPEG_3_2 From ee618a0c5c3d6b0f4c746e5e2c73e4379c4d5854 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 13 Sep 2019 11:22:30 -0400 Subject: [PATCH 4/4] Example.cpp: Finish indentation cleanup --- src/examples/Example.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index f532408a..9e5ee369 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -39,9 +39,9 @@ using namespace openshot; int main(int argc, char* argv[]) { - Settings *s = Settings::Instance(); - s->HARDWARE_DECODER = 2; // 1 VA-API, 2 NVDEC - s->HW_DE_DEVICE_SET = 0; + Settings *s = Settings::Instance(); + s->HARDWARE_DECODER = 2; // 1 VA-API, 2 NVDEC, 6 VDPAU + s->HW_DE_DEVICE_SET = 0; std::string input_filepath = TEST_MEDIA_PATH; input_filepath += "sintel_trailer-720p.mp4"; @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { // Close timeline r9.Close(); - cout << "Completed successfully!" << endl; + cout << "Completed successfully!" << endl; return 0; }