From 7fc214d803335edf55e8d712f13cb14015886074 Mon Sep 17 00:00:00 2001 From: "FeRD (Frank Dana)" Date: Fri, 13 Sep 2019 07:48:57 -0400 Subject: [PATCH] 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 +}