-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from boostcampaitech3/jj/feat
[feat] 데이터 추가를 위한 비디오를 이미지로 변환하는 코드 #81
- Loading branch information
Showing
2 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import os" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def createDir(dir):\n", | ||
" if not os.path.exists(dir):\n", | ||
" os.makedirs(dir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 9, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"New.World_1-29-30_1-32-23_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_14_label_B_P.mp4\n", | ||
"Sweet.Home_1_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_3_label_B_P.mp4\n", | ||
"New.World_1-16-10_1-17-00_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_12_label_B_P.mp4\n", | ||
"The.Outlaws_0-07-50_0-10-27_label_B_P.mp4\n", | ||
"SCUM1_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.3__#00-08-06_00-09-28_label_B_P.mp4\n", | ||
"The.Outlaws_1-51-48_1-53-18_label_B_P.mp4\n", | ||
"IRIS.The.Movie_3_label_B_P.mp4\n", | ||
"The.Outlaws_0-25-00_0-26-20_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_16_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_2_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_1_label_P.mp4\n", | ||
"A.Stroke.of.Genius_2_label_P.mp4\n", | ||
"A.Stroke.of.Genius_5_label_B_P.mp4\n", | ||
"SCUM2_label_B_P.mp4\n", | ||
"JAZZ_#00-07-07_00-07-51_label_B_P.mp4\n", | ||
"IRIS.The.Movie_12_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.2__#00-41-59_00-42-55_label_B_P.mp4\n", | ||
"Cold.Eyes_0-00-14_0-00-29_label_B_P.mp4\n", | ||
"Squid.Game_6_label_B_P.mp4\n", | ||
"Parasite_1-53-38_1-55-21_label_B_P.mp4\n", | ||
"Cold.Eyes_3_label_P.mp4\n", | ||
"The.Outlaws_0-18-45_0-19-55_label_B_P.mp4\n", | ||
"Sweet.Home_6_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.2__#00-06-31_00-07-39_label_B_P.mp4\n", | ||
"Squid.Game_7_label_P.mp4\n", | ||
"Squid.Game_10_label_B_P.mp4\n", | ||
"Cold.Eyes_5_label_P.mp4\n", | ||
"A.Stroke.of.Genius_1_label_B_P.mp4\n", | ||
"Cold.Eyes_0-02-14_0-02-20_0-02-35_0-02-37_0-02-43_0-02-46_0-02_51_0-02-55_0-03-06_0-03-07_0-03-12_0-03-16label_P.mp4\n", | ||
"IRIS.The.Movie_6_label_B_P.mp4\n", | ||
"IRIS.The.Movie_1_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.1__#00-58-54_01-00-13_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_13_label_B_P.mp4\n", | ||
"Cold.Eyes_0-00-06_0-00-33_0-01-24_0-01-29_label_B_P.mp4\n", | ||
"IRIS.The.Movie_5_label_B_P.mp4\n", | ||
"Sweet.Home_4_label_B_P.mp4\n", | ||
"Cold.Eyes_0-00-04_0-00-13_0-00-20_0-00-31_0-01-02_0-01-04_0-01_21_0-01-24_label_P.mp4\n", | ||
"IRIS.The.Movie_10_label_B_P.mp4\n", | ||
"New.World_0-01-03_0-02-14_label_P.mp4\n", | ||
"Cold.Eyes_0-00-02_0-00-06_label_B_P.mp4\n", | ||
"Squid.Game_1_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_4_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.1__#00-51-09_00-53-05_label_B_P.mp4\n", | ||
"IRIS.The.Movie_2_label_B_P.mp4\n", | ||
"IRIS.The.Movie_4_label_B_P.mp4\n", | ||
"Squid.Game_12_label_B_P.mp4\n", | ||
"Squid.Game_8_label_B_P.mp4\n", | ||
"Cold.Eyes_0-00-07_0-00-14_0-00-27_0-00-34_ 0-00-38_0-00-44_0-00_49_0-00-58_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_11_label_B_P.mp4\n", | ||
"Parasite_1-50-38_1-52-16_label_B_P.mp4\n", | ||
"A.Stroke.of.Genius_15_label_B_P.mp4\n", | ||
"All.of.Us.Are.Dead.2__#00-04-01_00-05-57_label_B_P.mp4\n", | ||
"Sweet.Home_2_label_P.mp4\n", | ||
"Cold.Eyes_0-01-29_0-01-33_label_B_P.mp4\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"file_list = os.listdir('./Movies/')\n", | ||
"\n", | ||
"blood_vid_list = []\n", | ||
"\n", | ||
"for file in file_list:\n", | ||
" if '_P' in file:\n", | ||
" print(file)\n", | ||
" blood_vid_list.append(file)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 10, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"num of blood vids: 58\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"print('num of blood vids:', len(blood_vid_list))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 18, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"createDir('images')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 20, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stderr", | ||
"output_type": "stream", | ||
"text": [ | ||
"Movies/Cold.Eyes_0-00-07_0-00-14_0-00-27_0-00-34_: No such file or directory\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"for b in blood_vid_list:\n", | ||
" createDir(os.path.join('images', b[:-4]))\n", | ||
"\n", | ||
" # print('convert video to images:', b[:-4])\n", | ||
"\n", | ||
" os.system(\"ffmpeg -hide_banner -loglevel error -i Movies/\"+ b +' -vf fps=1 -s 640x360 -qscale:v 4 -b 800k images/'+b[:-4]+'/%6d.jpg'\" < /dev/null\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3.8.10 64-bit", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.10" | ||
}, | ||
"orig_nbformat": 4, | ||
"vscode": { | ||
"interpreter": { | ||
"hash": "e7370f93d1d0cde622a1f8e1c04877d8463912d04d973331ad4851f04de6915a" | ||
} | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# mp4tojpg.ipynb | ||
|
||
- 비디오 파일을 이미지 파일로 변경. |