diff --git a/src/examples/Example.cpp b/src/examples/Example.cpp index 17550648..df218dd7 100644 --- a/src/examples/Example.cpp +++ b/src/examples/Example.cpp @@ -37,23 +37,24 @@ using namespace tr1; int main(int argc, char* argv[]) { - // Create a timeline Timeline r9(640, 480, Fraction(30, 1), 44100, 2, LAYOUT_STEREO); - r9.SetJson("{\"settings\": {}, \"clips\": [{\"perspective_c2_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"alpha\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"rotation\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"location_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"gravity\": 4, \"start\": 0, \"scale\": 1, \"scale_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"title\": \"MAH04194.MP4\", \"image\": \".openshot_qt\\\\thumbnail\\\\RW78V6EM7H.png\", \"perspective_c4_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"volume\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"duration\": 11.02933311462402, \"perspective_c1_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"effects\": [], \"waveform\": false, \"wave_color\": {\"green\": {\"Points\": [{\"handle_right\": {\"X\": 1.0, \"Y\": 123.0}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 1.0, \"Y\": 123.0}, \"handle_left\": {\"X\": 1.0, \"Y\": 123.0}}]}, \"blue\": {\"Points\": [{\"handle_right\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_left\": {\"X\": 1.0, \"Y\": 255.0}}]}, \"alpha\": {\"Points\": [{\"handle_right\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_left\": {\"X\": 1.0, \"Y\": 255.0}}]}, \"red\": {\"Points\": [{\"handle_right\": {\"X\": 1.0, \"Y\": 0.0}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 1.0, \"Y\": 0.0}, \"handle_left\": {\"X\": 1.0, \"Y\": 0.0}}]}}, \"layer\": 0, \"position\": 0, \"perspective_c4_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"anchor\": 0, \"perspective_c3_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"crop_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"crop_width\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"crop_height\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"shear_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"shear_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"end\": 11.02933311462402, \"file_id\": \"RW78V6EM7H\", \"perspective_c1_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"id\": \"L9S44F9NPE\", \"perspective_c2_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"perspective_c3_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"reader\": {\"sample_rate\": 48000, \"duration\": 11.02933311462402, \"interlaced_frame\": false, \"video_stream_index\": 0, \"acodec\": \"aac\", \"video_bit_rate\": 12176893, \"pixel_format\": 0, \"top_field_first\": true, \"file_size\": \"16804113\", \"type\": \"FFmpegReader\", \"has_video\": true, \"audio_timebase\": {\"num\": 1, \"den\": 48000}, \"path\": \"\\\\Users\\\\Jonathan\\\\Videos\\\\MAH04194.MP4\", \"fps\": {\"num\": 25, \"den\": 1}, \"channel_layout\": 3, \"audio_bit_rate\": 127391, \"vcodec\": \"h264\", \"display_ratio\": {\"num\": 16, \"den\": 9}, \"video_length\": \"276\", \"has_audio\": true, \"audio_stream_index\": 1, \"video_timebase\": {\"num\": 1, \"den\": 25000}, \"has_single_image\": false, \"width\": 1440, \"height\": 1080, \"channels\": 2, \"pixel_ratio\": {\"num\": 4, \"den\": 3}}, \"time\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"scale_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"crop_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"location_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}}], \"id\": \"T0\", \"sample_rate\": 44100, \"duration\": 300, \"layers\": [{\"number\": 0, \"id\": \"L4\", \"label\": \"\", \"y\": 0}], \"fps\": {\"num\": 24, \"den\": 1}, \"export_path\": \"\", \"scale\": 16, \"channel_layout\": 3, \"version\": {\"openshot-qt\": \"2.0.5\", \"libopenshot\": \"0.0.9\"}, \"tick_pixels\": 100, \"files\": [{\"sample_rate\": 48000, \"duration\": 11.02933311462402, \"interlaced_frame\": false, \"media_type\": \"video\", \"acodec\": \"aac\", \"video_bit_rate\": 12176893, \"pixel_format\": 0, \"top_field_first\": true, \"file_size\": \"16804113\", \"channels\": 2, \"has_single_image\": false, \"has_video\": true, \"id\": \"RW78V6EM7H\", \"audio_timebase\": {\"num\": 1, \"den\": 48000}, \"path\": \"\\\\Users\\\\Jonathan\\\\Videos\\\\MAH04194.MP4\", \"fps\": {\"num\": 25, \"den\": 1}, \"channel_layout\": 3, \"audio_bit_rate\": 127391, \"vcodec\": \"h264\", \"display_ratio\": {\"num\": 16, \"den\": 9}, \"video_length\": \"276\", \"has_audio\": true, \"audio_stream_index\": 1, \"video_timebase\": {\"num\": 1, \"den\": 25000}, \"type\": \"FFmpegReader\", \"width\": 1440, \"height\": 1080, \"video_stream_index\": 0, \"pixel_ratio\": {\"num\": 4, \"den\": 3}}], \"playhead_position\": 0, \"width\": 1920, \"effects\": [{\"brightness\": {\"Points\": [{\"handle_right\": {\"X\": 96.5999984741211, \"Y\": 1}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 1, \"Y\": 1}, \"handle_left\": {\"X\": 1, \"Y\": 1}}, {\"handle_right\": {\"X\": 240, \"Y\": -1}, \"handle_type\": 0, \"interpolation\": 0, \"co\": {\"X\": 263.04, \"Y\": -1}, \"handle_left\": {\"X\": 144.3999938964844, \"Y\": -1}}]}, \"end\": 10.96, \"contrast\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1, \"Y\": 3}}]}, \"layer\": 0, \"replace_image\": false, \"id\": \"YDKTU9SEM4\", \"start\": 0, \"position\": 0, \"reader\": {\"sample_rate\": 0, \"duration\": 86400.0, \"interlaced_frame\": false, \"acodec\": \"\", \"video_bit_rate\": 0, \"pixel_format\": -1, \"top_field_first\": true, \"file_size\": \"1658880\", \"channels\": 0, \"has_single_image\": true, \"has_video\": true, \"audio_timebase\": {\"num\": 1, \"den\": 1}, \"path\": \"C:\\\\Users\\\\Jonathan\\\\Apps\\\\openshot-qt-git\\\\src\\\\transitions\\\\common\\\\circle_out_to_in.svg\", \"fps\": {\"num\": 30, \"den\": 1}, \"channel_layout\": 4, \"audio_bit_rate\": 0, \"vcodec\": \"\", \"display_ratio\": {\"num\": 5, \"den\": 4}, \"video_length\": \"2592000\", \"has_audio\": false, \"audio_stream_index\": -1, \"video_timebase\": {\"num\": 1, \"den\": 30}, \"type\": \"QtImageReader\", \"width\": 720, \"height\": 576, \"video_stream_index\": -1, \"pixel_ratio\": {\"num\": 1, \"den\": 1}}, \"type\": \"Mask\", \"title\": \"Transition\"}], \"progress\": [], \"profile\": \"HD 1080p 24 fps\", \"markers\": [], \"height\": 1080, \"channels\": 2}"); - r9.debug = false; - // Add clips - //r9.AddClip(&clip_video); - //r9.AddClip(&clip_overlay); - - // Open Timeline - r9.Open(); int frame_count = 1; while (true) { - int frame_number = (rand() % 200) + 1; + // Create a timeline + Timeline r10(640, 480, Fraction(30, 1), 44100, 2, LAYOUT_STEREO); + r10.SetJson("{\"tick_pixels\": 100, \"effects\": [{\"reader\": {\"file_size\": \"1658880\", \"width\": 720, \"video_length\": \"2592000\", \"pixel_format\": -1, \"video_bit_rate\": 0, \"fps\": {\"den\": 1, \"num\": 30}, \"has_single_image\": true, \"channel_layout\": 4, \"audio_stream_index\": -1, \"vcodec\": \"\", \"has_video\": true, \"channels\": 0, \"video_timebase\": {\"den\": 30, \"num\": 1}, \"duration\": 86400.0, \"audio_timebase\": {\"den\": 1, \"num\": 1}, \"path\": \"/Users/jonathan/apps/openshot-qt-git/src/transitions/common/circle_out_to_in.svg\", \"interlaced_frame\": false, \"display_ratio\": {\"den\": 4, \"num\": 5}, \"type\": \"QtImageReader\", \"video_stream_index\": -1, \"acodec\": \"\", \"height\": 576, \"audio_bit_rate\": 0, \"pixel_ratio\": {\"den\": 1, \"num\": 1}, \"has_audio\": false, \"top_field_first\": true, \"sample_rate\": 0}, \"contrast\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1, \"Y\": 3}}]}, \"position\": 0, \"title\": \"Transition\", \"start\": 0, \"layer\": 4, \"type\": \"Mask\", \"replace_image\": false, \"id\": \"Y1SJ85D8HV\", \"brightness\": {\"Points\": [{\"handle_type\": 0, \"interpolation\": 0, \"handle_right\": {\"X\": 96.5999984741211, \"Y\": 1}, \"handle_left\": {\"X\": 1, \"Y\": 1}, \"co\": {\"X\": 1, \"Y\": 1}}, {\"handle_type\": 0, \"interpolation\": 0, \"handle_right\": {\"X\": 240, \"Y\": -1}, \"handle_left\": {\"X\": 144.3999938964844, \"Y\": -1}, \"co\": {\"X\": 1249.92, \"Y\": -1}}]}, \"end\": 52.08}], \"duration\": 300, \"version\": {\"openshot-qt\": \"2.0.5\", \"libopenshot\": \"0.0.9\"}, \"markers\": [], \"export_path\": \"\", \"clips\": [{\"reader\": {\"file_size\": \"7608204\", \"width\": 1280, \"video_length\": \"1253\", \"pixel_format\": 0, \"video_bit_rate\": 1165807, \"fps\": {\"den\": 1, \"num\": 24}, \"has_single_image\": false, \"channel_layout\": 3, \"audio_stream_index\": 1, \"vcodec\": \"h264\", \"has_video\": true, \"channels\": 2, \"video_timebase\": {\"den\": 24, \"num\": 1}, \"duration\": 51.9466667175293, \"audio_timebase\": {\"den\": 48000, \"num\": 1}, \"path\": \"/Users/jonathan/Movies/sintel_trailer-720p.mp4\", \"interlaced_frame\": false, \"display_ratio\": {\"den\": 9, \"num\": 16}, \"type\": \"FFmpegReader\", \"video_stream_index\": 0, \"acodec\": \"aac\", \"height\": 720, \"audio_bit_rate\": 126694, \"pixel_ratio\": {\"den\": 1, \"num\": 1}, \"has_audio\": true, \"top_field_first\": true, \"sample_rate\": 48000}, \"rotation\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"perspective_c2_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"perspective_c2_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"shear_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"shear_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"effects\": [], \"anchor\": 0, \"perspective_c4_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"location_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"location_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"crop_width\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"scale_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"position\": 0, \"gravity\": 4, \"crop_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"crop_height\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"layer\": 4, \"duration\": 51.9466667175293, \"perspective_c3_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"perspective_c3_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"title\": \"sintel_trailer-720p.mp4\", \"file_id\": \"J6VK47X5IS\", \"perspective_c4_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"perspective_c1_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"perspective_c1_x\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": -1.0}}]}, \"time\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"scale_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"id\": \"QLJJ0D354R\", \"crop_y\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"image\": \".openshot_qt/thumbnail/J6VK47X5IS.png\", \"alpha\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"start\": 0, \"scale\": 1, \"waveform\": false, \"wave_color\": {\"red\": {\"Points\": [{\"handle_type\": 0, \"interpolation\": 0, \"handle_left\": {\"X\": 1.0, \"Y\": 0.0}, \"handle_right\": {\"X\": 1.0, \"Y\": 0.0}, \"co\": {\"X\": 1.0, \"Y\": 0.0}}]}, \"alpha\": {\"Points\": [{\"handle_type\": 0, \"interpolation\": 0, \"handle_left\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_right\": {\"X\": 1.0, \"Y\": 255.0}, \"co\": {\"X\": 1.0, \"Y\": 255.0}}]}, \"blue\": {\"Points\": [{\"handle_type\": 0, \"interpolation\": 0, \"handle_left\": {\"X\": 1.0, \"Y\": 255.0}, \"handle_right\": {\"X\": 1.0, \"Y\": 255.0}, \"co\": {\"X\": 1.0, \"Y\": 255.0}}]}, \"green\": {\"Points\": [{\"handle_type\": 0, \"interpolation\": 0, \"handle_left\": {\"X\": 1.0, \"Y\": 123.0}, \"handle_right\": {\"X\": 1.0, \"Y\": 123.0}, \"co\": {\"X\": 1.0, \"Y\": 123.0}}]}}, \"volume\": {\"Points\": [{\"interpolation\": 2, \"co\": {\"X\": 1.0, \"Y\": 1.0}}]}, \"end\": 51.9466667175293}], \"settings\": {}, \"fps\": {\"den\": 1, \"num\": 24}, \"id\": \"T0\", \"channel_layout\": 3, \"playhead_position\": 0, \"layers\": [{\"number\": 0, \"y\": 0, \"label\": \"\", \"id\": \"L0\"}, {\"number\": 1, \"y\": 0, \"label\": \"\", \"id\": \"L1\"}, {\"number\": 2, \"y\": 0, \"label\": \"\", \"id\": \"L2\"}, {\"number\": 3, \"y\": 0, \"label\": \"\", \"id\": \"L3\"}, {\"number\": 4, \"y\": 0, \"label\": \"\", \"id\": \"L4\"}], \"height\": 720, \"progress\": [], \"width\": 1280, \"channels\": 2, \"profile\": \"HDV 720 24p\", \"scale\": 16, \"files\": [{\"file_size\": \"7608204\", \"width\": 1280, \"video_length\": \"1253\", \"pixel_format\": 0, \"video_bit_rate\": 1165807, \"fps\": {\"den\": 1, \"num\": 24}, \"has_single_image\": false, \"channel_layout\": 3, \"audio_stream_index\": 1, \"vcodec\": \"h264\", \"has_video\": true, \"channels\": 2, \"video_timebase\": {\"den\": 24, \"num\": 1}, \"duration\": 51.9466667175293, \"audio_timebase\": {\"den\": 48000, \"num\": 1}, \"path\": \"/Users/jonathan/Movies/sintel_trailer-720p.mp4\", \"interlaced_frame\": false, \"media_type\": \"video\", \"display_ratio\": {\"den\": 9, \"num\": 16}, \"type\": \"FFmpegReader\", \"video_stream_index\": 0, \"id\": \"J6VK47X5IS\", \"acodec\": \"aac\", \"height\": 720, \"audio_bit_rate\": 126694, \"pixel_ratio\": {\"den\": 1, \"num\": 1}, \"has_audio\": true, \"top_field_first\": true, \"sample_rate\": 48000}], \"sample_rate\": 44100}"); + r10.debug = false; + + // Open Timeline + r10.Open(); + + int frame_number = (rand() % 500) + 1; cout << frame_count << ": reading frame " << frame_number << endl; - r9.GetFrame(frame_number); + r10.GetFrame(frame_number); + + r10.Close(); frame_count++; // if (frame_count == 500)