Jump to content

How to create auto subtitle for any video audio file?


Recommended Posts

LCF-AT

Hi guys,

another questions I have today. :) So in the past I have seens live streams on internet and TV which was subtitled on fly and I always did wonder how it works. Also if I check videos on YT then I see that almost all using a subtitle track you can enable. Its a really nice feature and now I would like to know how I can auto subtitle any audio / video with any tools. Does anyone have some experiences using any tools (no online tools etc) I could try out? So wk did posted today a info / link to a tool called videogrep...

https://forum.tuts4you.com/topic/42778-whoknows-news/?do=findComment&comment=212148

yt-dlp + videogrep - How to Make Automatic Supercuts
lav.io/notes/videogrep-tutorial/
github.com/antiboredom/videogrep 

...and I did check this out what also sounds very interesting but this I could not try out because there is no CLI executable to download and I have no idea how to install this with the usage command of "pip install videogrep" ...etc. Just need / want a binary exe file. So from there I was trying to find out how to make just a subtitle by any auto mode tool and found this...

https://github.com/agermanidis/autosub

...but there is also no binary file to download. :( Just wanna know whether anyone of you could give some hints of tools etc I could try out to get some good results at the end and a subtitle file srt or vtt. Thanks.

greetz

Link to comment

At this moment, I have a GUI version of autosub at https://drive.google.com/drive/folders/1hbF3GAJVs6ljqeazXusNyFRtC9RzeOX8

I'm being at office. If you still want to use the CLI binary, I will send you the link ~8 hours later when I back home.

Or you can manually install the autosub python package then use PyInstaller to build a single CLI binary, the document at https://pyinstaller.org/en/stable/usage.html#cmdoption-F

  • Like 1
Link to comment
LCF-AT

Hi Vic,

thanks for posting that GUI package. How to use it? When I start the GUI I just can choose 2 languages and thats it. No file or anything. I also don't wanna translate a sub file from language A to language B yet so I wanna let create a subtitle file of any video/audio I have you know (Auto-generated subtitles for any video). Would be nice if you could upload the compiled binary exe file of Autosub for me so that I can test it. Sorry, I can not create any file by myself with that pyinstaller. No clue what to do there to make it work anyhow. But by the way it would be maybe also possible for you to create a binary file from this app...

https://github.com/antiboredom/videogrep

.,..so there is also no binary released and I really hate that some of those releases never release a binary file. :( Maybe you could do that too for me if possible just to have binary files I can also use directly. Thank you.

greetz

Link to comment
Posted (edited)

Hi LCF-AT,

I know, but it is not only a translation app, translation is just another feature of this app that translate subtitle after generated.

The app will perform 2 phases

  1. Generate subtitle file from a mp3 file to a subtitle file .srt (or other supported extensions)
  2. Translate the subtitle if "From" and "To" are not the same. (Example: If you choose "From English" "To English", the app will ignore the translation phase).

With the GUI version

  1. Take a look at the below image.
  2. You choose "From English" & "To English".
  3. Drag and drop a mp3 into th app
  4. Press Go.
  5. Done.

image.png.964082a7be95e628f488c6431d0ee67c.png

With the CLI version

  1. Actually, after you install "autosub" python package with command "pip install autosub", an EXE file is compiled at "C:\Python36\Scripts\autosub.exe" (your python version might differ, eg. 27, 38, 39, etc).
  2. Take a look at the below image.
  3. To use it, you just run a command "autosub path\to\your\input.mp3 -S en -D en -o path\to\save\subtile.srt" or just minimal "autosub path\to\your\input.mp3" (the .srt file will be saved to input file's directory)
  4. Done (the result is the same as the GUI version above)

image.png.aa341f147c5339eb0f7c5b854edd3768.png

P.S I do not know the video tool you mentioned above so have no comment.

Vic P.

Edited by Vic
  • Like 1
Link to comment
LCF-AT

Hi Vic,

thanks for your answer so far. Good idea just trying the drag & drop method (I did not before of course). Now it works as you said and it creates a subtitle of my video. Good so far. I also found another source here...

https://github.com/raryelcostasouza/pyTranscriber

...which seems to be almost similar. Here I can download a portable version pyTranscriber & ffmpeg = 2 files only. I tried this too and got almost same results out +/-. Just one question about using that "Speech Recognition". As I can see its using google API for that and needs access to internet to upload / download. My question here is what does it upload? The whole video or audio file? Just did test a small video at the moment and now another video and I see it does convert the audio to flac and does upload it. Thats bad. The converted file to flac format is larger than the entire video itself. :( I tried it now with an music video I have and here it did failed totally. Maybe not suitable for music. :(

About the other app I mentioned. I just was asking you whether you could make a binary / compiled exe for me?

https://github.com/antiboredom/videogrep

https://github.com/antiboredom/videogrep/releases

Here I got just the source only and I can not build any binary by myself. Just asking whether you can do it and send it to me / upload here. Thanks again.

greetz

Link to comment
LCF-AT

Hi again,

ok, after some checking I did install Python with success and can now use that pip install command to install videogrep and others. :) I was checking out videogrep and doing the same as in the tutorial and it really works great!!!!! :) Thats the good news. Also the videogrep can use the vosk tool to create subtitle as well but in this case you don't need access to internet and nothing gets uploaded and its also working pretty quick. The bad thing is that the created subtitle is a JSON file and no srt or vtt subtitle version.

https://lav.io/notes/videogrep-tutorial/

Now I wanted to find anything what can convert this JSON subtitle to vtt or srt anything a player can read. On the vosk site I have read this usage...

https://alphacephei.com/vosk/install

vosk-transcriber -i test.mp4 -o test.txt
vosk-transcriber -i test.mp4 -t srt -o test.srt
vosk-transcriber -l fr -i test.m4a -o test.srt
vosk-transcriber --list-languages

...what looks like that it can make a srt file. I tried this but I get a bunch of errors...

Spoiler
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 1037, in _send_output
    self.send(msg)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 975, in send
    self.connect()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\http\client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\ssl.py", line 513, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\ssl.py", line 1071, in _create
    self.do_handshake()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\ssl.py", line 1342, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\Scripts\vosk-transcriber.exe\__main__.py", line 7, in <module>
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\transcriber\cli.py", line 62, in main
    transcriber = Transcriber(args)
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\transcriber\transcriber.py", line 16, in __init__
    self.model = Model(model_path=args.model, model_name=args.model_name, lang=args.lang)
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 50, in __init__
    model_path = self.get_model_path(model_name, lang)
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 63, in get_model_path
    model_path = self.get_model_by_lang(lang)
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 97, in get_model_by_lang
    self.download_model(Path(directory, result_model[0]))
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 106, in download_model
    urlretrieve(MODEL_PRE_URL + str(model_name.name) + '.zip', str(model_name) + '.zip',
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 519, in open
    response = self._open(req, data)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.1520.0_x64__123\lib\urllib\request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:997)>
Exception ignored in: <function Model.__del__ at 0x000002B82D84E0E0>
Traceback (most recent call last):
  File "C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_123\LocalCache\local-packages\Python310\site-packages\vosk\__init__.py", line 56, in __del__
    _c.vosk_model_free(self._handle)
AttributeError: 'Model' object has no attribute '_handle'

 

...not sure why. Has anyone a idea how to fix this?

greetz

Link to comment
Posted (edited)

Hi friend,

Recently I'm busy, sorry for slow reply. Now I have time to help you. My answer as the following:

On 6/7/2022 at 4:04 AM, LCF-AT said:

About the other app I mentioned. I just was asking you whether you could make a binary / compiled exe for me?

https://github.com/antiboredom/videogrep

https://github.com/antiboredom/videogrep/releases

Here I got just the source only and I can not build any binary by myself. Just asking whether you can do it and send it to me / upload here. Thanks again.

This repo is need to add some codes to build the single EXE succeed. I cloned and modified this repo, you can see the changes at https://github.com/vic4key/videogrep/commits/master

 

8 hours ago, LCF-AT said:

https://lav.io/notes/videogrep-tutorial/

Now I wanted to find anything what can convert this JSON subtitle to vtt or srt anything a player can read. On the vosk site I have read this usage...

8 hours ago, LCF-AT said:

...not sure why. Has anyone a idea how to fix this?

Instead of fixing its error, I have an idea to save more time, it's added some codes to support exporting the result to .srt file, and I did, see the changes at https://github.com/vic4key/videogrep/commit/c7385be355283f6e8eb7eb3a73b871205bbbeb1d

 

I built the repo into a single EXE, so you can run directly via CLI. This file contains models, so its size is f*cking large (~90MB). Download it at https://secufiles.com/ad41f8eaf5c65253/videogrep.exe

The repo is now easy to built into a single EXE. You can join the repo to modify or build it yourself. The instruction I noted at https://github.com/vic4key/videogrep/blob/master/instructions.txt

Test the result by an online tool at https://www.happyscribe.com/subtitle-tools/online-subtitle-editor/free

P.S One cup of coffee when offline meeting. :D

 

Vic P.

Edited by Vic
  • Thanks 1
Link to comment
LCF-AT

Hello Vic,

thank you very much for taking the time to check this out and trying to help me. :) I did download your compiled 90 MB package and it seems to work on first test to output also a srt file next to json file. Very good! :) Only get still error infos in CMD window about that....when trying to search for terms in video...

[+] Creating clips.
[+] Concatenating clips.
[+] Writing ouput file.
Moviepy - Building video experience1.mp4.
MoviePy - Writing audio in temp-audio1654801851.1781707.m4a
MoviePy - Done.
Moviepy - Writing video experience1.mp4

Moviepy - Done !
Moviepy - video ready experience1.mp4
Exception ignored in: <bound method FFMPEG_VideoReader.__del__ of <moviepy.video.io.ffmpeg_reader.FFMPEG_VideoReader object at 0x000002C3D6900E10>>
Traceback (most recent call last):
  File "moviepy\video\io\ffmpeg_reader.py", line 199, in __del__
  File "moviepy\video\io\ffmpeg_reader.py", line 190, in close
  File "subprocess.py", line 1139, in terminate
OSError: [WinError 6] Das Handle ist ungültig
Exception ignored in: <bound method FFMPEG_AudioReader.__del__ of <moviepy.audio.io.readers.FFMPEG_AudioReader object at 0x000002C3D6900B70>>
Traceback (most recent call last):
  File "moviepy\audio\io\readers.py", line 254, in __del__
  File "moviepy\audio\io\readers.py", line 149, in close_proc
  File "subprocess.py", line 1139, in terminate
OSError: [WinError 6] Das Handle ist ungültig

...some exception and not valid handle etc. Similar same I have when using the python files. Why? Can I fix this etc? Or why do I get those errors? Just wanna know why I get errors and how to fix them.

One question about your compiled package. Is it just so large because you also did include ffmpeg? :) About this..

https://github.com/vic4key/videogrep/blob/master/instructions.txt

....hhmm. Not sure how to do. Is git-clone similar like pip install command? As I said I just installed Python from MS Store somehow and after this I could use the pip command. Sorry but here I'am again too stupid for. I have seen many interesting tools on github already but most of them don't release compiled files only install instructions with some commands lile clone xy whatever you know.

PS: You have really many GH projects in your channel! :) Looks quite interesting. Do you also have some knowledge about websockets?

greetz

Link to comment

Hi,

 

17 minutes ago, LCF-AT said:

...some exception and not valid handle etc. Similar same I have when using the python files. Why? Can I fix this etc? Or why do I get those errors? Just wanna know why I get errors and how to fix them.

Oh. The error occurred because of ffmpeg.exe is not found in your PC (in the current directory and the %PATH%). In this case, I did not embed it into videogrep.exe. It's easy to fix. I fixed & committed the code changes.

 

27 minutes ago, LCF-AT said:

One question about your compiled package. Is it just so large because you also did include ffmpeg? :) About this..

The first EXE is not yet included, it's almost come from the model folder, you can see its size in the repo. The EXE is now bigger, I embedded ffmpeg.exe and the f*cking size is 100+MB. :) Download at https://filebin.net/ttecwkqpe1enpvln/videogrep.exe

 

33 minutes ago, LCF-AT said:

Not sure how to do. Is git-clone similar like pip install command?

Yep. Just run the commands in the instruction.txt. Required PC has python 3.6+ & virtualenv & git cli. Hmm. But I compiled for you, so can ignore it now if no more changes.

 

38 minutes ago, LCF-AT said:

Do you also have some knowledge about websockets?

Probably, enough to use.

 

Vic P.

  • Like 1
Link to comment
LCF-AT

Hi Vic,

in your new file I get same error again as before...

[+] Creating clips.
[+] Concatenating clips.
[+] Writing ouput file.
Moviepy - Building video C:\1\Videogrep\experience2.mp4.
MoviePy - Writing audio in temp-audio1654811553.953343.m4a
MoviePy - Done.
Moviepy - Writing video C:\1\Videogrep\experience2.mp4

Moviepy - Done !
Moviepy - video ready C:\1\Videogrep\experience2.mp4
Exception ignored in: <bound method FFMPEG_VideoReader.__del__ of <moviepy.video.io.ffmpeg_reader.FFMPEG_VideoReader object at 0x00000191CE650E48>>
Traceback (most recent call last):
  File "moviepy\video\io\ffmpeg_reader.py", line 199, in __del__
  File "moviepy\video\io\ffmpeg_reader.py", line 190, in close
  File "subprocess.py", line 1139, in terminate
OSError: [WinError 6] Das Handle ist ungültig
Exception ignored in: <bound method FFMPEG_AudioReader.__del__ of <moviepy.audio.io.readers.FFMPEG_AudioReader object at 0x00000191CE650BA8>>
Traceback (most recent call last):
  File "moviepy\audio\io\readers.py", line 254, in __del__
  File "moviepy\audio\io\readers.py", line 149, in close_proc
  File "subprocess.py", line 1139, in terminate
OSError: [WinError 6] Das Handle ist ungültig

...also if I put a static ffmpeg exe into same folder where your created videogrep is I get same errors / infos. Must be something else. I also have a app folder in my path environments what has a ffmpeg version included what means all can have access to this ffmpeg file from anywhere.

greetz

Link to comment

In the 2nd EXE, you don't need to take care about ffmpeg.exe, it's embedded inside. I guess the error come from the moviepy library.

BTW, I fixed an error that almost same as your error, the result as the below. Download the 3rd EXE at https://secufiles.com/c7355cfc50b24862/videogrep_-_3rd.zip

(videogrep-exe) Codes\Gits\videogrep-exe\videogrep>videogrep -i tests\manifesto.mp4 --search adversaries --output out.mp4
[+] Creating clips.
[+] Concatenating clips.
[+] Writing ouput file.
Moviepy - Building video out.mp4.
MoviePy - Writing audio in temp-audio1654842539.687297.m4a
MoviePy - Done.
Moviepy - Writing video out.mp4
Moviepy - Done !
Moviepy - video ready out.mp4

P.S If it does not work, show me the command that you ran. I will reproduce exact your issue.

Edited by Vic
  • Thanks 1
Link to comment
R0ttenK4ne

@LCF-AT

Jesus... you don't know nothing!🙄😁
What do you do here?!😄
This are none questions for a RE forum!

Do you know the differences between windows and linux?
In linux there is no exe files!

So if you want to subtitle any video you have to think about it first on how to teach in the video then you can write the subtitles for it.😉
Yeah i know... it's not what you asking for.😊

Link to comment

Hi @Vic,

thanks for creating the new executable package part 3. :) Now it works and I get no more error infos as I get in both pre versions from you. Well done. One more question I have about the exported srt file. Why are they using the "," sign in the timestamps and not using "." sign?

1
00:00:0,180 --> 00:00:3,690
it is time for us to adopt a new company

2
00:00:3,690 --> 00:00:6,570
brand to encompass everything that we

3
00:00:6,570 --> 00:00:9,990
do to reflect who we are and what we

So you see this right. I also see that in all srt files I can find they using the comma and no dot. I tried to change the comma to dot in entire srt file and did save it and its also working too to play same in VLC player. So is it possible to set a extra commandline parameter to export the srt file with dot instead of comma in the timestamps? Just asking only because it would be better having dots in the timestamps so then I can just copy the whole timestamp and paste it into video edit tools like VirtualDub to jump right on the same location / time.

1
00:00:0.180 --> 00:00:3.690
it is time for us to adopt a new company

2
00:00:3.690 --> 00:00:6.570
brand to encompass everything that we

3
00:00:6.570 --> 00:00:9.990
do to reflect who we are and what we

Next question: What kind of extensions can moviepy output?

Videogrep can export any file type that moviepy can handle.

Where can I find a list what extensions it can output? Except XML.

Next question: So to have and use subtitles is really good but I see there are different types of subtitles. On youtube I can see its using VTT subtitles which I can also download and to play with VLC & other player but the they are showing differently. On YT every words is showing right on the point when somebody does speak and in VLC & Co player its not showing same like on YT so in VLC entire set is shown at once and then next set and next etc like when using SRT subtitles. Do players like VLC don't support playing VTT subtitles correctly? So VTT is more advanced and has timestamps for everything etc. Just wanna know whether VLC can show the VTT same like on youtube player or not? If its possible that VLC can show it same like on YT then it would be good also to have an export for VTT too if possible. Only a add on question and no must have or something etc.

@R0ttenK4ne

Do we know us?! :slap:

Link to comment
19 hours ago, LCF-AT said:

thanks for creating the new executable package part 3. :) Now it works and I get no more error infos as I get in both pre versions from you. Well done.

Sounds good. Just remember a cup of coffee. :)

 

19 hours ago, LCF-AT said:

Why are they using the "," sign in the timestamps and not using "." sign?

They are the thousands' separator, the comma sign used in most english-speaking countries. But the dot is not, it used in most non-english speaking countries.

Wikipedia said "since the program was written in France", and http://precisioncalc.com/Internationalized Thousands Separator Formatting.html

You're a German, right. :)

 

19 hours ago, LCF-AT said:

I also see that in all srt files I can find they using the comma and no dot. I tried to change the comma to dot in entire srt file and did save it and its also working too to play same in VLC player.

It works for sure. Because, VTT (WebVTT) extends / based on SRT file format for the proposed HTML5.

 

19 hours ago, LCF-AT said:

So is it possible to set a extra commandline parameter to export the srt file with dot instead of comma in the timestamps?

Do it yourself. Let follow my instruction.txt to modify anything you want.

I took the initiative to do that (replaced dot by comma), take a look at videogrep/srtfile.py (line 7) at https://github.com/vic4key/videogrep/commit/c7385be355283f6e8eb7eb3a73b871205bbbeb1d

 

19 hours ago, LCF-AT said:

Where can I find a list what extensions it can output? Except XML.

I believe that you know how to use Google or see its document. The list at https://zulko.github.io/moviepy/getting_started/videoclips.html#exporting-video-clips

 

19 hours ago, LCF-AT said:

Do players like VLC don't support playing VTT subtitles correctly? So VTT is more advanced and has timestamps for everything etc. Just wanna know whether VLC can show the VTT same like on youtube player or not?

It's designed/proposed for HTML5 and works well on web platform (of course, it's WebVTT) and becoming a web standard. But VLC is not, it's workable and not really well like web. Currently, it isn't official supported and being in progress.

Recently, VLC also fixed several of bugs that related to VTT extension, from VLC 3.0.x+ (http://git.videolan.org/?p=vlc.git;a=blob;f=NEWS;h=b100d9e1d8f6802894b729dcc80a3583f023a07d;hb=HEAD#l45)

 

See more references

https://www.w3.org/TR/webvtt1/

https://www.matroska.org/technical/subtitles.html#srt-subtitles

https://www.matroska.org/technical/subtitles.html#webvtt

https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API

http://nightlies.videolan.org/

http://git.videolan.org/?p=vlc.git;a=blob_plain;f=NEWS;hb=HEAD

Edited by Vic
  • Like 1
Link to comment

Hi again,

thanks for new infos Vic. Tu ne parles pas français? :) I'm just kidding. As I said, just would like to have a dot instead of comma to paste timestamps in tools like VD and others who don't handle commas. Would be cool if players like VLC could handle / showing the VTT subtitle on same way like in YT / HTML5 players on internet.

Alright, one more questions I have about making a own compiled version as you told me before I should enter commands from instructions file.

https://github.com/vic4key/videogrep/blob/master/instructions.txt

So I have installed Python already & git cli too. So in GitHub CLI I tried to execute some commands for testing and I always get a message to login / auth?

gh issue list

Welcome to GitHub CLI!

To authenticate, please run `gh auth login`.

What login? Is it only working when I did login? Sounds bad! Now I tried to execite your commands from instructions and it stopped to work at this command...

git clone https://github.com/vic4key/videogrep.git  <---
                                                         
Der Befehl "git" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.                                                        

...not working / found etc. Why? How to make that work? So git is a command of GitHub CLI right? Just tell me what to do here to make it work. Thanks.

greetz

Link to comment
7 hours ago, LCF-AT said:

...not working / found etc. Why? How to make that work? So git is a command of GitHub CLI right? Just tell me what to do here to make it work. Thanks.

Git != GitHub. I don't use gh.exe. I use git.exe. Install git.exe from https://git-scm.com/downloads, then make sure it's appended to %PATH% after installed. If not, you need to do it manually.

See more https://www.geeksforgeeks.org/difference-between-git-and-github/

  • Like 1
Link to comment

Hi again,

so you told before to install that CLI git...

Required PC has python 3.6+ & virtualenv & git cli.

....and I did install that. Now I tried to install that other thing you said called "Git-2.36.1-64-bit.exe" but I did aboard the installer because its asking tons of questions etc. :( No clue what to choose or not. Is there something more simple to download & install?

So I found that git.exe file on my system in any mingw64\bin folder I was playing around with a longer while ago. Could that be working too just using this file?

greetz

Link to comment

Just download EXE and install or to save time. You can contact me via Telegram, Skype, or anything else directly for quick @vic4key

  • Like 1
Link to comment

Hi again @Vic,

so I tried using that git.exe file I found on my PC and this works. :) Now I did done all steps you told me in your instruction file...

python3 -m venv videogrep-exe
cd videogrep-exe
Scripts\activate.bat

git clone https://github.com/vic4key/videogrep.git
cd videogrep

python -m pip install --upgrade pip
pip install -r videogrep\requirements.txt
pip install pyinstaller==4.10

python main.py -i tests\manifesto.mp4 --transcribe # test - to make sure videogrep package works  <---- did work

builder.cmd  <--- create executable file

videogrep -i tests\manifesto.mp4 --transcribe # test - to make sure exe works   <---- this now failed

Here the error...

(videogrep-exe) C:\videogrep-exe\videogrep>videogrep -i tests\manifesto.mp4 --transcribe
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from videogrep.cli import *
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "videogrep\__init__.py", line 3, in <module>
    from . import vtt, srt, sphinx, fcpxml
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "videogrep\fcpxml.py", line 1, in <module>
    from moviepy.editor import VideoFileClip
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "moviepy\editor.py", line 87, in <module>
  File "<string>", line 1, in <module>
AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
[3472] Failed to execute script 'main' due to unhandled exception!

Why do I get a error now and how to fix this? By the way, so on first test using the python script with your manifesto video it did work and it did create a JSON and srt file but the srt files inside had still commas..

00:01:04,799  <---, no . dot

....did you not add that? There is another problem with the timecode format in srt file whats showing like this...

1
00:00:1,590 --> 00:00:3,660
this audiobook is in the public domain

2
00:00:4,020 --> 00:00:5,370
you can find the text version of this

....so can you fix that and make the "," to "." and fill the not used digit places with 0 like this...

1
00:00:01.590 --> 00:00:03.660
this audiobook is in the public domain

2
00:00:04.020 --> 00:00:05.370
you can find the text version of this

....so the time format should always have 9 digit places like this  "xx:xx:xx.xxx" so maybe you check and fix this too later.

 Alright, so now you need to tell me what to execute again one by one to make it work to compile a ready exefile. So what did you mean with this...

# let copy overwrite `site-packages` to venv's `site-packages` to fix moviepy's bugs
# patch file like `site-packages\moviepy\audio\io\readers.patch`
# patch file like `site-packages\moviepy\video\io\ffmpeg_reader.patch`

....maybe you tell me again.

greetz

Link to comment
6 hours ago, LCF-AT said:

Alright, so now you need to tell me what to execute again one by one to make it work to compile a ready exefile. So what did you mean with this...

# let copy overwrite `site-packages` to venv's `site-packages` to fix moviepy's bugs
# patch file like `site-packages\moviepy\audio\io\readers.patch`
# patch file like `site-packages\moviepy\video\io\ffmpeg_reader.patch`

....maybe you tell me again.

Do not ignore any step. These are important steps you have to do to fix the error you got above.

The moviepy library per se several bugs that I told you and mentioned at the post "Posted Friday at 09:26 AM".

Details to fix its bugs as following:

#1 - Just copy overwrite "C:\videogrep-exe\videogrep\site-packages" to "C:\videogrep-exe\Lib\site-packages"

#2 - In the file "C:\videogrep-exe\Lib\site-packages\moviepy\audio\io\readers.py", find the function "def close_proc" and
- Change "self.proc.terminate()" to "# self.proc.terminate()"
- Change "self.proc.wait()" to "# self.proc.wait()"

#3 - In the file "C:\videogrep-exe\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", find the function "def close" and
- Change "self.proc.terminate()" to "# self.proc.terminate()"
- Change "self.proc.wait()" to "# self.proc.wait()"

After finish 3 above steps, the error will be resolved.

 

6 hours ago, LCF-AT said:

By the way, so on first test using the python script with your manifesto video it did work and it did create a JSON and srt file but the srt files inside had still commas..

6 hours ago, LCF-AT said:

....did you not add that? There is another problem with the timecode format in srt file whats showing like this...

6 hours ago, LCF-AT said:

....so can you fix that and make the "," to "." and fill the not used digit places with 0 like this...

6 hours ago, LCF-AT said:

....so the time format should always have 9 digit places like this  "xx:xx:xx.xxx" so maybe you check and fix this too later.

Yep. I did not change it. I said you can do it yourself. But alright, I updated the codes for you, the changes at https://github.com/vic4key/videogrep/commit/cdbfcf3a9c1d86c1d073dcacc11cd9de5f6dad9f

To get these changes to your PC, move CMD to your directory at C:\videogrep-exe\videogrep, and run the command git pull origin master

Note: Do not forget to activate the current python virtualenv by the command ..\Scripts\activate.bat (after ran, CMD showed "(videogrep-exe) C:\videogrep-exe\videogrep>"

Then, re-test python main.py -i tests\manifesto.mp4 --transcribe, ... The result is will be like this

1
00:00:01.590 --> 00:00:03.660
this audiobook is in the public domain

2
00:00:04.020 --> 00:00:05.370
you can find the text version of this

 

Ok. Now. Get it done !

Edited by Vic
  • Like 1
Link to comment

Hi Vic,

listen, you need to explain it a little better. Its just NOT WORKING! I always get those errors in the compiled exe file...

(videogrep-exe) C:\videogrep-exe\videogrep>videogrep -i tests\manifesto.mp4 --transcribe
Traceback (most recent call last):
  File "main.py", line 1, in <module>
    from videogrep.cli import *
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "videogrep\__init__.py", line 3, in <module>
    from . import vtt, srt, sphinx, fcpxml
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "videogrep\fcpxml.py", line 1, in <module>
    from moviepy.editor import VideoFileClip
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod03_importers.py", line 495, in exec_module
  File "moviepy\editor.py", line 87, in <module>
  File "<string>", line 1, in <module>
AttributeError: module 'moviepy.audio.fx.all' has no attribute 'audio_fadein'
[3044] Failed to execute script 'main' due to unhandled exception!

(videogrep-exe) C:\videogrep-exe\videogrep>

I tried diffrent things. First I tried just to put the 2 .patches files in to the right lib folders and I thought it would work without to edit the original 2 files but it did not. Then I just did copy the site-packages folder into the lib site-packages as you said but this failed too because of missing files from original site-packages folder. Now I did just edit the 2 original files readers.py & ffmpeg_reader.py and did the # sign on the right 2 locations and did save it and tried to compile new but oh wonder it failed too with same error again. So what to do now? So in your site-packages folder are already the 2 files with patch extension so why is it not enough just to copy those patch files into the original...

\Lib\site-packages\moviepy\video\io\ & \Lib\site-packages\moviepy\audio\io\ folder? Just tell me again what to do to make it work. Thank you.

greetz

Link to comment

 Oops.

1 hour ago, LCF-AT said:

listen, you need to explain it a little better. Its just NOT WORKING! I always get those errors in the compiled exe file...

Take a look at https://github.com/Zulko/moviepy/issues/591

 

Don't do different things. Why don't you do the steps ordered as I said. It must be ordered. You have to make sure the result of steps as the following:

 

STEP #1

15 hours ago, Vic said:
#1 - Just copy overwrite "C:\videogrep-exe\videogrep\site-packages" to "C:\videogrep-exe\Lib\site-packages"

The result of this step must be as the following (the purpose is patching 2 files __init__.py😞

- The content of "C:\videogrep-exe\Lib\site-packages\moviepy\audio\fx\all\__init__.py" must be like this https://github.com/vic4key/videogrep/blob/master/site-packages/moviepy/audio/fx/all/__init__.py

- The content of "C:\videogrep-exe\Lib\site-packages\moviepy\video\fx\all\__init__.py" must be like this https://github.com/vic4key/videogrep/blob/master/site-packages/moviepy/video/fx/all/__init__.py

 

STEP #2 (after STEP #1 finished)

15 hours ago, Vic said:
#2 - In the file "C:\videogrep-exe\Lib\site-packages\moviepy\audio\io\readers.py", find the function "def close_proc" and
- Change "self.proc.terminate()" to "# self.proc.terminate()"
- Change "self.proc.wait()" to "# self.proc.wait()"

#3 - In the file "C:\videogrep-exe\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", find the function "def close" and
- Change "self.proc.terminate()" to "# self.proc.terminate()"
- Change "self.proc.wait()" to "# self.proc.wait()"

Modify 2 original files (readers.py & ffmpeg_reader.py) as you did. The result must be like this

image.png.8d728bcf441830dabd8ef5afff7130b3.png image.png.cdf8ba9e9e12c7c58fb38c0b6a4d0310.png

But I guess that the cause of your error is doing wrong in STEP #1. Let try. God bless you!

Edited by Vic
  • Thanks 1
Link to comment

Hi @Vic,

thanks again for your answer. First the good news is I got it working now. :) NOW.....I just did copy & paste that folder as you said already before and then I tried to compile new file and this works now!=? But I don't know why and what the diffrent is compared to my manually steps I did before. So if I understand it right then the copy / past process does just copy the 2 patch files into the folders and thats it right?

This 2 files get copied only.
C:\videogrep-exe\Lib\site-packages\moviepy\audio\io\readers.patch
C:\videogrep-exe\Lib\site-packages\moviepy\video\io\ffmpeg_reader.patch

Somehow it works now but before I did those steps also manually to copy & paste both patch files into right folders and also trying to manually patch the 2 py files (same as in patch files) did not work before. Just don't understand it why copy / paste of folder does work here. Strange. Ok, so it works now and I'am happy so far. :) New output of srt files is like I wanted...

1
00:00:01.590 --> 00:00:03.660
this audiobook is in the public domain

2
00:00:04.020 --> 00:00:05.370
you can find the text version of this

....isn't it pretty? :) Wonder nice. Sorry if I was a little bit annoying, maybe. :) Now I got one more question about that VTT (vtt.py) script. So in the package of your in your test folder with the video I could see 3 files (JSON, SRT & VTT). So did you also add a support to output a VTT file too? So in my case I just get JSON & SRT files out but not VTT file. Just asking about it whether I should also get a VTT file or not.

greetz

Link to comment
35 minutes ago, LCF-AT said:

So if I understand it right then the copy / past process does just copy the 2 patch files into the folders and thats it right?

No, wrong. But let it be. You don't know what the .patch file is? I don't tell you to copy the .path file, the .patch files in my repo just showing which code lines are modified in STEP #2, you look at .path file to know how to modify in your side.

 

35 minutes ago, LCF-AT said:

Sorry if I was a little bit annoying, maybe.

Annoying? I think it's me, not you guy. But ok. It's over. Next time, just step by step do as I instruct and it must work.

 

35 minutes ago, LCF-AT said:

Just don't understand it why copy / paste of folder does work here. Strange. Ok, so it works now and I'am happy so far. :) New output of srt files is like I wanted...

 

It worked. Let it be.

 

35 minutes ago, LCF-AT said:

So in the package of your in your test folder with the video I could see 3 files (JSON, SRT & VTT). So did you also add a support to output a VTT file too? So in my case I just get JSON & SRT files out but not VTT file. Just asking about it whether I should also get a VTT file or not.

No. I don't. It existed from the beginning. Maybe, has a supported parameter to extract .VTT file. Let try to read the document to find it.

  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...