make mpeg2 file with hardcoded subs from .srt file

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

make mpeg2 file with hardcoded subs from .srt file

gepebril
Hi there,

I'm trying to produce MPEG2 files with hardcoded subs using ffmpeg under
Windows.
I'm following the instructions here:
http://trac.ffmpeg.org/wiki/How%20to%20burn%20subtitles%20into%20the%20video
I get perfect MPEG2 files with the default template in winff.
ffmpeg.exe -y -i "E:\src.mkv" -f dvd -target ntsc-dvd -r 29.97 -vf
scale=720:480 -aspect 16:9 -b:v 8000k -g 12 -mbd rd -trellis 1 -flags +mv0
-cmp 0 -subcmp 2 "E:\dest.mpg"

When I enter the option -vf subtitles=src.srt, like this

ffmpeg.exe -y -i "E:\src.mkv" -vf subtitles=src.srt -f dvd -target ntsc-dvd
-r 29.97 -vf scale=720:480 -aspect 16:9 -b:v 8000k -g 12 -mbd rd -trellis 1
-flags +mv0 -cmp 0 -subcmp 2 "E:\dest.mpg"

I get still the same mpeg file, without any subs....

When I type ffmpeg.exe I see it's compiled with libass
ffmpeg version N-51433-g551f683 Copyright (c) 2000-2013 the FFmpeg
developers
  built on Mar 28 2013 21:58:26 with gcc 4.8.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray
--enable-libcaca --enable-libfreetype --enable-libg
sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --ena
ble-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-lib
twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  2.100 / 55.  2.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.105 /  3. 48.105
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100

What is the problem, what am I doing wrong?

The output is this:
ffmpeg version N-51433-g551f683 Copyright (c) 2000-2013 the FFmpeg
developers
  built on Mar 28 2013 21:58:26 with gcc 4.8.0 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray
--enable-libcaca --enable-libfreetype --enable-libg
sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --ena
ble-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr
--enable-libspeex --enable-libtheora --enable-lib
twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
  libavutil      52. 22.101 / 52. 22.101
  libavcodec     55.  2.100 / 55.  2.100
  libavformat    55.  0.100 / 55.  0.100
  libavdevice    55.  0.100 / 55.  0.100
  libavfilter     3. 48.105 /  3. 48.105
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from src.mkv':
  Metadata:
    creation_time   : 2013-04-11 22:04:12
  Duration: 01:26:25.18, start: 0.000000, bitrate: 6955 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x688 [SAR 1:1 DAR
80:43], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
 (default)
    Stream #0:1: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
(default)
Output #0, dvd, to 'E:\testmpg.mpg':
  Metadata:
    encoder         : Lavf55.0.100
    Stream #0:0(eng): Video: mpeg2video (hq), yuv420p, 720x480 [SAR 32:27
DAR 16:9], q=2-31, 8000 kb/s, 90k tbn, 29.97 t
bc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mpeg2video)
  Stream #0:1 -> #0:1 (dca -> ac3)
Press [q] to stop, [?] for help
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Carl Eugen Hoyos
Albert Scholtalbers <compuvision.sr <at> gmail.com> writes:

> ffmpeg.exe -y -i "E:\src.mkv" -vf subtitles=src.srt
> -f dvd -target ntsc-dvd -r 29.97 -vf scale=720:480
> -aspect 16:9 -b:v 8000k -g 12 -mbd rd -trellis 1
> -flags +mv0 -cmp 0 -subcmp 2 "E:\dest.mpg"

I didn't test but I suspect specifying two
"-vf" options for one output file is either
undefined behaviour or forces only the
second option.

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
>I didn't test but I suspect specifying two"-vf" options for one output
file is either
> undefined behaviour or forces only the
> second option.

>Carl Eugen

I found a working command under Linux:
/usr/local/bin/ffmpeg -y -i src.mkv  -f dvd -target ntsc-dvd -r 29.97 -vf
scale=720:480 -vf subtitles=filename=src.srt -aspect 16:9 -b:v 8000k -g 12
-mbd rd -trellis 1 -flags +mv0 -cmp 0 -subcmp 2 dest.mpg

That "seems"to be easier. But I haven't found any option to set
font/size/color in document or Google yet.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Carl Eugen Hoyos
Albert Scholtalbers <compuvision.sr <at> gmail.com> writes:

> I found a working command under Linux:
> -vf subtitles=filename=src.srt

> But I haven't found any option to set
> font/size/color in document or Google yet.

I am really no srt expert, but I would have
expected that the srt file contains all
definitions for font/size/color.

Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
Thx for your honesty.

It seems besides libass, you also need to enable fontconfig
so --enable-libass --enable-fontconfig

I think otherwise you only have one basic font.

.srt files only contain txt and starttime code and stoptime code
so very easy and straight forward.

>> I found a working command under Linux:
>> -vf subtitles=filename=src.srt

>> But I haven't found any option to set
>> font/size/color in document or Google yet.

>I am really no srt expert, but I would have
>expected that the srt file contains all
>definitions for font/size/color.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Carl Eugen Hoyos
Albert Scholtalbers <compuvision.sr <at> gmail.com> writes:

> .srt files only contain txt and starttime code
> and stoptime code

This is at least not true for the one
srt file that FFmpeg uses for
regression tests.

Please avoid top-posting here, Carl Eugen

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
> Please avoid top-posting here, Carl Eugen

I don't know what you mean by that.
Why I discovered is that there is a gui for the mailinglists now.
So it will be easier to reply and format than in Gmail :)
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
Aha,

Via the Gui now :)
Is there a libass .srt specialist withing the FFMpeg community
It seems there is hardly any info on this matter on the Linux platform
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Moritz Barsnick
In reply to this post by gepebril
On Wed, Jul 10, 2013 at 18:35:04 -0300, Albert Scholtalbers wrote:
> > Please avoid top-posting here, Carl Eugen
> I don't know what you mean by that.

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

M.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
@Moritz

Thx for the reply.
If somebody writes that they don't know what somebody means.
You are not helping them by explaining why it's bad or good. Just an example what top posting textually is.....
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Robert Krüger-2
On Wed, Jul 10, 2013 at 11:59 PM, gepebril <[hidden email]> wrote:
> @Moritz
>
> Thx for the reply.
> If somebody writes that they don't know what somebody means.
> You are not helping them by explaining why it's bad or good. Just an example

He actually did. Please read the mail again and if you don't
understand the implicit explanation, try googling "top-posting".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
Ok,

Still not clear though. I see that the gui removes all previous text from the former mail. So that is probably not-top posting.

Anyway, after some hours of testing and wandering around the Net. I managed to get it working on Windows with ffmpeg. Although it seems possible to generate all kinds of different fonts using .srt, there is no actual working sample off it on the Net, which I found.
That left me to a working solution, thanks to this this webpage. Basically the trick is:
1) convert your .srt to .ass file (with ffmpeg)
2) Use Windows
3) Follow the instruction on the website
4) Render.

In commands it looks like this (create .ass file from .srt):
ffmpeg.exe -i subtitle_file.srt -y -scodec ass subtitle_file.ass


Make sure you have the local variables set right
set FC_CONFIG_DIR=E:\temp\Subtitles
set FONTCONFIG_FILE=fonts.xml
set FONTCONFIG_PATH=E:\temp\Subtitles

And use the related example of fonts.xml
<?xml version="1.0"?>
<fontconfig>

<dir>C:\WINDOWS\Fonts</dir>

<match target="pattern">
   <test qual="any" name="family"><string>mono</string></test>
   <edit name="family" mode="assign"><string>monospace</string></edit>
</match>

<match target="pattern">
   <test qual="all" name="family" mode="not_eq"><string>sans-serif</string></test>
   <test qual="all" name="family" mode="not_eq"><string>serif</string></test>
   <test qual="all" name="family" mode="not_eq"><string>monospace</string></test>
   <edit name="family" mode="append_last"><string>sans-serif</string></edit>
</match>

<alias>
   <family>Times</family>
   <prefer><family>Times New Roman</family></prefer>
   <default><family>serif</family></default>
</alias>
<alias>
   <family>Helvetica</family>
   <prefer><family>Arial</family></prefer>
   <default><family>sans</family></default>
</alias>
<alias>
   <family>Courier</family>
   <prefer><family>Courier New</family></prefer>
   <default><family>monospace</family></default>
</alias>
<alias>
   <family>serif</family>
   <prefer><family>Times New Roman</family></prefer>
</alias>
<alias>
   <family>sans</family>
   <prefer><family>Arial</family></prefer>
</alias>
<alias>
   <family>monospace</family>
   <prefer><family>Andale Mono</family></prefer>
</alias>
<match target="pattern">
   <test name="family" mode="eq">
      <string>Courier New</string>
   </test>
   <edit name="family" mode="prepend">
      <string>monospace</string>
   </edit>
</match>
<match target="pattern">
   <test name="family" mode="eq">
      <string>Courier</string>
   </test>
   <edit name="family" mode="prepend">
      <string>monospace</string>
   </edit>
</match>

</fontconfig>

Create your video file with burned in subs
ffmpeg.exe -y -i "src.mkv"  -f dvd -target ntsc-dvd -r 29.97 -vf scale=720:480 -vf "ass=subtitle_file.ass" -aspect 16:9 -b:v 8000k -g 12 -mbd rd -trellis 1 -flags +mv0 -cmp 0 -subcmp 2 e:\dst.mpg


Note: make sure that the .ass file is in the same path as where are, as I haven't managed to get a path reference working with ass
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

Stefano Sabatini-2
On date Thursday 2013-07-11 10:04:18 -0700, gepebril wrote:
> Ok,
[...]
> Create your video file with burned in subs
> ffmpeg.exe -y -i "src.mkv"  -f dvd -target ntsc-dvd -r 29.97 -vf
> scale=720:480 -vf "ass=subtitle_file.ass" -aspect 16:9 -b:v 8000k -g 12 -mbd
> rd -trellis 1 -flags +mv0 -cmp 0 -subcmp 2 e:\dst.mpg

This is still wrong, -vf foo -vf bar has the same effects as -vf bar,
what you want instead:
-vf scale=720:480,ass=subtitle_file.ass

Also why do you need to convert to ass?
 
> Note: make sure that the .ass file is in the same path as where are, as I
> haven't managed to get a path reference working with ass

You need to specify an absolute path (and be aware of escaping problems).

[...]
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
@ Stefano,

>This is still wrong, -vf foo -vf bar has the same effects as -vf bar,
Maybe in theory. I will try your suggestion today.

I didn't say that you have to convert to .ass to get burned in subtitles. It's just that FFMpeg takes the layout of subs from the .ass file, it's not present in .srt files.
Maybe there is a way to do it with .srt files (change fonts etc), but from the let's say 50 examples of how to place hardcoded subs with ffmpeg, 48 are done with .ass and of all .srt files examples none of the discusses lay-out/positioning/fonts/size. So I assume it's not possible/not yet implemented.
Reply | Threaded
Open this post in threaded view
|

Re: make mpeg2 file with hardcoded subs from .srt file

gepebril
@ Stefano,
I tested your command, and it works. That command makes more sense, so -vf <option 1>,<option 2>,<option 3> Thanks for that part.