Hello i need to embed srt files into 1000 videos. I have all the videos and individual srt files
Can any one suggest me a batch program that does this in window operating system.
This thread talked about MAC operating. I am looking for windows 7. operating system
Regards
Kamalakar
Try StreamFab Downloader and download from Netflix, Amazon, Youtube! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 30 of 65
Thread
-
-
Dear Sir,
Appreciate your reply. This really helps a lot.
What i reviewed the google search and youtube i saw is that once we open the video we have to switch on particular drop down menu item to see subtitles
What i am looking is hard code the subtitles, ie the subtitles becomes part of the picture so that no user can remove them.
We want to get the subtitles in a particular colour with a font size of 12 or 14 centered at the bottom.
Does such a feature exist in ffmpeg.
I should have been more specific, my videos are in .mp4 format. so
how does this command change.
for %%g in (*.mkv,*.avi,*mp4) do ffmpeg -i %%g -vf subtitles=%%~ng.srt %%~ng_WithSub.mkv
Is it that the output will be in .mkv format, will i not get output in .mp4 format.
Regards
Kamalakar
-
Ok I need to go through the doccumentation given here.
http://ffmpeg.org/ffmpeg-filters.html#subtitles-1
Once i acheive this i will post the entire code for the benefit of the remaining users
If any one has all ready done this earlier kindly share other wise.
My requirement is 1000 .mp4 files with to be
hard coded with
Input files fomrat: .mp4
Font Type: utf-8 srt files
Color: green or red or white colour
Font Size: 14
Position: Centered at the bottom of the video.
Output .mp4 files
Regards
Kamalakar -
We want to get the subtitles in a particular colour with a font size of 12 or 14 centered at the bottom.
.ass subtitles offers more formatting. Then instead of using the -vf subtitles= you would use -vf ass=. Subtitle Edit can with CLI convert all .srt to .ass.
I should have been more specific, my videos are in .mp4 format.Code:for %%g in (*.mkv,*.avi,*mp4) do ffmpeg -i %%g -vf subtitles=%%~ng.srt %%~ng_WithSub.mp4
-
It is possible to select color, size and position by using a combination in the SRT subtitles and the script for FFMPEG. Using the following SRT subtitle example:
1
00:00:01,000 --> 00:00:03,123
This is the first subtitle
2
00:00:04,000 --> 00:00:06,000
Another subtitle demonstrating tags:
<b>bold</b>, <i>italic</i>, <u>underlined</u>
<font color="#ff0000">red text</font>
3
00:00:07,000 --> 00:00:10,000 X1:40 X2:600 Y1:20 Y2:80
Another subtitle demonstrating position.
Code:ffmpeg -i "C:\Users\Bud\Desktop\[dp]Manjandani-1.mp4" -ss 00:00:00.000 -to 99:00:00.000 -vf "subtitles='C\:\\Users\\Bud\\Desktop\\[dp]Manjandani-1.srt:force_style=Fontsize=24,PrimaryColour=&Hffffff&'",scale=704:368,pad=704:368:0:0 -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Bud\Desktop\[dp]Manjandani-1_Timed_2.mp4"
[Attachment 44117 - Click to enlarge]
... and you will get a very nice combination of subtitle formats and size.
[Attachment 44118 - Click to enlarge]
[Attachment 44119 - Click to enlarge] -
Sir,
Appreciate your reply.
Will it hard code the subtitles to the vdieo
You are showing me some menu. Can this be done from command prompt.
Regards
Kamalakar -
Yes the larger subtitles are hardcoded, otherwise they would be normal sized. The menu was just to demonstrate and test the actual command line (they are shown in a pseudo command utility window used to test). I also included the ffmpeg command just in front of the image.
Change the command or use it in a modified batch file for your use. -
Merry Christmas to you and to all the volunteers here who also help others with their expert knowledge and help!!!
How to modify this command for UTF-8 font in SRT files
[Attachment 44126 - Click to enlarge]
[Attachment 44125 - Click to enlarge]
Additional information: If I run into filenames that my computer does not recognize such as Cyrillic filenames or containing Ellipsis characters or EM Dash (Long Dash), I add 'chcp xxxx' to the command line for whatever codepage recognizes it. In my case it is 'chcp 1252'. (chcp means change codepage)
[Attachment 44127 - Click to enlarge]Last edited by Budman1; 24th Dec 2017 at 19:43.
-
My Mother Tongue is Telugu an Indian langugage. While making the srt files i save the notepad as UTF-8 characters option
-
Seems like FFMPEG accepts utf-8 OK and works fine
FFPLAY
[Attachment 44133 - Click to enlarge]
FFMPEG Command Line
[Attachment 44134 - Click to enlarge] -
You are very innovative and helpful. I never expected that you will wish me in my mother tongue. Great.
What is your actual name and where do you stay
How do i open the command line utility form
Regards
Kamalakar -
You cannot open the command line Utility. It is part of a GUI program that I wrote to perform many of the repeated requests on this site. I use it to demonstrate and test that the information I give actually works with the actual command line. The Command line utility is simply a DOS (CMD) functional form that peforms the CMD function. If you see it there it will work in a normal CMD Window.
Just open the FFMPEG scripts in a CMD Window and they should run the same as in my Utility, since it is simply a GUI CMD Window. My Utility
takes video conversions (Image2Video, mp42flv, lighten, add subtitles, etc as noted by the tabs) and outputs the correct ffmpeg string for people to match against the images they come from.
For Instance:
I used the Image2Vid tab to create a 10 second video of my Avatar image. Then added the subtitles to the video with the Extract/Edit tab and hit 'Extract by Time' and it created the correct FFMPEG string which I can view, change or execute to make sure it works and that new versions of FFMPEG work as correctly as when I wrote the program.
[Attachment 44136 - Click to enlarge]
[Attachment 44137 - Click to enlarge]
Notice how the above settings match the script below. This allows seeing how FFMPEG script is set up to match the requested functions.
[Attachment 44138 - Click to enlarge]
Okay time to turn in and let Santa arrive. LOL Merry Christmas to all!!!Last edited by Budman1; 24th Dec 2017 at 23:49.
-
Sir,
In the code you have sent what does these things do
scale=704:368,
pad=704:368:0:0
-vcodec libx264 -crf 22 -r 23.976
-acodec aac -ac 2 -ar 44.1k -b:a 128k
Do i really need to specify these.
I understand fontsize and colour
How does the software understand that it has to place the subtiltes at the bottom centered of the video
Are these commands doing that. -
All these are entered into the ffmpeg script in case they are needed. The video i used was actually 2.25x1 aspect but stored as 704x368. I left it scaled smaller for upload since sqashing it didnt hurt the subtitle demo. Pad is actually empty since the last 2 zeroes means no pillar bars or letterbox bars. Both could be left off but they are there in case your video looks odd, they can be changed to correct.
The acodec (a.udio codec) and vcodec ( video codec ) are because hard coding subtitles reencodes the video and they choose h264 video and aac audio and the crf 22 sets the quality near where it was.
Subtitles SRT are set in the bottom middle by default by ffmpeg. -
Hi one more question. you have shown a program command line utillity program which is menu driven. i strongly feel ffmpeg is also at one point of time menu driven. i dont know in which language it is written. but the question is how do people convert it into .exe such that it can be run from command prompt with out using any software compiler program.
Suppose i write a program in say JAVA or PHP or C, or C++, how do you convert this so that it can be executed as dos prompt command -
Our video is 480 pixels video and we want it to be remained as it is, I wish the above command does not change the pixes.
-
Sir,
I Modified your command to my files . I am getting the error shown in the attached jpeg image.
Can you kindly correct my code.
ffmpeg -i "C:\Users\Kamalakar\Desktop\upload\Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" -ss 00:00:00.000 -to 99:00:00.000 -vf subtitles='C:\Users\Kamalakar\Desktop\upload\Don't _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P rimaryColour=&H000000FF' " ,scale=704:368,pad=704:368:0:0 -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Kamalakar\Desktop\4.mp4"
https://files.videohelp.com/u/274393/1.jpg
https://files.videohelp.com/u/274393/srt.txt
Regards
kamalakarLast edited by kamalakar108; 25th Dec 2017 at 11:02. Reason: added error file and text file
-
You forgot the quotes in front of subtitles to match the one after the colour code. Also you could leave off the -ss time since it means beginning to 99 hours. Also -scale will make it 704x368. Leave it off or change to what you want. Pad you can leave off since you dont want black bars and it says 0,0 for no bars anyway.
Code:ffmpeg -i "C:\Users\Kamalakar\Desktop\upload\Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" -vf "subtitles='C:\Users\Kamalakar\Desktop\upload\Don't _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P rimaryColour=&H000000FF' " -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Kamalakar\Desktop\4.mp4"
-
You forgot the quotes in front of subtitles to match the one after the colour code. Also you could leave off the -ss time since it means beginning to 99 hours. Also -scale will make it 704x368. Leave it off or change to what you want. Pad you can leave off since you dont want black bars and it says 0,0 for no bars anyway. You have no trailing & on colour and too many 000000s. They designate blue,green and red in order so 0000ff means red. 00ff00 would mean green and ff0000 means blue and ffffff means all colors or white.
Code:ffmpeg -i "C:\Users\Kamalakar\Desktop\upload\Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" -vf "subtitles='C:\Users\Kamalakar\Desktop\upload\Don't _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,PrimaryColour=&H0000ff&'" -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Kamalakar\Desktop\4.mp4"
-
too many 000000sso 0000ff means red
-
Yes you can use transparency but you specified 00 which is the default. Just as i used -ss and pad and scale. I w as simplifying down to basic defaults , no transparency, no time duration, no pad etc. No scale or sizing. All of these can be used or not. Thats why i include in case anyone want them. Your example had a lot of missing quotes, extra spaces, etc so i gave an alternate defaulted example to make sure less possibilty of errors just to start. You are certainly correct about transparency though.
-
Sir, Conversion started and failed with the following error.
C:\Users\Kamalakar>ffmpeg -i "C:\Users\Kamalakar\Desktop\upload\Dont Surrender T
o Any Nonsense - Prabhupada 0004.mp4" -vf "subtitles='C:\Users\Kamalakar\Deskto
p\upload\Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=F
ontsize=24,PrimaryColour=&H000000FF' " -c mov_text -c:v copy -c:a copy -vcode
c libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k "C:\Users\Kama
lakar\Desktop\4.mp4"
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --e
nable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libblur
ay --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopu
s --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --ena
ble-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-lib
x264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-z
lib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-c
uvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-l
ibmfx
libavutil 55. 78.100 / 55. 78.100
libavcodec 57.107.100 / 57.107.100
libavformat 57. 83.100 / 57. 83.100
libavdevice 57. 10.100 / 57. 10.100
libavfilter 6.107.100 / 6.107.100
libswscale 4. 8.100 / 4. 8.100
libswresample 2. 9.100 / 2. 9.100
libpostproc 54. 7.100 / 54. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\Kamalakar\Desktop\upload\Dont
Surrender To Any Nonsense - Prabhupada 0004.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.14.100
Duration: 00:07:54.71, start: 0.000000, bitrate: 410 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 480x360 [
SAR 1:1 DAR 4:3], 277 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, flt
p, 125 kb/s (default)
Metadata:
handler_name : SoundHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[subtitles @ 0000000004db1400] Unable to parse option value "UsersKamalakarDeskt
opuploadDont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt" as image size
Last message repeated 1 times
[subtitles @ 0000000004db1400] Error setting option original_size to value Users
KamalakarDesktopuploadDont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt.
[Parsed_subtitles_0 @ 0000000004db1320] Error applying options to the filter.
[AVFilterGraph @ 00000000006cc440] Error initializing filter 'subtitles' with ar
gs 'C:\Users\Kamalakar\Desktop\upload\Dont _Surrender_To_Any_Nonsense_-_Prabhupa
da_0004_tel.srt:force_style=Fontsize=24,PrimaryCol our=&H000000FF'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
[aac @ 00000000006cf700] Qavg: 65536.000
[aac @ 00000000006cf700] 2 frames left in the queue on closing
Conversion failed!
Can you kindly correct the code.
https://files.videohelp.com/u/274393/1.txt
I removed the folder location in srt file name and it worked. how to run the file with srt file name having folder location includedLast edited by kamalakar108; 25th Dec 2017 at 20:48. Reason: added the content into a note pad and posted the link
-
Sir, I want to create the batch file in the following fashion. so that it would be easy for me to change my file names
@echo off
set folder_name ="Kamalakar\Desktop"
cd %folder_name%
cd upload
set input_file="Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt"
set output_file="4.mp4"
set srt_file="Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt"
echo input file name is %input_file%
echo output file name is %output_file%
echo srt file name is %srt_file%
ffmpeg -i %input_file% -vf "subtitles=' %srt_file%:force_style=Fontsize=24,PrimaryColour=& H000000FF' " -c mov_text -c:v copy -c:a copy -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k %output_file%
cmd
ffmpeg command is giving the following error. can you kindly correct the ffmpeg command
[NULL @ 00000000001245c0] Unable to find a suitable output format for '_Surrende
r_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P rimaryColou
r=&H000000FF' '
_Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P ri
maryColour=&H000000FF' : Invalid argument
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
Regards
kamalakar -
Okay... slowly now. You have been adding stuff and causing more errors.
First:
When you use the full path name in the subtitles filter you must use the backslash to escape the colon and backslashes in the name since they mean something else in FFMPEG and you must use an additional backslash as shown in my ORIGINAL example.
-vf "subtitles='C\:\\Users\\Bud\\Desktop\\[dp]Manjandani-1.srt:force_style=Fontsize=24,PrimaryColour=&Hffff ff&'"
Code:ffmpeg -i %input_file% -vf "subtitles=' %srt_file%:force_style=Fontsize=24,PrimaryColour=& H000000FF' " -c mov_text -c:v copy -c:a copy -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k %output_file%
1. FFmpeg is very specific where and what you type.. You put extra spaces in the areas in red above.
2. You left off the final & after colour 000000FF as in blue. This will give you Black color subtitles
3. -c mov_text is used for creating a subtitle TRACK not embedding.
4. -c:v copy says to copy the video but you cannot copy when re-encoding for hard subs. This is also overridden by the -vcodec selecting libc264 codec later
5. -c:a copy says to copy the audio, which you can do since it is not being changed due to encoding video but -acodec overrides it again with aac codec (one or the other).
Your batch will work as :
Code:@echo off set folder_name ="c:\users\bud\desktop" cd %folder_name% cd upload set input_file="[dp]Manjandani-1.mp4" set output_file="4.mp4" set srt_file="frame.srt" echo input file name is %input_file% echo output file name is %output_file% echo srt file name is %srt_file% ffmpeg -i %input_file% -vf "subtitles='%srt_file%:force_style=Fontsize=24,PrimaryColour=&H000000ff&'"^ -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k^ %output_file%
NOTE: Carat (SHift 6) is a dos continuation character. It will work using these instead of one lone string.Last edited by Budman1; 26th Dec 2017 at 00:06.
-
Sir,
I changed my inputs to as shown below. But i am getting the same error
[NULL @ 0000000002c0f900] Unable to find a suitable output format for '_Surrende
r_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P rimaryColou
r=&H000000ff&' '
_Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:force_style=Fontsize=24,P ri
maryColour=&H000000ff&' : Invalid argument
https://files.videohelp.com/u/274393/bat1.txt
May be it is adding spaces when we are posting through webbrowser and copying.
Can you kindly upload the text file and send the weblink. so that i will change only the file names and directory and not touch the ffmpeg command -
Looks like your CMD is sticking in extra " quotes due to the spaces in the SRT filename:
ffmpeg -i "Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" -vf "subtitles='"Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt
":force_style=Fontsize=24,PrimaryColour=&H000000ff& ' "
Some Dos environments do this automatically. Open a CMD window and drag your srt file to it and you will see it add quotes. Now take out the spaces and drag and drop and the quotes will probably not be there. Try it without spaces in the filenames.
You can try altering to accommodate space by changing SRT leading quote to single quote and none at the end
and remove the single quote after subtitles=.
Code:@echo off set folder_name ="desktop\upload" cd %folder_name% cd upload set input_file="Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" set output_file="4.mp4" set srt_file='Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt echo input file name is %input_file% echo output file name is %output_file% echo srt file name is %srt_file% ffmpeg -i %input_file% -vf "subtitles=%srt_file%:force_style=Fontsize=24,PrimaryColour=&H000000ff&' "^ -vcodec libx264 -crf 22 -r 23.976 -acodec aac -ac 2 -ar 44.1k -b:a 128k^ %output_file% pause
ffmpeg -i "Dont Surrender To Any Nonsense - Prabhupada 0004.mp4" -vf "subtitles='Dont _Surrender_To_Any_Nonsense_-_Prabhupada_0004_tel.srt:
force_style=Fontsize=24,PrimaryColour=&H000000ff&' " -
Sir,
This worked me too.
Appreciate your patience in solving my issue.
May lord bless you with all you require in your life.
Regards
Kamalakar.
Similar Threads
-
Batch script for forcing subtitles on MKV files.
By hemstock in forum SubtitleReplies: 2Last Post: 9th Oct 2015, 15:40 -
Batch muxing video files with subtitles
By calexicoca in forum SubtitleReplies: 4Last Post: 16th May 2015, 09:31 -
Using Ffmpeg to hard code subtitles
By wotdefcuk in forum SubtitleReplies: 21Last Post: 8th May 2014, 10:01 -
Free Video Encoder With Hard Code Subtitles Option Works on Server 2008
By lib3rty1 in forum Newbie / General discussionsReplies: 9Last Post: 3rd Oct 2013, 08:33 -
x264 CLI How to Hard-code Subtitles?
By dark_cross in forum SubtitleReplies: 4Last Post: 8th Apr 2013, 20:06