Created
January 22, 2019 23:36
-
-
Save dsuess/a19595435ff7ccae511af9a5d2b50691 to your computer and use it in GitHub Desktop.
VideoReader speed test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "from smu.visualise.video import VideoReader\nfrom tqdm import tqdm", | |
"execution_count": 1, | |
"outputs": [] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%timeit\n\nall_frames = np.array(list(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4')))", | |
"execution_count": 5, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "16.5 s ± 1.67 s per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sample_frames = np.array(list(tqdm(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', 100, None))))\n\nnp.abs(sample_frames - all_frames[100:]).max()", | |
"execution_count": 8, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "2585it [00:06, 398.01it/s]\n", | |
"name": "stderr" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%timeit\n\nnp.array(list(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', 1292, None)))", | |
"execution_count": 11, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "6.81 s ± 285 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sample_frames = np.array(list(tqdm(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', 1000))))\n\nnp.abs(sample_frames - all_frames[:1000]).max()", | |
"execution_count": 12, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "1000it [00:02, 365.12it/s]\n", | |
"name": "stderr" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 12, | |
"data": { | |
"text/plain": "0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "%%timeit\n\nnp.array(list(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', 1292)))", | |
"execution_count": 13, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "5.06 s ± 31.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n", | |
"name": "stdout" | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sample_frames = np.array(list(tqdm(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', None, None, 10))))\n\nnp.abs(sample_frames - all_frames[::10]).max()", | |
"execution_count": 14, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "269it [00:12, 21.04it/s]\n", | |
"name": "stderr" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 14, | |
"data": { | |
"text/plain": "0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sample_frames = np.array(list(tqdm(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', None, None, 100))))\n\nnp.abs(sample_frames - all_frames[::100]).max()", | |
"execution_count": 15, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "27it [00:01, 20.50it/s]\n", | |
"name": "stderr" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 15, | |
"data": { | |
"text/plain": "0" | |
}, | |
"metadata": {} | |
} | |
] | |
}, | |
{ | |
"metadata": { | |
"trusted": true | |
}, | |
"cell_type": "code", | |
"source": "sample_frames = np.array(list(tqdm(\n VideoReader('/Users/dsuess/Downloads/SJ4000 _ Short Cinematic Test Video-geaY4_obGnU.mp4', 342, 2153, 10))))\n\nnp.abs(sample_frames - all_frames[342:2153:10]).max()", | |
"execution_count": 16, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"text": "182it [00:08, 24.43it/s]\n", | |
"name": "stderr" | |
}, | |
{ | |
"output_type": "execute_result", | |
"execution_count": 16, | |
"data": { | |
"text/plain": "0" | |
}, | |
"metadata": {} | |
} | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"name": "conda-env-smu-py", | |
"display_name": "Python [conda env:smu]", | |
"language": "python" | |
}, | |
"varInspector": { | |
"window_display": false, | |
"cols": { | |
"lenName": 16, | |
"lenType": 16, | |
"lenVar": 40 | |
}, | |
"kernels_config": { | |
"python": { | |
"library": "var_list.py", | |
"delete_cmd_prefix": "del ", | |
"delete_cmd_postfix": "", | |
"varRefreshCmd": "print(var_dic_list())" | |
}, | |
"r": { | |
"library": "var_list.r", | |
"delete_cmd_prefix": "rm(", | |
"delete_cmd_postfix": ") ", | |
"varRefreshCmd": "cat(var_dic_list()) " | |
} | |
}, | |
"types_to_exclude": [ | |
"module", | |
"function", | |
"builtin_function_or_method", | |
"instance", | |
"_Feature" | |
] | |
}, | |
"language_info": { | |
"name": "python", | |
"version": "3.7.1", | |
"mimetype": "text/x-python", | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"pygments_lexer": "ipython3", | |
"nbconvert_exporter": "python", | |
"file_extension": ".py" | |
}, | |
"gist": { | |
"id": "", | |
"data": { | |
"description": "VideoReader speed test", | |
"public": true | |
} | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment