Mrrrr's Forum (VIEW ONLY)
Un forum care ofera solutii pentru unele probleme legate in general de PC. Pe langa solutii, aici puteti gasi si alte lucruri interesante // A forum that offers solutions to some PC related issues. Besides these, here you can find more interesting stuff.
Lista Forumurilor Pe Tematici
Mrrrr's Forum (VIEW ONLY) | Reguli | Inregistrare | Login

POZE MRRRR'S FORUM (VIEW ONLY)

Nu sunteti logat.
Nou pe simpatie:
iulian93 pe Simpatie
Femeie
25 ani
Ilfov
cauta Barbat
27 - 68 ani
Mrrrr's Forum (VIEW ONLY) / Tutoriale si Ghiduri Utile // Tutorials and useful guides / [POWERSHELL] Convert JSON (or other format) Subtitles to SRT Moderat de TRaP, TonyTzu
Autor
Mesaj Pagini: 1
Mrrrr
AdMiN

Inregistrat: acum 19 ani
Postari: 2366
I downloaded a free health video online, but the English subtitles coming with it are not downloadable with the video, they're not in VTT format, but in JSON format. I tried one of the fancy online converters, but they appear to be expecting something else.

Gave ChatGPT a sample, and it wrote the following command that converted my subtitle.json file into subtitle.srt:

$j=Get-Content .\subtitle.json -Raw | ConvertFrom-Json;$n=1;$out=foreach($i in $j.content.items){$s=[timespan]::FromSeconds($i.startTime);$e=[timespan]::FromSeconds($i.endTime);"$n`r`n{0:hh\:mm\:ss},{1:000} --> {2:hh\:mm\:ss},{3:000}`r`n{4}`r`n" -f $s,$s.Milliseconds,$e,$e.Milliseconds,$i.content;$n++};$out | Set-Content .\subtitle.srt -Encoding UTF8


Source: ChatGPT


_______________________________________


pus acum 8 zile
   
Mrrrr
AdMiN

Inregistrat: acum 19 ani
Postari: 2366
For a video without any subtitles (were never made), I got a bit creative and used a "Create subtitles from audio" option that PotPlayer has. After downloading the required engine and model, I got it to work but in the destination directory I could not find a saved subtitle.

But the generated subtitle was in the creation window, in the following format:

[00:35.040 --> 00:54.380] Bla bla bla.
[00:54.380 --> 00:57.120] More bla bla.
[00:57.600 --> 00:59.280] And some other bla.

Powershell command to convert that to SRT format:

$i=1; gc input.txt | % { if($_ -match '^\[(\d+):(\d+\.\d+)\s+-->\s+(\d+):(\d+\.\d+)\]\s*(.*)$'){ "$i`n00:$('{0:D2}' -f $matches[1]):$($matches[2]-replace '\.',',') --> 00:$('{0:D2}' -f $matches[3]):$($matches[4]-replace '\.',',')`n$($matches[5])`n"; $i++ } } | Out-File output.srt -Encoding utf8


Source: ChatGPT


_______________________________________


pus acum 6 zile
   
Pagini: 1  

Mergi la