Activity › Forums › Compression Techniques › ffmpeg add subtitle in video
-
ffmpeg add subtitle in video
Posted by Hoa Pham on September 23, 2010 at 7:24 amHi all.
I try to add a subtitle in a video by using ffmpeg. I try to convert from .avi to mp4 standart h264 mp4
My command like:
ffmpeg.exe -i test.avi
-scodec copy
-newsubtitle test.srt
-slang vie
-sbsf text2movsub-vcodec libx264
-b 950
-f mp4 test.mp4But it report at least an output specific
Chris Henderson replied 15 years, 2 months ago 4 Members · 5 Replies -
5 Replies
-
Michael Rampe
September 24, 2010 at 7:38 amHave you tried the subtitle file in the .txt format?
[hoa pham] “But it report at least an output specific”
Please post full output so versions, stream data and full errors can be seen.
[hoa pham] “-vcodec libx264
-b 950”Also post full command line. This is incomplete and will not encode with current versions. For libx264, you either specify all the options or use a preset.
Michael
“half-way to world domination A.K.A. the belligerent blue bike shed”
-
Hoa Pham
September 25, 2010 at 3:13 amif i don’t add subtitle the convert is correct:
ffmpeg.exe -i DearJohn.avi -vcodec libx264 -b 950 -f mp4 DearJohn.mp4But when i add a subtitle like this, it does not work:
ffmpeg.exe -i DearJohn.avi -scodec copy -newsubtitle kid.srt -slang vie -sbsf text2movsub -vcodec libx264 -b 950 -f mp4 DearJohn.mp4it notices At least one output file must be specified
I have tried subtitle .txt change .srt to .txt.
Can you have any idea?
-
Michael Rampe
September 25, 2010 at 8:30 amPlease post the full FFmpeg console output.
For example:FFmpeg version SVN-r23145, Copyright (c) 2000-2010 the FFmpeg developers
built on Jun 16 2010 19:15:10 with gcc 4.2.1 (Apple Inc. build 5646) (dot 1)
configuration: –enable-gpl –enable-postproc –enable-swscale –enable-libmp3lame –enable-libx264 –enable-nonfree –enable-shared –arch=x86_64 –enable-avfilter –enable-avfilter-lavf
libavutil 50.15. 2 / 50.15. 2
libavcodec 52.67. 0 / 52.67. 0
libavformat 52.62. 0 / 52.62. 0
libavdevice 52. 2. 0 / 52. 2. 0
libavfilter 1.20. 0 / 1.20. 0
libswscale 0.10. 0 / 0.10. 0
libpostproc 51. 2. 0 / 51. 2. 0
…(I am guessing you may be using an outdated version but want to make sure)
[hoa pham] “ffmpeg.exe -i DearJohn.avi -vcodec libx264 -b 950 -f mp4 DearJohn.mp4”
You stated that this works on your system but doesn’t with recent versions. The bitrate is far too low to be able to compress any video and libx264 doesn’t work without a preset or implicit encoding commands. The relevant warnings I get are:
“WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not kbits/s
…
[libx264 @ 0x10100d400]broken ffmpeg default settings detected
[libx264 @ 0x10100d400]use an encoding preset (vpre)”try “-b 950k” and “-vpre normal”
(I think you might have to specify the path to the location of the presets folder/file inside the FFmpeg folder on windows installs, not sure, I use *nix.)With your subtitle insert command:
One problem is your position of -newsubtitle… it belongs after the output.From the FFmpeg documentation:
“The -newvideo, -newaudio and -newsubtitle options have to be specified immediately after the name of the output file to which you want to add them.”I don’t have any subtitle files to replicate this at the moment but you could try:
ffmpeg -i [video_input] -i [subtitle input] [encode_parameters] [output_file] -newsubtitle
or in your case something like:
ffmpeg.exe -i DearJohn.avi -i kid.srt -vcodec copy -acodec copy -scodec copy DearJohn.mp4 -slang vie -newsubtitle
Let me know how you go…
Michael
“half-way to world domination A.K.A. the belligerent blue bike shed”
-
Al Munoz
January 12, 2011 at 11:22 pmHi Michael,
I tried the command line that you recommended, but It didn’t work for me. I got the same error with any subtitle file. I think FFmpeg can read those files.
My command line is:
ffmpeg.exe -i myAVItest.avi -i myAVItest.srt -vcodec copy -acodec copy -scodec copy myNEWAVItest.avi -slang vie -newsubtitlewhere
myAVItest.avi is the video
myAVItest.srt is the subtitle file
myNEWAVItest.avi is the new fileHere is my results:
C:\ffmpeg.exe -i myAVItest.avi -i myAVItest.srt -vcodec copy -acodec copy -scodec copy myNEWAVItest.avi -slang vie -newsubtitleFFmpeg version SVN-r23012, Copyright (c) 2000-2010 the FFmpeg developers
built on May 3 2010 19:05:24 with gcc 3.4.5 (mingw-vista special r3)
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffs
erver --enable-memalign-hack --enable-libmp3lame --enable-w32threads --extra-ldf
lags=-L/static/lib --extra-cflags=-I/static/include
libavutil 50.15. 0 / 50.15. 0
libavcodec 52.66. 0 / 52.66. 0
libavformat 52.62. 0 / 52.62. 0
libavdevice 52. 2. 0 / 52. 2. 0
libswscale 0.10. 0 / 0.10. 0Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/
2733) -> 23.98 (24000/1001)
Input #0, avi, from 'myAVItest.avi':
Metadata:
ISFT : VirtualDubMod 1.5.4.1 (build 2178/release)
IAS1 : English
Duration: 01:30:10.82, start: 0.000000, bitrate: 1093 kb/s
Stream #0.0: Video: mpeg4, yuv420p, 688x288 [PAR 1:1 DAR 43:18], 23.98 tbr,
23.98 tbn, 23.98 tbc
Stream #0.1: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/smyAVItest.srt: Invalid data found when processing input
I’d appreciate your help!
-
Chris Henderson
June 2, 2011 at 1:52 amDoes your AC3 have embedded timecode or other header info that the AC3 decoder in FFMPEG doesn’t support?
-CJ
Reply to this Discussion! Login or Sign Up