[FFmpeg-trac] #10551(ffmpeg:new): When copying chapters to an ogg file 1 second is added to the timestamp of some chapters
FFmpeg
trac at avcodec.org
Wed Sep 6 07:27:36 EEST 2023
#10551: When copying chapters to an ogg file 1 second is added to the timestamp of
some chapters
------------------------------------+----------------------------------
Reporter: giwiniswut | Type: defect
Status: new | Priority: normal
Component: ffmpeg | Version: 6.0
Keywords: | Blocked By:
Blocking: | Reproduced by developer: 0
Analyzed by developer: 0 |
------------------------------------+----------------------------------
Summary of the bug:
While converting a chaptered m4a (aac) audio to ogg (opus) I noticed that
some chapters were off by one second, exactly. The decimal points are
intact, the second timestamp has exactly 1s added onto it.
While converting, ffmpeg prints the correct timestamps. When taking a look
at the resulting file after conversion is done the timestamps are off.
I do not see an obvious pattern as per which chapters are affected.
Things work as expected if chapter information is manually converted to
vorbiscomment chapter tags. (If that's what they're called, what I'm
trying to refer to is this style of chapters in ffmetadata:)
CHAPTER000=00:00:00.000
CHAPTER000NAME=Chapter 1
CHAPTER001=00:00:01.000
CHAPTER001NAME=Chapter 2
[...]
FFmpeg & mpv properly pick up the chapters in this case.
How to reproduce:
{{{
# Note: source.m4a is omitted, chapter information from ffmetadata.txt is
attached instead.
# The issue is reproducible with that file alone.
% ffmpeg -i source.m4a -map_metadata 0:s -f ffmetadata ffmetadata.txt
% LENGTH='04:01:42.32' # duration of source.m4a as reported in previous
output
% ffmpeg -f lavfi -i anullsrc -i ffmetadata.txt -map_chapters 1 -t
"$LENGTH" ffmetadata.opus
% ffmpeg -i ffmetadata.opus -map_metadata 0:s -f ffmetadata
ffmetadata.opus.reexport.txt
% diff ffmetadata.txt ffmetadata.opus.reexport.txt
==> Some chapters are off by 1s. The last END tag is adjusted to the
precise length of the new file.
# Note: resulting chapters.txt file is attached
% echo ";FFMETADATA1" >chapters.txt
% ffprobe -v error -of default=noprint_wrappers=1 -show_entries chapters
source.m4a \
| while read -r line; do
tt="${line#TAG:title=}"
if [ "$tt" = "$line" ]; then
eval $line
else
stmp=$(date --date="@$start_time" --utc +'%T.%3N')
printf 'CHAPTER%03d=%s\nCHAPTER%03dNAME=Chapter %d\n' $id
"$stmp" $id $((id+1))
fi
done >>chapters.txt
% ffmpeg -f lavfi -i anullsrc -i chapters.txt -map_metadata 1 -t "$LENGTH"
chapters.opus
% ffmpeg -i chapters.opus -map_metadata 0:s -f ffmetadata
chapters.opus.reexport.txt
% diff ffmetadata.txt chapters.opus.reexport.txt
==> All chapters are correct. Only the last END tag is adjusted to the
precise length of the new file.
ffmpeg version 2:6.0-9 as packaged by Arch Linux
https://archlinux.org/packages/extra/x86_64/ffmpeg/
built on 2023-09-05 17:55 UTC
ffmpeg version git+release/6.0 at 3d5edb89e75fe3ab3a6757208ef121fa2b0f54c7
commit date 2023-08-08 17:41:20 UTC
}}}
--
Ticket URL: <https://trac.ffmpeg.org/ticket/10551>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
More information about the FFmpeg-trac
mailing list