Skip to content

Instantly share code, notes, and snippets.

@sazio
Created August 28, 2020 14:20
Show Gist options
  • Save sazio/49388416824b10714d7713ccaf6e1197 to your computer and use it in GitHub Desktop.
Save sazio/49388416824b10714d7713ccaf6e1197 to your computer and use it in GitHub Desktop.
"""# We're only interested in Frames --> uncomment ffextract_audio if you need it
AUDIO_FORMAT = "wav" # "aac"
videos_folder = VIDEOS_FOLDER_TRAIN
images_folder_path = IMAGES_FOLDER_TRAIN
audios_folder_path = AUDIOS_FOLDER_TRAIN
if EXTRACT_CONTENT == True:
# 1h20min for chunk#0 (11GB)
# Extract some images + audio track
for idx, row in tqdm(train_pd.iterrows(), total=meta_pd.shape[0]):
try:
video_path = videos_folder + "/" + row["filename"]
images_path = images_folder_path + "/" + row["filename"][:-4]
audio_path = audios_folder_path + "/" + row["filename"][:-4]
# Extract images
if not os.path.exists(images_path): os.makedirs(images_path)
ret = ffextract_frames(video_path, images_path, rate = FRAME_RATE)
# Extract audio
if not os.path.exists(audio_path): os.makedirs(audio_path)
# ret = ffextract_audio(video_path, audio_path + "/audio." + AUDIO_FORMAT)
except:
print("Cannot extract frames/audio for:" + row["filename"])
""";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment