Ticket #1277 (closed defect: fixed)
Subtitle (hdmv_pgs_subtitle) conversion fails
| Reported by: | bakhshian | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | undetermined |
| Version: | git-master | Keywords: | dvdsub |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | yes | |
| Analyzed by developer: | no |
Description (last modified by ubitux) (diff)
I need to convert the format of the subtitle stream of a movie so my device can play it.
Here is the list of all existing streams :
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x816 [SAR 1:1 DAR 40:17], 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)
Metadata:
title : 3/2+1
Stream #0:2(eng): Subtitle: hdmv_pgs_subtitle (default)
Stream #0:3(ger): Subtitle: hdmv_pgs_subtitle
Stream #0:4(ger): Subtitle: hdmv_pgs_subtitle
Stream #0:5(ger): Subtitle: hdmv_pgs_subtitle
Stream #0:6(ger): Subtitle: hdmv_pgs_subtitle
I want to keep only the English subtitle and convert it too. The available codecs are :
> ffmpeg -codecs | grep sub DES ass Advanced SubStation Alpha subtitle DES dvbsub DVB subtitles DES dvdsub DVD subtitles D S pgssub HDMV Presentation Graphic Stream subtitles DES srt SubRip subtitle DES xsub DivX subtitles (XSUB)
I choose dvdsub as the new format and try to run ffmpeg command with the following arguments :
ffmpeg -i in.mkv -scodec dvdsub -vcodec copy -acodec copy out.mkv
It starts running, but after a while ( I think when it reaches the first frame with subtitle ) crashes. Here you can see the messages :
Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Stream #0:2 -> #0:2 (pgssub -> dvdsub) Press [q] to stop, [?] for help Subtitle encoding failed1.0 size= 182919kB time=00:00:00.00 bitrate= 0.0kbits/s
The interesting point is that ffplay and mplayer both can play the input file and they show the subtitle properly.
Here is the output of ffmpeg -version command :
ffmpeg version 0.10.2-4:0.10.2-0ubuntu0jon1~oneiric1 built on Mar 18 2012 11:07:55 with gcc 4.6.1 configuration: --extra-version='4:0.10.2-0ubuntu0jon1~oneiric1' --arch=amd64 --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-stripping --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --enable-libvpx --enable-runtime-cpudetect --enable-libfreetype --enable-vaapi --enable-frei0r --enable-gpl --enable-postproc --enable-x11grab --enable-librtmp --enable-libvo-aacenc --enable-version3 --enable-libvo-amrwbenc --enable-version3 --enable-libdc1394 --shlibdir=/usr/lib/x86_64-linux-gnu --enable-shared --disable-static libavutil 51. 35.100 / 51. 35.100 libavcodec 53. 61.100 / 53. 61.100 libavformat 53. 32.100 / 53. 32.100 libavdevice 53. 4.100 / 53. 4.100 libavfilter 2. 61.100 / 2. 61.100 libswscale 2. 1.100 / 2. 1.100 libswresample 0. 6.100 / 0. 6.100 libpostproc 52. 0.100 / 52. 0.100
Attachments
Change History
Changed 13 months ago by bakhshian
-
attachment
ffmpeg-20120505-192526.log
added
the report created by ffmpeg
comment:2 in reply to: ↑ 1 Changed 13 months ago by bakhshian
Replying to cehoyos:
Please provide backtrace etc. for crashes, as explained on http://ffmpeg.org/bugreports.html
I attached the report file to the ticket. Would you please let me know if it is enough or something else is needed ?
comment:3 follow-up: ↓ 4 Changed 13 months ago by cehoyos
In your original report you describe a "crash", the report you provided does not show any indication for a crash. Please clarify.
comment:4 in reply to: ↑ 3 ; follow-up: ↓ 5 Changed 13 months ago by bakhshian
Replying to cehoyos:
In your original report you describe a "crash", the report you provided does not show any indication for a crash. Please clarify.
It exits after an error occurs. It prints the error message : Subtitle encoding failed. As you can see in the attached log file, it happens while converting the 4308 frame of the movie and the conversion fails. I am not sure if I can call it a crash or not.
comment:5 in reply to: ↑ 4 ; follow-up: ↓ 6 Changed 13 months ago by cehoyos
- Keywords pgssub -> removed
- Priority changed from important to normal
Replying to bakhshian:
It exits after an error occurs. It prints the error message : Subtitle encoding failed. As you can see in the attached log file, it happens while converting the 4308 frame of the movie and the conversion fails. I am not sure if I can call it a crash or not.
It is not a crash.
Is the problem also reproducible if you cut the sample with dd (to make it short enough to attach / upload)?
comment:6 in reply to: ↑ 5 ; follow-up: ↓ 7 Changed 13 months ago by bakhshian
Replying to cehoyos:
Replying to bakhshian:
It exits after an error occurs. It prints the error message : Subtitle encoding failed. As you can see in the attached log file, it happens while converting the 4308 frame of the movie and the conversion fails. I am not sure if I can call it a crash or not.
It is not a crash.
Is the problem also reproducible if you cut the sample with dd (to make it short enough to attach / upload)?
I cut 3minutes of the movie and converted its video and audio formats to make it small enough to upload. The same error occurs while trying to convert the subtitle codec. The file can be found under ftp://upload.ffmpeg.org/incoming/. Its name is SCodecConversionFailsSample.mkv. There is another txt file with the same name describing the problem.
comment:7 in reply to: ↑ 6 Changed 13 months ago by bakhshian
hi again,
was my problem re-producible by the given file ? or is it just a problem from my side ?
please help
comment:8 Changed 12 months ago by cehoyos
- Status changed from new to open
- Version changed from 0.10.2 to git-master
- Component changed from FFmpeg to undetermined
- Reproduced by developer set
Sorry for the delay, the issue is reproducible: encode_dvd_subtitles() is called with h->num_rects == 0
comment:9 follow-up: ↓ 10 Changed 12 months ago by cehoyos
A possibly related bug is the null-pointer dereference in line 136 of xsubenc.c in xsub_encode():
$ ffmpeg -i SCodecConversionFailsSample.mkv -scodec xsub -f null -
comment:10 in reply to: ↑ 9 Changed 12 months ago by bakhshian
Replying to cehoyos:
A possibly related bug is the null-pointer dereference in line 136 of xsubenc.c in xsub_encode():
$ ffmpeg -i SCodecConversionFailsSample.mkv -scodec xsub -f null -
Converting to xsub using '-f null' option, I get a more descriptive message :
[xsub @ 0x2026680] No more than 4 subtitle colors supported (256 found.)
[xsub @ 0x2026680] Only single rects supported (0 in subtitle.)
comment:11 Changed 10 months ago by michael
- Summary changed from Subtitle conversion fails to Subtitle (hdmv_pgs_subtitle) conversion fails
comment:12 Changed 10 months ago by Cigaes
I would like to access the sample, to see if my recent patches in that area are enough to solve the problem.
comment:13 Changed 10 months ago by cehoyos
Sample uploaded to samples/ffmpeg-bugs/trac/ticket1277
comment:14 Changed 10 months ago by Cigaes
Thanks Carl Eugen.
This patch fixes the failure:
http://ffmpeg.org/pipermail/ffmpeg-devel/2012-August/129069.html
The resulting encoded subtile has completely wrong colors, but the following patch fixes it, and gives IMHO a very decent result given the limitations of the dvdsub format:
http://ffmpeg.org/pipermail/ffmpeg-devel/2012-August/129070.html
The resulting subtitle is still huge, though, and slightly differently so between MPlayer and ffplay, but that is definitely an improvement. See the attached screenshots.
I'll try to look into the size matter.
Changed 10 months ago by Cigaes
-
attachment
sub_bad_colors_ffplay.png
added
Screenshot of ffplay after encoding with the "ffmpeg: add an option to fix subtitles durations" patch
Changed 10 months ago by Cigaes
-
attachment
sub_bad_colors_mplayer.png
added
Screenshot of mplayer after encoding with the "ffmpeg: add an option to fix subtitles durations" patch
Changed 10 months ago by Cigaes
-
attachment
sub_good_colors_huge_ffplay.png
added
Screenshot of ffplay after encoding with the "dvdsubenc: make it usable for transcoding" patch
Changed 10 months ago by Cigaes
-
attachment
sub_good_colors_huge_mplayer.png
added
Screenshot of mplayer after encoding with the "dvdsubenc: make it usable for transcoding" patch
comment:15 Changed 10 months ago by Cigaes
I believe the following patch series:
http://ffmpeg.org/pipermail/ffmpeg-devel/2012-August/129111.html
fixes all the issues. You need to add -fix_sub_duration to the input and either -analyzeduration 20E6 to the input or -s:s 1920x1080 to the output.
The subtitles will stay huge in certain players, but it works at least in MPlayer.
Changed 10 months ago by Cigaes
-
attachment
sub_fixed_mplayer.png
added
Screenshot of mplayer after encoding with the patch series suggested in comment #15
comment:16 Changed 9 months ago by bakhshian
Thank you so much. Would you please let me know how can I apply this patch or when the new official release including these changes will be available ?
comment:17 Changed 9 months ago by cehoyos
If you cannot apply the latest series of this patch - http://ffmpeg.org/pipermail/ffmpeg-devel/2012-August/129212.html - please wait until the patch is applied and the ticket closed.
comment:18 Changed 9 months ago by Cigaes
The patch series was just pushed to the current Git head. Please close the bug if it fixes things for you.
comment:19 follow-up: ↓ 26 Changed 9 months ago by Sharkhunter
Does these patches fix srt -> dvdsub as well? Previous adding srt -> dvdsub worked but crashed the video during playback (crash on first subtitle frame) now (at least Zeranoes win build" carshes completly without a trace...
comment:20 Changed 9 months ago by Cigaes
No, it does not. srt is text, dvdsub is bitmap: converting one to the other would require rendering the text, using fonts and layout engine.
comment:21 Changed 9 months ago by Sharkhunter
So burning srt to dvdsub will simply never work?
comment:22 Changed 9 months ago by Cigaes
Not never, but nobody is currently working on it, and it will certainly have to wait for a proper API for decoded text subtitles.
Note that spumux can do it.
comment:23 Changed 9 months ago by Sharkhunter
Mencoder can as well but it has other issues. It would just be nice to avoid using 3 or 4 programs just to get it working...
comment:24 Changed 9 months ago by Cigaes
AFAIK, no, mencoder can not, unless you expressed your problem incorrectly. Also, remember this is an issue tracker, and this issue is, I hope, fixed.
comment:25 Changed 9 months ago by Sharkhunter
Sure I just asked.
comment:26 in reply to: ↑ 19 Changed 9 months ago by cehoyos
- Status changed from open to closed
- Resolution set to fixed
Replying to Sharkhunter:
Previous adding srt -> dvdsub worked but crashed the video during playback (crash on first subtitle frame) now (at least Zeranoes win build" carshes completly without a trace...
Did you report this?
Even if no backtrace is possible, complete, uncut console output missing.



Please provide backtrace etc. for crashes, as explained on http://ffmpeg.org/bugreports.html