I've been using mkvmerge
to merge a video file and subtitles, I'm using the following command
mkvmerge -o output.mkv video.mp4 subtitles.srt
Which is working fine but as you can probably guess this is really slow operation
- I've to open terminal in every one of those directories where movies are stored.
- Then I've to copy and paste the names of the files in the command
- Then I've to rename the output file
- Then delete the original files which I used
This is a lengthy process.
Ideal situation that I want.
- I'll go into the folder which contains a movie file and a subtitle file with the same name.
- I select a movie file and and a subtitles file, right click and run a nautilus script on them.
- They get merged
- Original file gets deleted.
- Rename the merged file with the name of the orignal file with
mkv
extension
This doesn't need to be recursive, I don't want my HDD creating and deleting 100's of files at ones. Movie files and Subtitle files generally have the same name but some times have "_en" post fixed to subtitle files. If you have another approach of doing it I'm on board with that too.
I've decided to gain some experience with Bash and wrote the below script, that has next features:
mkvmerge
to merge video with subtitle files also usesnotify-send
to show some messages in GUI. Also it usesgvfs-trash
to move files in user's trash folder.notify-send
command exists into the script's body.The script:
Setup:
Create executable file and paste the above content inside. Let's call this file
merge-video-sub
:Copy (or
ln -s
) this file into the folder~/.local/share/nautilus/scripts
to make it available as Nautilus script for the current user.At the moment I can't find a way how to make it available system wide as Nautilus script.
Copy the file into
~/bin
(and addexport PATH=$PATH:~/bin
to the bottom of~/.bashrc
if is needed) to make it available as shell command for the current user.Copy the file into
/usr/local/bin
to make it available as shell command system wide.The short way is to
curl
the script from my PasteBin directly intonautilus/scripts
folder:Demo:
Additional references:
I made another script which has GUI. It can find all subtitle files with their related videos (searches for the same name) in folder and sub-folder and merge them at ones.
Here is GitHub link for the script: https://github.com/bhaktanishant/Total-Subtitle-Merger
Here is code :
How to use it as nautilus script:
paste this code to a file and name it
merge
.Now, open a terminal at the directory where you saved file
marge
and putmv merge ~/.local/share/nautilus/scripts/merge
and hit enter.now put
cd ~/.local/share/nautilus/scripts/
and hit enter.now put
chmod +x merge
and hit enter.now go to the root folder where movies and subtitles are and right click on any file or folder then select
scripts > merge
Done.
Here, I made a script for this. Just make sure there are only two files in your movie folder, one is your movie and other is the subtitle (they don't need to have the same name).
Create a file called
merge
at Desktop and paste this code:Now, open a terminal at the directory where you saved
marge
(In this case on Desktop) and putmv merge ~/.local/share/nautilus/scripts/merge
and hit enter.now put
cd ~/.local/share/nautilus/scripts/
and hit enter.now put
chmod +x merge
and hit enter.now go to the folder where movie and subtitle is and right click on any file then select
scripts > merge
Done.
If you have any problem, let me know.