Adding subtitles to video fails with ffmpeg

Gururaj

I am trying to add a subtitle to a video using ffmpeg and a .srt file. Using the command:

ffmpeg -i videopath.mp4 -i subtitlefilepath.srt -c:v libx264 -preset ultrafast -ar 44100 -ac 2 -ab 128k -strict -2 videooutput.mp4

.srt file looks like

1
00:00:00,30-->00:00:05,30
Sample sub title for video 

What is that 30 after duration?

Output:

ffmpeg version git-2013-12-11-3b28564 Copyright (c) 2000-2014 the FFmpeg developers  built on Jan 22 2014 13:22:00 with gcc 4.6 (GCC) 20120106 (peelease)  configuration: --arch=arm --target-os=linux --enable-cross-compile --cross-prefix=/Users/sunitha/Downloads/android-ndk-r9c/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/arm-linux-androideabi- --prefix=../build --sysroot=/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm --extra-cflags=' -I/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm/usr/include -I../libmp3lame/include -I../libx264/include -DANDROID -marm -march=armv6 ' --extra-ldflags=' -L/Users/sunitha/Downloads/android-ndk-r9c/platforms/android-9/arch-arm/usr/lib -L../libmp3lame/lib -L../libx264/lib' --disable-debug --enable-libmp3lame --enable-libx264 --disable-ffplay --disable-ffprobe --disable-ffserver --enable-avfilter --enable-decoders --enable-demuxers --enable-encoders --enable-filters --enable-indevs --enable-network --enable-parsers --enable-protocols --enable-swscale --enable-gpl --enable-nonfree
libavutil      52. 63.100 / 52. 63.100  
libavcodec     55. 48.102 / 55. 48.102  
libavformat    55. 25.101 / 55. 25.101  
libavdevice    55.  5.102 / 55.  5.102  
libavfilter     4.  1.100 /  4.  1.100  
libswscale      2.  5.101 /  2.  5.101  
libswresample   0. 17.104 /  0. 17.104  
libpostproc    52.  3.100 / 52.  3.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/Camera/20141022_125926.mp4':  
    Metadata:    
        major_brand     : isom    
        minor_version   : 0    
        compatible_brands: isom3gp4    
        creation_time   : 2014-10-22 07:29:39  
        Duration: 00:00:08.58, start: 0.000000, bitrate: 11752 kb/s  
    Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, smpte170m), 1280x720, 11758 kb/s, 29.33 fps, 30 tbr, 90k tbn, 180k tbc (default)    
    Metadata:      
        rotate          : 90      
        creation_time   : 2014-10-22 07:29:39      
        handler_name    : VideoHandle    
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 60 kb/s (default)    
    Metadata:      
        creation_time   : 2014-10-22 07:29:39      
        handler_name    : SoundHandle

Input #1, srt, from '/storage/emulated/0/DCIM/Camera/subtitle.srt':  Duration: N/A, bitrate: N/A    
Stream #1:0: Subtitle: subrip

[libx264 @ 0x11cf050] using cpu capabilities: ARMv6 NEON[libx264 @ 0x11cf050] profile Constrained Baseline, level 3.1
[libx264 @ 0x11cf050] 264 - core 140 r2377 1ca7bb9 - H.264/MPEG-4 AVC codec - Copyleft 2003-2013 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=1 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0

Output #0, mp4, to '/storage/emulated/0/VideoOverLay/videooverlay1413965066659.mp4':  
    Metadata:    
        major_brand     : isom    
        minor_version   : 0    
        compatible_brands: isom3gp4    
        encoder         : Lavf55.25.101    
    Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720, q=-1--1, 15360 tbn, 30 tbc (default)    
    Metadata:      
        rotate          : 90      
        creation_time   : 2014-10-22 07:29:39      
        handler_name    : VideoHandle    
    Stream #0:1(eng): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s (default)    
    Metadata:      
        creation_time   : 2014-10-22 07:29:39      
        handler_name    : SoundHandle

Stream mapping:  
    Stream #0:0 -> #0:0 (h264 -> libx264)  
    Stream #0:1 -> #0:1 (aac -> aac)

Press [q] to stop, [?] for help
frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.47 bitrate=   0.8kbits/s    
frame=    0 fps=0.0 q=0.0 size=       0kB time=00:00:00.91 bitrate=   0.4kbits/s    
frame=    3 fps=1.2 q=23.0 size=      38kB time=00:00:01.00 bitrate= 311.9kbits/s    
frame=    6 fps=1.9 q=22.0 size=      7
10-22 13:35:08.365: D/dalvikvm(1754): GC_CONCURRENT freed 1968K, 26% free 16486K/22120K, paused 14ms+6ms, total 59ms
10-22 13:35:08.365: I/exit code >>>>>>>>..(1754): 0
10-22 13:35:08.365: I/exit code >>>>>>>>..(1754): 0

I can't see any subtitles on the video. Where's the problem?

slhck

You're not telling ffmpeg to use the subtitles. With multiple inputs ffmpeg will only map one, IIRC:

Stream mapping:  
    Stream #0:0 -> #0:0 (h264 -> libx264)  
    Stream #0:1 -> #0:1 (aac -> aac)

So try something like:

ffmpeg -i videopath.mp4 -i subtitlefilepath.srt \
-c:v libx264 -preset ultrafast \
-ar 44100 -ac 2 -ab 128k -strict -2 \
-c:s mov_text -map 0 -map 1 \
videooutput.mp4

This would copy the subtitles as-is and map the input video (-map 0) and subtitle file (-map 1) to the output. You should see something like this:

Stream mapping:  
    Stream #0:0 -> #0:0 (h264 -> libx264)  
    Stream #0:1 -> #0:1 (aac -> aac)
    Stream #1:0 -> #1:0 (srt -> mov_text)

You could also use the subtitles filter to hardcode subs. For that you need to compile ffmpeg version with libass though, which is not the case for the one you're using.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding text subtitles to video track (in Swift) fails with error code -11841

From Dev

Adding subtitles with fluent-ffmpeg

From Dev

ffmpeg adding ass subtitles: error initializing filter 'subtitles' with args ''

From Dev

Extract every audio and subtitles from a video with ffmpeg

From Dev

FFMPEG burn subtitles while Cutting video

From Dev

Force output video duration with external subtitles in ffmpeg

From Dev

ffmpeg encoding to convert video to PNGs, with subtitles

From Dev

Adding subtitles via command line in ffmpeg

From Dev

Is there way to increase speed of adding subtitles to a video?

From Dev

ffmpeg concat video fails on Android

From Dev

Adding soundtrack to a video using FFMPEG

From Dev

How to Add Font size in subtitles in ffmpeg video filter

From Dev

How to Add Font size in subtitles in ffmpeg video filter

From Dev

Using FFMPEG to add subtitles to a M4v video file

From Dev

ffmpeg fails to mux video and audio properly

From Dev

Rotate video adding black bars with ffmpeg

From Dev

Adding multiple audio inputs to video with ffmpeg not working

From Dev

Rotate video adding black bars with ffmpeg

From Dev

FFMPEG : Adding font to Video gives error

From Dev

FFmpeg/avconv rotate video with watermark adding using PHP-FFmpeg

From Dev

ffmpeg and hardcoding subtitles

From Dev

FFmpeg, error hardcoding subtitles

From Dev

Adding watermark bitmap over video in android: 4.3's MediaMuxer or ffmpeg

From Dev

Adding more than one image in front of video in ffmpeg

From Dev

ffmpeg - adding/re-encoding audio stream on video file

From Dev

FFMpeg DVB Subtitles memory leak

From Dev

Understanding FFMPEG Error Extracting Subtitles

From Dev

Youtube video embed withenforce subtitles

From Dev

Convert .avi to .gif with ffmpeg with good quality AND subtitles

Related Related

  1. 1

    Adding text subtitles to video track (in Swift) fails with error code -11841

  2. 2

    Adding subtitles with fluent-ffmpeg

  3. 3

    ffmpeg adding ass subtitles: error initializing filter 'subtitles' with args ''

  4. 4

    Extract every audio and subtitles from a video with ffmpeg

  5. 5

    FFMPEG burn subtitles while Cutting video

  6. 6

    Force output video duration with external subtitles in ffmpeg

  7. 7

    ffmpeg encoding to convert video to PNGs, with subtitles

  8. 8

    Adding subtitles via command line in ffmpeg

  9. 9

    Is there way to increase speed of adding subtitles to a video?

  10. 10

    ffmpeg concat video fails on Android

  11. 11

    Adding soundtrack to a video using FFMPEG

  12. 12

    How to Add Font size in subtitles in ffmpeg video filter

  13. 13

    How to Add Font size in subtitles in ffmpeg video filter

  14. 14

    Using FFMPEG to add subtitles to a M4v video file

  15. 15

    ffmpeg fails to mux video and audio properly

  16. 16

    Rotate video adding black bars with ffmpeg

  17. 17

    Adding multiple audio inputs to video with ffmpeg not working

  18. 18

    Rotate video adding black bars with ffmpeg

  19. 19

    FFMPEG : Adding font to Video gives error

  20. 20

    FFmpeg/avconv rotate video with watermark adding using PHP-FFmpeg

  21. 21

    ffmpeg and hardcoding subtitles

  22. 22

    FFmpeg, error hardcoding subtitles

  23. 23

    Adding watermark bitmap over video in android: 4.3's MediaMuxer or ffmpeg

  24. 24

    Adding more than one image in front of video in ffmpeg

  25. 25

    ffmpeg - adding/re-encoding audio stream on video file

  26. 26

    FFMpeg DVB Subtitles memory leak

  27. 27

    Understanding FFMPEG Error Extracting Subtitles

  28. 28

    Youtube video embed withenforce subtitles

  29. 29

    Convert .avi to .gif with ffmpeg with good quality AND subtitles

HotTag

Archive