View previous topic :: View next topic |
Author |
Message |
curmudgeon Veteran
Joined: 08 Aug 2003 Posts: 1741
|
Posted: Sun Sep 29, 2013 1:41 pm Post subject: subtitles part two (ffmpeg) |
|
|
I am trying to extract subtitles from a file with ffmpeg. For some reason that I don't understand, I can only extract the first subtitle stream.
Code: |
$ mediainfo /path/to/some/file
[...]
Text #1
ID : 3
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Language : English
Default : No
Forced : No
Text #2
ID : 4
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Language : English
Default : No
Forced : No
Text #3
ID : 5
Format : UTF-8
Codec ID : S_TEXT/UTF8
Codec ID/Info : UTF-8 Plain Text
Language : English
Default : No
Forced : No
Text #4
ID : 6
Format : VobSub
Codec ID : S_VOBSUB
Codec ID/Info : The same subtitle format used on DVDs
Language : French
Default : No
Forced : No
Text #5
ID : 7
Format : VobSub
Codec ID : S_VOBSUB
Codec ID/Info : The same subtitle format used on DVDs
Language : Spanish
Default : No
Forced : No
Text #6
ID : 8
Format : VobSub
Codec ID : S_VOBSUB
Codec ID/Info : The same subtitle format used on DVDs
Language : Portuguese
Default : No
Forced : No
[...]
|
First set of subtitles, no problem:
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0 srt sub0.srt
ffmpeg version 1.0.7 Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 30 2013 13:05:24 with gcc 4.6.3 (Gentoo 4.6.3 p1.13, pie-0.5.2)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --extra-cflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --extra-cxxflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --disable-debug --disable-doc --disable-vaapi --disable-runtime-cpudetect --enable-libmp3lame --enable-libvo-aacenc --enable-libtheora --enable-libx264 --enable-lib libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[...]
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), s16, 1536 kb/s (default)
Stream #0:2(eng): Subtitle: subrip
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
Stream #0:5(fre): Subtitle: dvd_subtitle
Stream #0:6(spa): Subtitle: dvd_subtitle
Stream #0:7(por): Subtitle: dvd_subtitle
Output #0, srt, to 'sub0.srt':
[...]
Stream mapping:
Stream #0:2 -> #0:0 (subrip -> srt)
Press [q] to stop, [?] for help
size= 100kB time=02:00:00.00 bitrate= 0.1kbits/s ts/s
video:0kB audio:0kB subtitle:100 global headers:0kB muxing overhead 0.000000%
|
But any other set of subtitles gets me this:
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:1 srt sub1.srt
[...] (identical to above)
Stream mapping:
Stream #0:2 -> #0:0 (subrip -> ?)
Encoder (codec none) not found for output stream #0:0
|
I am probably doing something wrong, but I can't figure out exact what. :)
Last edited by curmudgeon on Tue Oct 15, 2013 11:31 am; edited 2 times in total |
|
Back to top |
|
|
massimo Veteran
Joined: 22 Jun 2003 Posts: 1226
|
Posted: Tue Oct 01, 2013 6:45 am Post subject: Re: subtitles part two (ffmpeg) |
|
|
curmudgeon wrote: | But any other set of subtitles gets me this:
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:1 srt sub1.srt
[...] (identical to above)
Stream mapping:
Stream #0:2 -> #0:0 (subrip -> ?)
Encoder (codec none) not found for output stream #0:0
|
I am probably doing something wrong, but I can't figure out exact what. :) |
Do these work?
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.2 srt sub2.srt
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.3 srt sub3.srt
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.6 srt sub6.srt
|
_________________ Hello 911? How are you? |
|
Back to top |
|
|
curmudgeon Veteran
Joined: 08 Aug 2003 Posts: 1741
|
Posted: Tue Oct 15, 2013 11:43 am Post subject: Re: subtitles part two (ffmpeg) |
|
|
massimo wrote: |
Do these work?
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.2 srt sub2.srt
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.3 srt sub3.srt
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.6 srt sub6.srt
|
|
No they don't. No matter which stream I ask for, I ALWAYS get the first subtitle stream:
Code: |
$ ffmpeg -i /path/to/some/file -an -vn -c:s:0.6 srt sub6.srt
ffmpeg version 1.0.7 Copyright (c) 2000-2013 the FFmpeg developers
built on Jun 30 2013 13:05:24 with gcc 4.6.3 (Gentoo 4.6.3 p1.13, pie-0.5.2)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --extra-cflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --extra-cxxflags='-O2 -fomit-frame-pointer -pipe -march=core2 -mcx16 -msahf -msse4.1 --param l1-cache-size=32 --param l1-cache-line-size=64 --param l2-cache-size=2048 -mfpmath=sse' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --enable-avresample --disable-stripping --disable-debug --disable-doc --disable-vaapi --disable-runtime-cpudetect --enable-libmp3lame --enable-libvo-aacenc --enable-libtheora --enable-libx264 --enable-lib libavutil 51. 73.101 / 51. 73.101
libavcodec 54. 59.100 / 54. 59.100
libavformat 54. 29.104 / 54. 29.104
libavdevice 54. 2.101 / 54. 2.101
libavfilter 3. 17.100 / 3. 17.100
libswscale 2. 1.101 / 2. 1.101
libswresample 0. 15.100 / 0. 15.100
libpostproc 52. 0.100 / 52. 0.100
[...]
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800 [SAR 1:1 DAR 12:5], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Stream #0:1(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), s16, 1536 kb/s (default)
Stream #0:2(eng): Subtitle: subrip
Stream #0:3(eng): Subtitle: subrip
Stream #0:4(eng): Subtitle: subrip
Stream #0:5(fre): Subtitle: dvd_subtitle
Stream #0:6(spa): Subtitle: dvd_subtitle
Stream #0:7(por): Subtitle: dvd_subtitle
Output #0, srt, to 'sub6.srt':
[...]
Stream #0:2 -> #0:0 (subrip -> srt)
Press [q] to stop, [?] for help
size= 129kB time=02:03:15.80 bitrate= 0.1kbits/s
video:0kB audio:0kB subtitle:129 global headers:0kB muxing overhead 0.000000%
|
Note that it still uses (even though I asked for 0.6):
Code: |
Stream #0:2 -> #0:0 (subrip -> srt)
|
|
|
Back to top |
|
|
Nicias Guru
Joined: 06 Dec 2005 Posts: 446
|
Posted: Mon Sep 15, 2014 3:56 pm Post subject: |
|
|
Don't know if you are still fighting with this but try this:
Code: | $ ffmpeg -i /path/to/some/file -map 0:s:0 -an -vn -c:s srt sub0.srt | change the 0:s:0 to 0:s:1, etc for other tracks |
|
Back to top |
|
|
Bloody100 n00b
Joined: 02 Apr 2006 Posts: 7 Location: Berlin
|
Posted: Wed Sep 17, 2014 5:46 am Post subject: You need to specify what you want... |
|
|
By default, ffmpeg selects the first available/suited stream, so you need to specify which one you want (not just which codec you want to use), like:
ffmpeg -i /path/to/some/file -c copy -map 0:s:0 sub0.srt
ffmpeg -i /path/to/some/file -c copy -map 0:s:1 sub1.srt
ffmpeg -i /path/to/some/file -c copy -map 0:s:2 sub2.srt
Cheers... _________________ Cheers,
Oliver 'Bloody' Lange. |
|
Back to top |
|
|
Zelt n00b
Joined: 07 Jul 2014 Posts: 72
|
Posted: Sun Sep 21, 2014 12:54 am Post subject: |
|
|
What is it you plan to do with these extracted subtitles?
A great toolset with/instead of ffmpeg is mkvtoolnix. _________________ k. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|