[FFmpeg-trac] #10949(undetermined:new): Cutting videos with ass streams (duration and timestamps)
FFmpeg
trac at avcodec.org
Sat Apr 6 03:49:45 EEST 2024
#10949: Cutting videos with ass streams (duration and timestamps)
--------------------------------+----------------------------------------
Reporter: x-yuri | Owner: (none)
Type: defect | Status: new
Priority: normal | Component: undetermined
Version: 6.1.1 | Resolution:
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
--------------------------------+----------------------------------------
Description changed by x-yuri:
Old description:
> {{{
> // the video is 20 seconds long
> $ ffprobe -i a.mkv |& grep -E 'Duration:| DURATION |Stream' | grep -v
> STATISTICS
> Duration: 00:00:20.00, start: 0.000000, bitrate: 2223 kb/s
> Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
> 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn (default)
> DURATION : 00:00:20.003000000
> Stream #0:1(spa): Audio: vorbis, 48000 Hz, 5.1, fltp
> DURATION : 00:00:20.003000000
> Stream #0:2(eng): Subtitle: ass
> DURATION : 00:00:18.523000000
>
> $ ffmpeg -i a.mkv a.ass
>
> // cut -ss 10 -to 20
> $ ffmpeg -i a.mkv -ss 10 b.mkv
>
> // the overall and ass stream duration is 20 seconds
> $ ffprobe -i b.mkv |& grep -E 'Duration:| DURATION |Stream' | grep -v
> STATISTICS
> Duration: 00:00:18.53, start: 0.000000, bitrate: 1450 kb/s
> Stream #0:0: Video: h264 (High), yuv420p(progressive), 1920x1080 [SAR
> 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn (default)
> DURATION : 00:00:10.003000000
> Stream #0:1(spa): Audio: vorbis, 48000 Hz, 5.1, fltp
> DURATION : 00:00:10.016000000
> Stream #0:2(eng): Subtitle: ass
> DURATION : 00:00:18.526000000
>
> $ ffmpeg -i b.mkv b.ass
>
> // it removed the dialogues, but didn't change the timestamps
> // actually the timestamps changed a bit, but not enough and in the wrong
> direction
> $ diff -u a.ass b.ass
> --- a.ass 2024-04-06 03:08:02.822240448 +0300
> +++ b.ass 2024-04-06 03:08:46.379108389 +0300
> @@ -12,9 +12,7 @@
>
> [Events]
> Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV,
> Effect, Text
> -Dialogue: 0,0:00:06.04,0:00:08.36,Default,,0,0,0,,{\c&HFFFFFF&}Where's
> the surgical instrument kit?{\c}
> -Dialogue: 0,0:00:08.44,0:00:10.64,Default,,0,0,0,,{\c&HFFFFFF&}-There's
> a scalpel in it.{\c}\N{\c&HFFFFFF&}-Berlin has it.{\c}
> -Dialogue: 0,0:00:11.40,0:00:14.40,Default,,0,0,0,,{\c&HFFFFFF&}The
> surgeons!{\c}\N{\c&HFFFFFF&}Go steal tools from them. Hurry!{\c}
> -Dialogue: 0,0:00:14.48,0:00:15.36,Default,,0,0,0,,{\c&HFFFFFF&}Okay.{\c}
> -Dialogue: 0,0:00:15.44,0:00:16.52,Default,,0,0,0,,{\c&HFFFFFF&}Wait!{\c}
> -Dialogue: 0,0:00:17.12,0:00:18.52,Default,,0,0,0,,{\c&HFFFFFF&}Give him
> this note, please.{\c}
> +Dialogue: 0,0:00:11.41,0:00:14.41,Default,,0,0,0,,{\c&HFFFFFF&}The
> surgeons!{\c}\N{\c&HFFFFFF&}Go steal tools from them. Hurry!{\c}
> +Dialogue: 0,0:00:14.49,0:00:15.37,Default,,0,0,0,,{\c&HFFFFFF&}Okay.{\c}
> +Dialogue: 0,0:00:15.45,0:00:16.53,Default,,0,0,0,,{\c&HFFFFFF&}Wait!{\c}
> +Dialogue: 0,0:00:17.13,0:00:18.53,Default,,0,0,0,,{\c&HFFFFFF&}Give him
> this note, please.{\c}
>
> $ ffmpeg -version
> ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
> built with gcc 13.2.1 (GCC) 20230801
> configuration: --prefix=/usr --disable-debug --disable-static --disable-
> stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto
> --enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls
> --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-
> libbluray --enable-libbs2b --enable-libdav1d --enable-libdrm --enable-
> libfreetype --enable-libfribidi --enable-libgsm --enable-libharfbuzz
> --enable-libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug
> --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb
> --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-
> libplacebo --enable-libpulse --enable-librav1e --enable-librsvg --enable-
> librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex
> --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora
> --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
> --enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264
> --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid
> --enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-
> opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-
> vulkan
> libavutil 58. 29.100 / 58. 29.100
> libavcodec 60. 31.102 / 60. 31.102
> libavformat 60. 16.100 / 60. 16.100
> libavdevice 60. 3.100 / 60. 3.100
> libavfilter 9. 12.100 / 9. 12.100
> libswscale 7. 5.100 / 7. 5.100
> libswresample 4. 12.100 / 4. 12.100
> libpostproc 57. 3.100 / 57. 3.100
> }}}
New description:
{{{
// the video is 20 seconds long
$ ffprobe -i cut-ass-duration-timestamps.mkv |& grep -E 'Duration:|
DURATION |Stream' | grep -v STATISTICS
Duration: 00:00:20.01, start: 0.000000, bitrate: 207 kb/s
Stream #0:0(spa): Audio: vorbis, 48000 Hz, 5.1, fltp
DURATION : 00:00:20.012000000
Stream #0:1(eng): Subtitle: ass
DURATION : 00:00:18.523000000
$ ffmpeg -i cut-ass-duration-timestamps.mkv cut-ass-duration-
timestamps.ass
// cut -ss 10 -to 20
$ ffmpeg -i cut-ass-duration-timestamps.mkv -ss 10 b.mkv
// the overall and ass stream duration is 20 seconds
$ ffprobe -i b.mkv |& grep -E 'Duration:| DURATION |Stream' | grep -v
STATISTICS
Duration: 00:00:18.53, start: 0.000000, bitrate: 135 kb/s
Stream #0:0(spa): Audio: vorbis, 48000 Hz, 5.1, fltp
DURATION : 00:00:10.016000000
Stream #0:1(eng): Subtitle: ass
DURATION : 00:00:18.526000000
$ ffmpeg -i b.mkv b.ass
// it removed the dialogues, but didn't change the timestamps
// actually the timestamps changed a bit, but not enough and in the wrong
direction
$ diff -u cut-ass-duration-timestamps.ass b.ass
--- cut-ass-duration-timestamps.ass 2024-04-06 03:43:44.611727478
+0300
+++ b.ass 2024-04-06 03:44:24.698540468 +0300
@@ -12,9 +12,7 @@
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV,
Effect, Text
-Dialogue: 0,0:00:06.04,0:00:08.36,Default,,0,0,0,,{\c&HFFFFFF&}Where's
the surgical instrument kit?{\c}
-Dialogue: 0,0:00:08.44,0:00:10.64,Default,,0,0,0,,{\c&HFFFFFF&}-There's a
scalpel in it.{\c}\N{\c&HFFFFFF&}-Berlin has it.{\c}
-Dialogue: 0,0:00:11.40,0:00:14.40,Default,,0,0,0,,{\c&HFFFFFF&}The
surgeons!{\c}\N{\c&HFFFFFF&}Go steal tools from them. Hurry!{\c}
-Dialogue: 0,0:00:14.48,0:00:15.36,Default,,0,0,0,,{\c&HFFFFFF&}Okay.{\c}
-Dialogue: 0,0:00:15.44,0:00:16.52,Default,,0,0,0,,{\c&HFFFFFF&}Wait!{\c}
-Dialogue: 0,0:00:17.12,0:00:18.52,Default,,0,0,0,,{\c&HFFFFFF&}Give him
this note, please.{\c}
+Dialogue: 0,0:00:11.41,0:00:14.41,Default,,0,0,0,,{\c&HFFFFFF&}The
surgeons!{\c}\N{\c&HFFFFFF&}Go steal tools from them. Hurry!{\c}
+Dialogue: 0,0:00:14.49,0:00:15.37,Default,,0,0,0,,{\c&HFFFFFF&}Okay.{\c}
+Dialogue: 0,0:00:15.45,0:00:16.53,Default,,0,0,0,,{\c&HFFFFFF&}Wait!{\c}
+Dialogue: 0,0:00:17.13,0:00:18.53,Default,,0,0,0,,{\c&HFFFFFF&}Give him
this note, please.{\c}
$ ffmpeg -version
ffmpeg version n6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13.2.1 (GCC) 20230801
configuration: --prefix=/usr --disable-debug --disable-static --disable-
stripping --enable-amf --enable-avisynth --enable-cuda-llvm --enable-lto
--enable-fontconfig --enable-frei0r --enable-gmp --enable-gnutls --enable-
gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray
--enable-libbs2b --enable-libdav1d --enable-libdrm --enable-libfreetype
--enable-libfribidi --enable-libgsm --enable-libharfbuzz --enable-
libiec61883 --enable-libjack --enable-libjxl --enable-libmodplug --enable-
libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-
libopenjpeg --enable-libopenmpt --enable-libopus --enable-libplacebo
--enable-libpulse --enable-librav1e --enable-librsvg --enable-
librubberband --enable-libsnappy --enable-libsoxr --enable-libspeex
--enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora
--enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-libvorbis
--enable-libvpl --enable-libvpx --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid
--enable-libzimg --enable-nvdec --enable-nvenc --enable-opencl --enable-
opengl --enable-shared --enable-vapoursynth --enable-version3 --enable-
vulkan
libavutil 58. 29.100 / 58. 29.100
libavcodec 60. 31.102 / 60. 31.102
libavformat 60. 16.100 / 60. 16.100
libavdevice 60. 3.100 / 60. 3.100
libavfilter 9. 12.100 / 9. 12.100
libswscale 7. 5.100 / 7. 5.100
libswresample 4. 12.100 / 4. 12.100
libpostproc 57. 3.100 / 57. 3.100
}}}
--
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10949#comment:1>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list