Spaces:
Sleeping
Sleeping
Alexandre Gazola
commited on
Commit
·
68cc240
1
Parent(s):
0c2f97b
workaround para leitura video youtube a partir de arquivo local
Browse files
count_max_bird_species_tool.py
CHANGED
|
@@ -15,7 +15,11 @@ def count_max_bird_species_in_video(youtube_url: str) -> int:
|
|
| 15 |
- int: The maximum number of bird species detected in the YouTube video.
|
| 16 |
"""
|
| 17 |
|
| 18 |
-
frames = sample_youtube_video(youtube_url, 5)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
return count_max_bird_species(frames)
|
| 20 |
|
| 21 |
def count_max_bird_species(framesStr: list[str]) -> int:
|
|
@@ -66,6 +70,9 @@ def count_max_bird_species(framesStr: list[str]) -> int:
|
|
| 66 |
# Return the maximum number of distinct bird species detected in any frame
|
| 67 |
return max_bird_species_count
|
| 68 |
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
if __name__ == "__main__":
|
| 71 |
sampled_frames = sample_youtube_video.invoke({
|
|
|
|
| 15 |
- int: The maximum number of bird species detected in the YouTube video.
|
| 16 |
"""
|
| 17 |
|
| 18 |
+
# frames = sample_youtube_video(youtube_url, 5)
|
| 19 |
+
youtube_video_in_base_64 = os.path.join(BASE_DIR, 'files', frames_youtube_birds_video.b64)
|
| 20 |
+
print('youtube video path: ' + youtube_video_in_base_64)
|
| 21 |
+
frames = read_list_from_txt(youtube_video_in_base_64)
|
| 22 |
+
|
| 23 |
return count_max_bird_species(frames)
|
| 24 |
|
| 25 |
def count_max_bird_species(framesStr: list[str]) -> int:
|
|
|
|
| 70 |
# Return the maximum number of distinct bird species detected in any frame
|
| 71 |
return max_bird_species_count
|
| 72 |
|
| 73 |
+
def read_list_from_txt(file_path: str) -> list[str]:
|
| 74 |
+
with open(file_path, 'r', encoding='utf-8') as f:
|
| 75 |
+
return [line.rstrip('\n') for line in f]
|
| 76 |
|
| 77 |
if __name__ == "__main__":
|
| 78 |
sampled_frames = sample_youtube_video.invoke({
|
files/frames_youtube_birds_video.b64
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sample_youtube_video.py
CHANGED
|
@@ -26,6 +26,7 @@ def sample_youtube_video(youtube_url: str, sample_rate: int) -> List[str]:
|
|
| 26 |
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4', # Get the best quality video and audio in mp4 format
|
| 27 |
'outtmpl': '%(title)s.%(ext)s', # Save with the video title
|
| 28 |
'quiet': True, # Suppress console output
|
|
|
|
| 29 |
}
|
| 30 |
|
| 31 |
# Download the video
|
|
|
|
| 26 |
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/mp4', # Get the best quality video and audio in mp4 format
|
| 27 |
'outtmpl': '%(title)s.%(ext)s', # Save with the video title
|
| 28 |
'quiet': True, # Suppress console output
|
| 29 |
+
'cookiefile': 'youtube_cookies.txt'
|
| 30 |
}
|
| 31 |
|
| 32 |
# Download the video
|