Help: How to add subtitles to a video created from images?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Help: How to add subtitles to a video created from images?

Srinidhi S
I am trying to use ffmpeg to create a video from images and add subtitles to the video.
The following is the command that I am using
ffmpeg -f concat -i input.txt -i 02-38-2019-112729.m4a -vf "scale=1280:720,subtitles=subtitles.srt" -pix_fmt yuv420p output.mp4

where input.txt is a text file in the following format
file 'IMG_0001.JPG'
duration 2
file 'IMG_0002.JPG'
duration 50
file 'IMG_0002.JPG'

and subtitles.srt is a subtitle file. I find that while the video is generated, the subtitles are not present.

Can anyone point out what I am doing wrong?

The following is the ffmpeg output-
ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with Apple LLVM version 10.0.0 (clang-1000.11.45.5)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.1.1 --enable-shared --enable-pthreads --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags='-I/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/include -I/Library/Java/JavaVirtualMachines/openjdk-11.0.2.jdk/Contents/Home/include/darwin' --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libmp3lame --enable-libopus --enable-librubberband --enable-libsnappy --enable-libtesseract --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-videotoolbox --disable-libjack --disable-indev=jack --enable-libaom --enable-libsoxr
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
  libpostproc    55.  3.100 / 55.  3.100
Input #0, concat, from 'input.txt':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 4288x2848 [SAR 72:72 DAR 134:89], 25 tbr, 25 tbn, 25 tbc
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '02-38-2019-112729.m4a':
  Metadata:
    major_brand     : M4A
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2019-02-07T05:58:18.000000Z
  Duration: 00:00:49.09, start: 0.000000, bitrate: 107 kb/s
    Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 98 kb/s (default)
    Metadata:
      creation_time   : 2019-02-07T05:58:18.000000Z
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[Parsed_subtitles_1 @ 0x7faed8d0a4c0] Shaper: FriBidi 1.0.5 (SIMPLE) HarfBuzz-ng 2.3.0 (COMPLEX)
[Parsed_subtitles_1 @ 0x7faed8d0a4c0] Using font provider coretext
[swscaler @ 0x7faed9826600] deprecated pixel format used, make sure you did set range correctly
[libx264 @ 0x7faed9007000] using SAR=603/712
[libx264 @ 0x7faed9007000] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7faed9007000] profile High, level 3.1
[libx264 @ 0x7faed9007000] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output.mp4':
  Metadata:
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 603:712 DAR 134:89], q=-1--1, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      creation_time   : 2019-02-07T05:58:18.000000Z
      encoder         : Lavc58.35.100 aac
More than 1000 frames duplicated       0kB time=00:00:00.00 bitrate=N/A dup=49 drop=0 speed=   0x    
frame= 1349 fps= 96 q=-1.0 Lsize=    1785kB time=00:00:53.84 bitrate= 271.6kbits/s dup=1346 drop=0 speed=3.84x    
video:1012kB audio:744kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.638231%
[libx264 @ 0x7faed9007000] frame I:7     Avg QP:15.34  size:136979
[libx264 @ 0x7faed9007000] frame P:340   Avg QP:16.08  size:   116
[libx264 @ 0x7faed9007000] frame B:1002  Avg QP:23.29  size:    37
[libx264 @ 0x7faed9007000] consecutive B-frames:  1.0%  0.0%  0.0% 99.0%
[libx264 @ 0x7faed9007000] mb I  I16..4:  2.6% 69.2% 28.2%
[libx264 @ 0x7faed9007000] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.7%  0.0%  0.0%  0.0%  0.0%    skip:99.2%
[libx264 @ 0x7faed9007000] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%  L0:13.6% L1:86.4% BI: 0.0%
[libx264 @ 0x7faed9007000] 8x8 transform intra:69.2% inter:99.3%
[libx264 @ 0x7faed9007000] coded y,uvDC,uvAC intra: 96.0% 98.0% 96.2% inter: 0.0% 0.2% 0.0%
[libx264 @ 0x7faed9007000] i16 v,h,dc,p: 12% 16%  2% 69%
[libx264 @ 0x7faed9007000] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 18%  6%  7%  9% 10% 12% 10% 11%
[libx264 @ 0x7faed9007000] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 14% 16%  6%  8% 13% 12% 14%  8%  8%
[libx264 @ 0x7faed9007000] i8c dc,h,v,p: 40% 24% 19% 17%
[libx264 @ 0x7faed9007000] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x7faed9007000] ref P L0: 96.4%  0.3%  2.9%  0.4%
[libx264 @ 0x7faed9007000] ref B L0: 32.7% 67.3%
[libx264 @ 0x7faed9007000] ref B L1: 99.4%  0.6%
[libx264 @ 0x7faed9007000] kb/s:153.49
[aac @ 0x7faed9008800] Qavg: 53066.160



_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help: How to add subtitles to a video created from images?

Gyan


On 15-02-2019 10:49 AM, Srinidhi S wrote:

> I am trying to use ffmpeg to create a video from images and add subtitles to the video.
> The following is the command that I am using
> ffmpeg -f concat -i input.txt -i 02-38-2019-112729.m4a -vf "scale=1280:720,subtitles=subtitles.srt" -pix_fmt yuv420p output.mp4
>
> where input.txt is a text file in the following format
> file 'IMG_0001.JPG'
> duration 2
> file 'IMG_0002.JPG'
> duration 50
> file 'IMG_0002.JPG'
>
> and subtitles.srt is a subtitle file. I find that while the video is generated, the subtitles are not present.
>
> Can anyone point out what I am doing wrong?
Already pointed out in your Q at video stack exch

Frames must exist within the time intervals of the subtitles. You can
use the fps filter to generate a CFR stream before applying subtitles.

But to keep VFR, you'll need to create duplicate entries in your
textfile, with suitable duration values.

Gyan


_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: Help: How to add subtitles to a video created from images?

Srinidhi S

Thank you. Adding the fps filter solved my problem.

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".