ffmpeg subtitle background - ffmpeg

I am trying to add subtitles to a video in marathi language and to make it user friendly i have added a background to subtitle however there are some black lines coming in the background. Please help me in removing those lines.
ffmpeg -i output_mp4.mp4 -vf "subtitles=transcript_srt.srt: force_style='OutlineColour=&H80000000,BorderStyle=3,Outline=1,Shadow=1'" -c:a copy output_srt.mp4
This is the command i have used.

Related

burning subtitles onto mp4, such that they always show, and cannot be turned off

I have successfully create a command line that allows subtitles to be displayed, I can see them when I select the track number in VLC. What I would like is to burn the subtitles such that they always show when the mp4 is played by any player, and not provide the option to be turned off. All i need is a clue to pursue. does ffmpeg have an option to do this.
Thanks.
Use the subtitles filter to make hardsubs (burnt-in subtitles).
Assuming you have a subtitles file named sub.srt:
ffmpeg -i input.mkv -vf "subtitles=sub.srt" output.mp4
Or if the subtitles are in input.mkv:
ffmpeg -i input.mkv -vf "subtitles=input.mkv" output.mp4

FFMPEG - crop and pad a video (keep 3840x1920 but with black borders)

I am trying to crop a video so that I can remove a chunk of the content from the sides of a 360-degree video file using FFmpeg.
I used the following command and it does part of the job:
ffmpeg -i testVideo.mp4 -vf crop=3072:1920:384:0,pad=3840:1920:384:0 output.mp4
This will remove the sides of the video and that was initially exactly what I wanted (A). Now I'm wondering if it is possible to crop in the same way but to keep the top third of video. As such, A is what I have, B is what I want.:
I thought I could simply do this:
ffmpeg -i testVideo.mp4 -vf crop=3072:1920:384:640,pad=3840:1920:384:640 output.mp4
But that doesn't seem to work.
Any input would be very helpful.
Use the drawbox filter to fill cropped portion with default colour black.
ffmpeg -i testVideo.mp4 -vf drawbox=w=384:h=1280:x=0:y=640:t=fill,drawbox=w=384:h=1280:x=3840-384:y=640:t=fill -c:a copy output.mp4
The first filter acts on the left side, and the 2nd on the right.

Draw text ffmpeg does not end when the word ends

It works very well. But it can not end the video while the text has run out. And it runs forever. The bottom is my code. It has gaps with the background image forever. I want to stop it when the text is over. please complete it help me.
ffmpeg -loop 1 -i "C:\Users\Cu\Desktop\Lam\Lam\a.jpg" -i "C:\Users\Cu\Desktop\Lam\Lam\a.mp3" -vf drawtext='fontfile="Arial"\:style=bold:fontsize=70:textfile="C\:/Users/CuEm/Desktop/91990756.txt":fontcolor=#FFFFFF':x=0:y=h-20*t,format=yuv420p,scale=852x480,setsar=1:1 -vcodec libx264 -b:v 1000k -preset superfast "C:\Users\Cu\Desktop\b_o.mp4"
enter image description here
The drawtext filter has no concept of completion or progress. Assuming that you want the video to stop when the audio does, add -shortest.

ffmpeg add text with fade in effect

I am trying to create a simple music video with a single image background and the lyrics showing up in a fade in and fade out effect during the video.
Like stuff done with After Effects. Can a quality fade in and fade out be done with ffmpeg?
What would be the command to call when trying to achieve a simple text fading in the middle of the video at about 10s, fading out at 15s and then the next one? etc...
If possible please include a solution with background image.
Use ASS subtitles. They are easy to create in Aegisub. If you must have fades use the /fade or /fad override tags.
Once you make the subtitles you can run your ffmpeg command:
ffmpeg -loop 1 -i bg.png -i music.m4a -vf "subtitles=lyrics.ass" -c:a copy -vf format=yuv420p -shortest output.mkv

How to Add Font size in subtitles in ffmpeg video filter

I'm using this command to crop,scale, and then add subtitles as overlay
ffmpeg -i input.avi -vf "[in]crop=in_w:in_h-20:0:0 [crop]; [crop]scale=320:240 [scale];[scale]subtitles=srt.srt" -aspect 16:9 -vcodec libx264 -crf 23 oq.mp4
how can we set font size/color of subtitle ?
There are two methods to use subtitles: hardsubs and softsubs.
Hardsubs
The subtitles video filter can be used to hardsub, or burn-in, the subtitles. This requires re-encoding and the subtitles become part of the video itself.
force_style option
To customize the subtitles you can use the force_style option in the subtitles filter. Example using subtitles file subs.srt and making font size of 24 with red font color.
ffmpeg -i video.mp4 -vf "subtitles=subs.srt:force_style='Fontsize=24,PrimaryColour=&H0000ff&'" -c:a copy output.mp4
force_style uses the SubStation Alpha (ASS) style fields.
PrimaryColour is in hexadecimal in Blue Green Red order. Note that this is the opposite order of HTML color codes. Color codes must always start with &H and end with &.
Aegisub
Alternatively, you can use Aegisub to create and stylize your subtitles. Save as SubStation Alpha (ASS) format as it can support font size, font color, shadows, outlines, scaling, angle, etc.
Softsubs
These are additional streams within the file. The player simply renders them upon playback. More flexible than hardsubbing because:
You do not need to re-encode the video.
You can have multiple subtitles (various languages) and switch between them.
You can toggle them on/off during playback.
They can be resized with any player worth using.
Of course sometimes hardsubs are needed if the device or player is unable to utilize softsubs.
To mux subtitles into a video file using stream copy mode:
ffmpeg -i input.mkv -i subtitles.ass -codec copy -map 0 -map 1 output.mkv
Nothing is re-encoded, so the whole process will be quick and the quality and formats will be preserved.
Using SubStation Alpha (ASS) subtitles will allow you to format the subtitles however you like. These can be created/converted with Aegisub.
Also see
subtitles video filter documentation
How to burn subtitles into the video
How to convert subtitle from SRT to ASS format
From the documentation you can use a srt subtitle file and change the size of the font by putting ASS style format KEY=VALUE pairs separated by ,. So,
ffmpeg -i input.mp4 -vf subtitles=sub.srt:force_style='FontName=DejaVu Serif,FontSize=24' -vcodec libx264 -acodec copy -q:v 0 -q:a 0 output.mp4
will put the subtitles with DejaVu font and size 24 while keeps the quality of the video. I've tried myself and it worked.
FFmpeg is good sometimes, but some videos can becoms blurry. I recoomend to compare with VLC player.
media>Convert/Save
I find the default settings for Profile Video for iPad HD/iPhone/PSP is very good. Or I can reduce the Biterates from 700kb/s to 350kb/s to make smaller.

Resources