Spaces:
Runtime error
Runtime error
smellslikeml
commited on
Commit
·
45b75be
1
Parent(s):
ccd8589
adding ffprobe tool
Browse files- README.md +3 -3
- app.py +4 -0
- ffprobe.py +19 -0
- requirements.txt +4 -0
- tool_config.json +6 -0
README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
---
|
| 2 |
title: Ffprobe Tool
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.33.1
|
| 8 |
app_file: app.py
|
|
|
|
| 1 |
---
|
| 2 |
title: Ffprobe Tool
|
| 3 |
+
emoji: 🧐
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
sdk_version: 3.33.1
|
| 8 |
app_file: app.py
|
app.py
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers.tools.base import launch_gradio_demo
|
| 2 |
+
from ffprobe import FFProbeTool
|
| 3 |
+
|
| 4 |
+
launch_gradio_demo(FFProbeTool)
|
ffprobe.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import ffmpeg
|
| 3 |
+
from transformers import Tool
|
| 4 |
+
|
| 5 |
+
class FFProbeTool(Tool):
|
| 6 |
+
name = "ffprobe_tool"
|
| 7 |
+
description = """
|
| 8 |
+
This tool extracts metadata from input video using ffmpeg/ffprobe
|
| 9 |
+
Input is input_path. Output is a text string.
|
| 10 |
+
"""
|
| 11 |
+
inputs = ["text"]
|
| 12 |
+
outputs = ["text"]
|
| 13 |
+
|
| 14 |
+
def __call__(self, input_path: str):
|
| 15 |
+
probe = ffmpeg.probe(input_path)
|
| 16 |
+
return json.dumps(next(
|
| 17 |
+
(stream for stream in probe["streams"] if stream["codec_type"] == "video"),
|
| 18 |
+
None,
|
| 19 |
+
), indent=2)
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
json
|
| 2 |
+
ffmpeg-python
|
| 3 |
+
huggingface_hub
|
| 4 |
+
transformers
|
tool_config.json
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"description": "This tool extracts metadata from input video using ffmpeg/ffprobe. Input is input_path. Output is a text string.",
|
| 3 |
+
"name": "ffprobe_tool",
|
| 4 |
+
"tool_class": "ffproble.FFProbeTool"
|
| 5 |
+
}
|
| 6 |
+
|