subed icon indicating copy to clipboard operation
subed copied to clipboard

[bug] Content of the waveform for the last subtitle is not properly centered

Open rodrigomorales1 opened this issue 2 months ago • 2 comments

How I reproduced the bug

I created a sample audio file /tmp/subed/a.mp3 using the command shown below. The audio plays beeps at times 00:01, 00:03, 00:05 and 00:07 and 00:09. The screenshot shown below shows the waveform in Audacity version 2.4.2.

$ ffmpeg \
  -v error \
  -y \
  -f lavfi -i "sine=frequency=1000:duration=10" \
  -af "volume=0:enable='between(t,0,1)',\
volume=0:enable='between(t,1.2,3)',\
volume=0:enable='between(t,3.2,5)',\
volume=0:enable='between(t,5.2,7)',\
volume=0:enable='between(t,7.2,9)',\
volume=0:enable='between(t,9.2,10)'" \
  /tmp/subed/a.mp3

image

I inserted the content of the code block below into the file /tmp/subed/a.srt.

1
00:00:00,000 --> 00:00:02,000
This is subtitle no. 1

2
00:00:02,000 --> 00:00:04,000
This is subtitle no. 2

3
00:00:04,000 --> 00:00:06,000
This is subtitle no. 3

4
00:00:06,000 --> 00:00:08,000
This is subtitle no. 4

5
00:00:08,000 --> 00:00:10,000
This is subtitle no. 5

I cloned the subed git repository to make sure that I was using the latest changes in subed.

$ git clone --branch main --depth 1 https://github.com/sachac/subed /tmp/subed/subed-repo

I built GNU Emacs 29.3 from source. For convenience to reproduce the bug, I wrote the following command to start Emacs, visit the file /tmp/subed/a.srt and enable subed-waveform-minor-mode.

$ EMACSLOADPATH= EMACSNATIVELOADPATH= ./src/emacs \
             --quick \
             --no-splash \
             --eval "(add-to-list 'load-path \"/tmp/subed/subed-repo/subed/\")" \
             --eval "(require 'subed-srt)" \
             --eval "(add-hook 'subed-mode-hook 'subed-enable-sync-player-to-point)" \
             --eval "(add-hook 'subed-mode-hook 'subed-enable-loop-over-current-subtitle)" \
             --eval "(find-file \"/tmp/subed/a.srt\")" \
             --eval "(subed-waveform-minor-mode 1)"

When I executed the command, an Emacs window and a mpv window were opened and the waveform for the first subtitle (the subtitle the point was on) was shown. See screenshot below.

image

I moved the point to the last subtitle (i.e. This is subtitle no. 5).

What happened?

The waveform image which was inserted into the buffer showed the waveform for the beep further to the right than its actual position. See screenshot below.

image

The screenshot shown below shows the buffer after calling subed-waveform-toggle-show-all. Note that the waveform for the beep is centered for all subtitles except for the last one.

image

What should have happened?

The waveform for the beep in the last subtitle should be shown at the middle of the image since the beep is approximately played at 00:09 and the subtitle spans from 00:08 to 00:10.

System information

ELISP> (version)
"GNU Emacs 29.3 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.33, cairo version 1.16.0)
 of 2024-06-20"
$ ffmpeg -version                                                           
ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil      56. 70.100 / 56. 70.100
libavcodec     58.134.100 / 58.134.100
libavformat    58. 76.100 / 58. 76.100
libavdevice    58. 13.100 / 58. 13.100
libavfilter     7.110.100 /  7.110.100
libswscale      5.  9.100 /  5.  9.100
libswresample   3.  9.100 /  3.  9.100
libpostproc    55.  9.100 / 55.  9.100

rodrigomorales1 avatar Jun 20 '24 04:06 rodrigomorales1