Can't get ffpmeg to add subtitles to mp4 files

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

Can't get ffpmeg to add subtitles to mp4 files

Richard DJE
All,


I started using FFmpeg to try adding subtitles to some of my mp3 files.
For that I turned those mp3 files into mp4 files by doing

*$ ffmpeg -i my.mp3 my.mp4*
-----------------------------------------------------------------------------------------------------

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers

  built with Apple clang version 11.0.0 (clang-1100.0.33.16)

  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin
-fno-stack-check' --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-libvidstab
--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-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack

  libavutil      56. 31.100 / 56. 31.100

  libavcodec     58. 54.100 / 58. 54.100

  libavformat    58. 29.100 / 58. 29.100

  libavdevice    58.  8.100 / 58.  8.100

  libavfilter     7. 57.100 /  7. 57.100

  libavresample   4.  0.  0 /  4.  0.  0

  libswscale      5.  5.100 /  5.  5.100

  libswresample   3.  5.100 /  3.  5.100

  libpostproc    55.  5.100 / 55.  5.100

[mp3 @ 0x7ff5e5000000] Estimating duration from bitrate, this may be
inaccurate

Input #0, mp3, from 'my.mp3':

  Duration: 00:00:08.75, start: 0.000000, bitrate: 127 kb/s

    Stream #0:0: Audio: mp3, 44100 Hz, mono, fltp, 128 kb/s

Stream mapping:

  Stream #0:0 -> #0:0 (mp3 (mp3float) -> aac (native))

Press [q] to stop, [?] for help

Output #0, mp4, to 'my.mp4':

  Metadata:

    encoder         : Lavf58.29.100

    Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp,
69 kb/s

    Metadata:

      encoder         : Lavc58.54.100 aac

size=      78kB time=00:00:08.75 bitrate=  73.0kbits/s speed= 156x

video:0kB audio:76kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 2.987824%
-----------------------------------------------------------------------------------------------------

I then executed the following in order to add the subtitles

*$ ffmpeg -report -i my.mp4 -vf subtitles=my.srt my_sub.mp4*
-----------------------------------------------------------------------------------------------------

ffmpeg version 4.2.2 Copyright (c) 2000-2019 the FFmpeg developers

  built with Apple clang version 11.0.0 (clang-1100.0.33.16)

  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.2.2 --enable-shared
--enable-pthreads --enable-version3 --enable-avresample --cc=clang
--host-cflags='-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include
-I/Library/Java/JavaVirtualMachines/adoptopenjdk-13.0.1.jdk/Contents/Home/include/darwin
-fno-stack-check' --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-libvidstab
--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-libsoxr --enable-videotoolbox --disable-libjack
--disable-indev=jack

  libavutil      56. 31.100 / 56. 31.100

  libavcodec     58. 54.100 / 58. 54.100

  libavformat    58. 29.100 / 58. 29.100

  libavdevice    58.  8.100 / 58.  8.100

  libavfilter     7. 57.100 /  7. 57.100

  libavresample   4.  0.  0 /  4.  0.  0

  libswscale      5.  5.100 /  5.  5.100

  libswresample   3.  5.100 /  3.  5.100

  libpostproc    55.  5.100 / 55.  5.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'my.mp4':

  Metadata:

    major_brand     : isom

    minor_version   : 512

    compatible_brands: isomiso2mp41

    encoder         : Lavf58.29.100

  Duration: 00:00:08.78, start: 0.000000, bitrate: 72 kb/s

    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono,
fltp, 70 kb/s (default)

    Metadata:

      handler_name    : SoundHandler

Stream mapping:

  Stream #0:0 -> #0:0 (aac (native) -> aac (native))

Press [q] to stop, [?] for help

Output #0, mp4, to 'my_sub.mp4':

  Metadata:

    major_brand     : isom

    minor_version   : 512

    compatible_brands: isomiso2mp41

    encoder         : Lavf58.29.100

    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono,
fltp, 69 kb/s (default)

    Metadata:

      handler_name    : SoundHandler

      encoder         : Lavc58.54.100 aac

size=      78kB time=00:00:08.75 bitrate=  73.2kbits/s speed= 174x

video:0kB audio:76kB subtitle:*0*kB other streams:0kB global headers:0kB
muxing overhead: 2.971010%

[aac @ 0x7ffbeb003800] Qavg: 761.199
-----------------------------------------------------------------------------------------------------

I attached the log of the above command as ffmpeg-20200103-134542.log.

The problem I am seeing is that no subtitle is displayed, at all.
This seems to be confirmed with subtitle:*0*kB.

I also tried different subtitles' commands like

*$ ffmpeg -i my.pm4 -i my.srt -c copy -c:s mov_text my_sub.mp4*

But I end up with the exact same issue.

I Googled a lot yesterday, read a lot of different ways to add subtitles
using FFmpeg but none of them worked.

I am running on a macOS Catalina Version 10.15.2
*$ uname -a*

Darwin Richards-MacBook-Pro.local 19.2.0 Darwin Kernel Version 19.2.0: Sat
Nov  9 03:47:04 PST 2019; root:xnu-6153.61.1~20/RELEASE_X86_64 x86_64



I attached the following files
- *my.mp3*
-* my.srt*

This file only contains two subtitle entries



* Is the issue due to my srt file ?
* Did I use the right options for creating the mp4 from the mp3
* Did I use the right set of options for adding the subtitles ?


Thank you in advance for any help you might provide.

BR,
-Richard

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

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

ffmpeg-20200103-134542.log (8K) Download Attachment
my.mp3 (187K) Download Attachment
my.srt (98 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Can't get ffpmeg to add subtitles to mp4 files

Nicolas George
Richard DJE (12020-01-03):
> I then executed the following in order to add the subtitles

Doing it in two steps is a terrible idea, the image and sound are
degraded twice.

> *$ ffmpeg -report -i my.mp4 -vf subtitles=my.srt my_sub.mp4*

> The problem I am seeing is that no subtitle is displayed, at all.
> This seems to be confirmed with subtitle:*0*kB.

You won't go very far with a video filter on a file that does not
contain video.

> I also tried different subtitles' commands like
>
> *$ ffmpeg -i my.pm4 -i my.srt -c copy -c:s mov_text my_sub.mp4*
>
> But I end up with the exact same issue.

No, you ended up with a different issue that seems similar to you.

Regards,

--
  Nicolas George

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

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

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Can't get ffpmeg to add subtitles to mp4 files

kumowoon1025
In reply to this post by Richard DJE
> I also tried different subtitles' commands like
>
> *$ ffmpeg -i my.pm4 -i my.srt -c copy -c:s mov_text my_sub.mp4*
>
> But I end up with the exact same issue.
>
> I Googled a lot yesterday, read a lot of different ways to add subtitles
> using FFmpeg but none of them worked.

That should have worked as far as adding the subtitles goes, but without video, where are you expecting them to show up? If you’re looking for karaoke-type display, you’re probably going to need a different approach.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Can't get ffpmeg to add subtitles to mp4 files

Ashish Jha
Try below mentioned command:

ffmpeg -i input.mp4 -filter:v subtitles=subtitle.srt output.mp4

it's working for me.


--
Ashish
________________________________
From: ffmpeg-user <[hidden email]> on behalf of Ted Park <[hidden email]>
Sent: Saturday, January 4, 2020 2:05 PM
To: FFmpeg user questions <[hidden email]>
Subject: Re: [FFmpeg-user] Can't get ffpmeg to add subtitles to mp4 files

> I also tried different subtitles' commands like
>
> *$ ffmpeg -i my.pm4 -i my.srt -c copy -c:s mov_text my_sub.mp4*
>
> But I end up with the exact same issue.
>
> I Googled a lot yesterday, read a lot of different ways to add subtitles
> using FFmpeg but none of them worked.

That should have worked as far as adding the subtitles goes, but without video, where are you expecting them to show up? If you’re looking for karaoke-type display, you’re probably going to need a different approach.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Can't get ffpmeg to add subtitles to mp4 files

Moritz Barsnick
On Sat, Jan 04, 2020 at 09:43:16 +0000, Ashish Jha wrote:
> Try below mentioned command:
>
> ffmpeg -i input.mp4 -filter:v subtitles=subtitle.srt output.mp4
>
> it's working for me.

If you read Richard's mail, you will notice that that is exactly what
he tried. It fails for him though, because his input doesn't have any
video stream, so there's nothing the "subtitles" filter can overlay
onto.

Richard needs to add an artificial video as a base for the subtitles.
This works just fine (without the intermediate my.mp4):

$ ffmpeg -i my.mp3 -f lavfi -i color=color=black,subtitles=my.srt -shortest my.mp4

(The subtitles filter is directly chained with the artificial input
source. It could just as well be given via "-vf" == "-filter:v", but
doesn't need to be in this case.)

Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://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: Can't get ffpmeg to add subtitles to mp4 files

Richard DJE
Hi Moritz,

On Sat, Jan 4, 2020 at 3:16 PM Moritz Barsnick <[hidden email]> wrote:

> On Sat, Jan 04, 2020 at 09:43:16 +0000, Ashish Jha wrote:
> > Try below mentioned command:
> >
> > ffmpeg -i input.mp4 -filter:v subtitles=subtitle.srt output.mp4
> >
> > it's working for me.
>
> If you read Richard's mail, you will notice that that is exactly what
> he tried. It fails for him though, because his input doesn't have any
> video stream, so there's nothing the "subtitles" filter can overlay
> onto.
>
> Richard needs to add an artificial video as a base for the subtitles.
> This works just fine (without the intermediate my.mp4):
>
> $ ffmpeg -i my.mp3 -f lavfi -i color=color=black,subtitles=my.srt
> -shortest my.mp4
>
> (The subtitles filter is directly chained with the artificial input
> source. It could just as well be given via "-vf" == "-filter:v", but
> doesn't need to be in this case.)
>

Thank you for your reply.

The root cause of my issue was effectively spotted by a previous reply
from *Nicolas
George *to which I couldn't reply as I didn't receive that reply but I
could read it directly on the Forum's archive.
The problem with his post is that he didn't provide any guidance.

After more search I managed to find the proper command to generate blank
videos of a specific duration.
I first played with *nullsrc* and then *color*.

But your reply *Moritz* is precise and confirm my finding but does things
in a more concise way!

In my case, I did the blank video and subtitle steps separately as I am not
too familiar with FFmpeg.

Again thank you for your reply *Moritz* and also to *Ashish Jha* and *Ted
Park* ! :)


BR,
-Richard
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

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