Thursday, January 5, 2023

How to extract Chinese hardcoded subtitles from video files

Here is a simple way to extract Chinese hardcoded subtitles from video files for free.

It will help to have basic knowledge about ffmpeg. You will need to be patient if your video file has a lot of hardcoded subtitles. You can try this tutorial on a short video clip that has hardcoded subtitles to see how it works. A lot of movie trailers have hardcoded subtitles. 1 - Cropping the video file: Here is is the ffmpeg script to crop the video.mp4 file used in this tutorial. Please adjust parameters according to your video file and note the file extension ffmpeg -i video.mp4 -filter:v "crop=1850:250:0:830" -c:a copy video-cropped.mp4
Note the crop parameter is "crop=Croped Length:Croped Width:Start X:StartY"
2 - Inserting Timestamps into the video file: This is the ffmpeg script to embed timestamps in video-cropped.mp4 ffmpeg -i video-cropped.mp4 -vf "drawtext=text='timestamp\: %{pts \: hms}': x=0: y=2: fontsize=28:fontcolor=yellow: box=1: boxcolor=black" -c:a copy video-cropped-timestamps.mp4
Note the ':' is an argument separator in ffmpeg so if the parameters contains ':' , it should be escaped using '\'
3 - Creating Image Files every second: This is the ffmpeg script to create image files every second from video file video-cropped-timestamps.mp4 ffmpeg -i video-cropped-timestamps.mp4 -start_number 1 -vf fps=1 video-%04d.jpg Note: For a long movie, creating image files every 1 second will generate a huge number of files. You could try creating image files every 2 or 3 seconds or even more.
Here is the script every 2 seconds ffmpeg -i video-cropped-timestamps.mp4 -start_number 1 -vf fps=1/2 video-%04d.jpg Here is the script every 3 seconds ffmpeg -i video-cropped-timestamps.mp4 -start_number 1 -vf fps=1/3 video-%04d.jpg

Note it's better to set to create images every seconds so that those short subtitles will not be missed.

4 - Using Adobe Bridge/ACD See to select images with first appeared text:
Using ctrl-I to flag those images using Adobe Bridge (ACDSee had similar functionality and much smaller than Adobe Bridge) and copy them to different folder
Select 60 images each time and print them into one pdf using Microsoft print to pdf with Unchecked fit pictures to frame option.

Upload the pdf file to Google Drive and open it using Google Docs to do OCR and copy result into text file.
Edit the text file to fix some errors.

5. Using special text editor to block select time frames and text separately and save to different text files and Import the 2 files into Subtitle Edit and combine those repeating and save to srt file.

6. Load the video with hardcoded subtitle into Subtitle Edit with the new edited srt file. Synchronize the new subtitle file with video.

The final text file can be used as subtitle file.

The above tip is from following youtube link but I added my own note above when I applied them:
https://www.youtube.com/watch?v=2o08WUNDUfY

Friday, August 30, 2019

AngularJS Binding Explain

AngularJS has 3 bindings inside a directive. @, =, and &.

@  attribute string binding
 =   two way binding
 &  callback method binding

For @, it is the binding for passing strings. The variables inside the directive's parent scope can pass into the current directive. Using @ looked like the current directive has parameters who was passed by their parent html.

For =, it is the two way model binding, Usually it will be a model which exists both in the current directive's isolated scope and the parent directive's scope. The 2 models are linked together so that any change in one model will be reflected in another model.

For &, it is the methods from the parent scope, so that the current directive can use the method in the parent directive's scope.


https://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope-in-angularjs

Tuesday, April 23, 2019

Visual Studio Compile error The item "obj\Debug\SampleProject.Forms.MDIMain.resources" was specified more than once in the "Resources" parameter.

When merged develop branch to master branch it could happen that the project file contains repeating items. As result, compiling your visual studio project will have such compile error like:
The item "xxx" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.

The solution is easy:
1. Right click on your project and select "Unload the project"
2. Right click on your project and select "Edit YourProject.csproj"
3. Locate the repeating items and remove them.
4. Reload the project

Then these compile error will be resolved.



Resolve issues while openning old project in Visual Studio 2015/2017

When you opened your old project in Visual studio 2015/2017, you will find a lot of missing packages. When you tried to install any one of those missing packages, the visual studio will warn you that the soltuion is not saved.

How to resolve this?

My easy solution is:

1. Under File, choose save your solution.
2. Open Tools, Nuget Package Manager, Package Manger Console, and enter following command:

Update-Package –reinstall Microsoft.AspNet.Web.Optimization

Note Microsoft.AspNet.Web.Optimization can be any one of your missing package, then all missing package will be reinstalled automatically.

Reference:
https://developercommunity.visualstudio.com/content/problem/40958/update-package-reinstall-forces-all-packages-to-re.html

Thursday, March 28, 2019

How to upload local project from windows to github

First you need to install Git for Windows, once it's done, using Command Prompt and enter following commands:

cd <the folder>
git init
git add .   //for all files under the folder
commit -m "adding files" git remote add origin https://github.com/<your-user-name>/<your-repository-name>.git
git push -u origin master

how-to-upload-a-project-to-github

Tuesday, May 22, 2018

Process with an ID #### is not running on Visual Studio 2015

When I installed both Visual Studio 2013 and 2015 on my computer,  and use 2013 to open my visual studio web project and doing my test/run at first without problem, and then use 2015 to open the same project and choose to debug, there is error "Process with an ID #### is not running" on Visual Studio 2015. I google the issue and there is following solution:

  1. Delete the \Documents\IISExpress folder using the following console command:
  2. Delete the applicationhost.config file which is placed within the \.vs\Config\ folder in your Visual Studio project root folder.
I tried both and the issue is gone. I think it's because 2013 had created some files which was used by 2015 but have issues.

https://www.ryadel.com/en/process-id-not-running-visual-studio-2015-fix/

Tuesday, May 8, 2018

Git Bitbucket Stage VS Unstage

According to Johannes Kilian, "the staging area is a container where git collects all changes which will be part of the next commit". Inside bitbucket, when you staging the file, you put the uncommited file into the staging area. "The next git commit will transfer all items from staging into your repository".

When you have multiple bugs to be fixed, you don't want to commit all your changes, you select the code you want to commit and do staging them. Through this way you will have a clean commit specific for one bug.

You can choose complete files, hunks (part of one file), or single line for staging.

https://community.atlassian.com/t5/Sourcetree-questions/Staged-vs-Unstaged/qaq-p/127916