fix subtitles
This commit is contained in:
parent
c381c624be
commit
d7b1d8b55c
4 changed files with 306 additions and 28 deletions
36
app.py
36
app.py
|
|
@ -317,6 +317,7 @@ class EditRequest(BaseModel):
|
|||
job_id: str
|
||||
clip_index: int
|
||||
api_key: Optional[str] = None
|
||||
input_filename: Optional[str] = None
|
||||
|
||||
@app.post("/api/edit")
|
||||
async def edit_clip(
|
||||
|
|
@ -337,8 +338,15 @@ async def edit_clip(
|
|||
raise HTTPException(status_code=400, detail="Job result not available")
|
||||
|
||||
try:
|
||||
# Resolve Input Path: Prefer explict input_filename from frontend (chaining edits)
|
||||
if req.input_filename:
|
||||
# Security: Ensure just a filename, no paths
|
||||
safe_name = os.path.basename(req.input_filename)
|
||||
input_path = os.path.join(OUTPUT_DIR, req.job_id, safe_name)
|
||||
filename = safe_name
|
||||
else:
|
||||
# Fallback to original clip
|
||||
clip = job['result']['clips'][req.clip_index]
|
||||
# Resolve file path
|
||||
filename = clip['video_url'].split('/')[-1]
|
||||
input_path = os.path.join(OUTPUT_DIR, req.job_id, filename)
|
||||
|
||||
|
|
@ -428,6 +436,7 @@ class SubtitleRequest(BaseModel):
|
|||
clip_index: int
|
||||
position: str = "bottom" # top, middle, bottom
|
||||
font_size: int = 16
|
||||
input_filename: Optional[str] = None
|
||||
|
||||
@app.post("/api/subtitle")
|
||||
async def add_subtitles(req: SubtitleRequest):
|
||||
|
|
@ -455,27 +464,16 @@ async def add_subtitles(req: SubtitleRequest):
|
|||
if req.clip_index >= len(clips):
|
||||
raise HTTPException(status_code=404, detail="Clip not found")
|
||||
|
||||
clip = clips[req.clip_index]
|
||||
clip_data = clips[req.clip_index]
|
||||
|
||||
# Video Path
|
||||
# Handle current video (might have been edited already)
|
||||
# We use the video_url from job/data. If it points to an edited one, we subtitle THAT one.
|
||||
# Note: job['result']['clips'] might be in memory, but data is from disk.
|
||||
# We should trust what's current.
|
||||
|
||||
# Let's verify what video_url is in data vs job.
|
||||
# We'll use the one from disk data as it's fresh? No, job dict is main truth in memory.
|
||||
# But transcript is only in disk data now.
|
||||
|
||||
# Sync: Use data's clips but check job status?
|
||||
# Actually, job['result'] is populated from disk in run_job.
|
||||
# But let's assume `data` is correct.
|
||||
|
||||
clip_data = clips[req.clip_index]
|
||||
filename = clip_data.get('video_url', '').split('/')[-1]
|
||||
|
||||
if not filename:
|
||||
if req.input_filename:
|
||||
# Use chained file
|
||||
filename = os.path.basename(req.input_filename)
|
||||
else:
|
||||
# Fallback to standard naming
|
||||
filename = clip_data.get('video_url', '').split('/')[-1]
|
||||
if not filename:
|
||||
base_name = os.path.basename(json_files[0]).replace('_metadata.json', '')
|
||||
filename = f"{base_name}_clip_{req.clip_index+1}.mp4"
|
||||
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs
|
|||
body: JSON.stringify({
|
||||
job_id: jobId,
|
||||
clip_index: index,
|
||||
// We send it in header now, but backend might expect it in body too currently.
|
||||
// We will update backend to be flexible.
|
||||
input_filename: currentVideoUrl.split('/').pop()
|
||||
})
|
||||
});
|
||||
|
||||
|
|
@ -84,7 +83,8 @@ export default function ResultCard({ clip, index, jobId, uploadPostKey, uploadUs
|
|||
job_id: jobId,
|
||||
clip_index: index,
|
||||
position: options.position,
|
||||
font_size: options.fontSize
|
||||
font_size: options.fontSize,
|
||||
input_filename: currentVideoUrl.split('/').pop()
|
||||
})
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,84 @@
|
|||
1
|
||||
00:00:00,260 --> 00:00:01,859
|
||||
Hoy o a partir
|
||||
|
||||
2
|
||||
00:00:01,859 --> 00:00:02,940
|
||||
de hoy
|
||||
|
||||
3
|
||||
00:00:02,940 --> 00:00:04,540
|
||||
Extremadura tiene
|
||||
|
||||
4
|
||||
00:00:04,540 --> 00:00:06,140
|
||||
mayor bloqueo y
|
||||
|
||||
5
|
||||
00:00:06,140 --> 00:00:06,460
|
||||
mayor
|
||||
|
||||
6
|
||||
00:00:06,460 --> 00:00:07,200
|
||||
inestabilidad.
|
||||
|
||||
7
|
||||
00:00:08,120 --> 00:00:09,520
|
||||
A Extremadura no
|
||||
|
||||
8
|
||||
00:00:09,520 --> 00:00:10,280
|
||||
ha llegado la
|
||||
|
||||
9
|
||||
00:00:10,280 --> 00:00:10,820
|
||||
estabilidad
|
||||
|
||||
10
|
||||
00:00:10,820 --> 00:00:11,820
|
||||
política sino
|
||||
|
||||
11
|
||||
00:00:11,820 --> 00:00:12,320
|
||||
todo lo
|
||||
|
||||
12
|
||||
00:00:12,320 --> 00:00:14,120
|
||||
contrario. Con
|
||||
|
||||
13
|
||||
00:00:14,120 --> 00:00:15,359
|
||||
estas elecciones
|
||||
|
||||
14
|
||||
00:00:15,359 --> 00:00:16,140
|
||||
lo que se ha
|
||||
|
||||
15
|
||||
00:00:16,140 --> 00:00:17,900
|
||||
producido es
|
||||
|
||||
16
|
||||
00:00:17,900 --> 00:00:19,380
|
||||
un engorde de la
|
||||
|
||||
17
|
||||
00:00:19,380 --> 00:00:20,100
|
||||
ultra derecho y,
|
||||
|
||||
18
|
||||
00:00:20,100 --> 00:00:20,500
|
||||
por lo tanto,
|
||||
|
||||
19
|
||||
00:00:20,880 --> 00:00:21,880
|
||||
hay más bloqueo
|
||||
|
||||
20
|
||||
00:00:21,880 --> 00:00:22,440
|
||||
y más
|
||||
|
||||
21
|
||||
00:00:22,440 --> 00:00:23,240
|
||||
inestabilidad.
|
||||
|
||||
|
|
@ -0,0 +1,196 @@
|
|||
1
|
||||
00:00:00,000 --> 00:00:00,260
|
||||
pavos. Es que
|
||||
|
||||
2
|
||||
00:00:00,260 --> 00:00:00,580
|
||||
hay un problema.
|
||||
|
||||
3
|
||||
00:00:00,580 --> 00:00:01,540
|
||||
Cuando es tu
|
||||
|
||||
4
|
||||
00:00:01,540 --> 00:00:02,960
|
||||
dinero, sí que
|
||||
|
||||
5
|
||||
00:00:02,960 --> 00:00:03,640
|
||||
estás en cuenta
|
||||
|
||||
6
|
||||
00:00:03,640 --> 00:00:04,360
|
||||
de... Mierda, me
|
||||
|
||||
7
|
||||
00:00:04,360 --> 00:00:04,660
|
||||
han vuelto a
|
||||
|
||||
8
|
||||
00:00:04,660 --> 00:00:05,140
|
||||
pasar. Claro,
|
||||
|
||||
9
|
||||
00:00:05,140 --> 00:00:05,520
|
||||
pero cuando es
|
||||
|
||||
10
|
||||
00:00:05,520 --> 00:00:06,000
|
||||
la presentación,
|
||||
|
||||
11
|
||||
00:00:06,160 --> 00:00:06,780
|
||||
pero cuando me
|
||||
|
||||
12
|
||||
00:00:06,780 --> 00:00:07,100
|
||||
quede... Que le
|
||||
|
||||
13
|
||||
00:00:07,100 --> 00:00:07,920
|
||||
sigue... Está
|
||||
|
||||
14
|
||||
00:00:07,920 --> 00:00:08,500
|
||||
diciendo el
|
||||
|
||||
15
|
||||
00:00:08,500 --> 00:00:09,060
|
||||
dinero de otros
|
||||
|
||||
16
|
||||
00:00:09,060 --> 00:00:10,340
|
||||
dices, pues me
|
||||
|
||||
17
|
||||
00:00:10,340 --> 00:00:11,240
|
||||
da igual, porque
|
||||
|
||||
18
|
||||
00:00:11,240 --> 00:00:11,560
|
||||
como lo he
|
||||
|
||||
19
|
||||
00:00:11,560 --> 00:00:12,040
|
||||
estado, es lo
|
||||
|
||||
20
|
||||
00:00:12,040 --> 00:00:13,480
|
||||
mismo. Aquí la
|
||||
|
||||
21
|
||||
00:00:13,480 --> 00:00:14,240
|
||||
historia, yo,
|
||||
|
||||
22
|
||||
00:00:14,360 --> 00:00:15,660
|
||||
precisamente, una
|
||||
|
||||
23
|
||||
00:00:15,660 --> 00:00:16,200
|
||||
cosa que yo me
|
||||
|
||||
24
|
||||
00:00:16,200 --> 00:00:17,100
|
||||
enfade este año,
|
||||
|
||||
25
|
||||
00:00:17,100 --> 00:00:17,439
|
||||
es porque
|
||||
|
||||
26
|
||||
00:00:17,439 --> 00:00:18,460
|
||||
estábamos pagando
|
||||
|
||||
27
|
||||
00:00:18,460 --> 00:00:19,080
|
||||
clases de inglés,
|
||||
|
||||
28
|
||||
00:00:19,480 --> 00:00:20,320
|
||||
¿vale? Y la
|
||||
|
||||
29
|
||||
00:00:20,320 --> 00:00:21,980
|
||||
gente no iba. Es
|
||||
|
||||
30
|
||||
00:00:21,980 --> 00:00:22,280
|
||||
decir, yo este
|
||||
|
||||
31
|
||||
00:00:22,280 --> 00:00:22,820
|
||||
año, he dicho
|
||||
|
||||
32
|
||||
00:00:22,820 --> 00:00:23,360
|
||||
como ni qué hace
|
||||
|
||||
33
|
||||
00:00:23,360 --> 00:00:23,900
|
||||
unos días, no ha
|
||||
|
||||
34
|
||||
00:00:23,900 --> 00:00:24,120
|
||||
habido ningún
|
||||
|
||||
35
|
||||
00:00:24,120 --> 00:00:24,860
|
||||
drama. Creo que
|
||||
|
||||
36
|
||||
00:00:24,860 --> 00:00:25,180
|
||||
la gente ha
|
||||
|
||||
37
|
||||
00:00:25,180 --> 00:00:25,660
|
||||
entendido mi
|
||||
|
||||
38
|
||||
00:00:25,660 --> 00:00:27,140
|
||||
descontento. Les
|
||||
|
||||
39
|
||||
00:00:27,140 --> 00:00:27,600
|
||||
he dicho, mira,
|
||||
|
||||
40
|
||||
00:00:27,640 --> 00:00:28,260
|
||||
yo es pago. El
|
||||
|
||||
41
|
||||
00:00:28,260 --> 00:00:29,060
|
||||
50 % de las
|
||||
|
||||
42
|
||||
00:00:29,060 --> 00:00:29,980
|
||||
clases. Pero tu
|
||||
|
||||
43
|
||||
00:00:29,980 --> 00:00:30,680
|
||||
50 lo pagas tú.
|
||||
|
||||
44
|
||||
00:00:31,220 --> 00:00:31,840
|
||||
Porque cuando lo
|
||||
|
||||
45
|
||||
00:00:31,840 --> 00:00:32,300
|
||||
pagas tú,
|
||||
|
||||
46
|
||||
00:00:32,660 --> 00:00:33,380
|
||||
entonces vas. Y
|
||||
|
||||
47
|
||||
00:00:33,380 --> 00:00:34,260
|
||||
lo usas. Un
|
||||
|
||||
48
|
||||
00:00:34,260 --> 00:00:34,840
|
||||
copago. Un
|
||||
|
||||
49
|
||||
00:00:34,840 --> 00:00:35,220
|
||||
copago.
|
||||
|
||||
Loading…
Reference in a new issue