trimmed audio has wrong duration

classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

trimmed audio has wrong duration

FFmpeg-users mailing list
Hello

I'm trying to trim 1.001 seconds from the beginning of a FLAC file.
But the output has the wrong duration (same as the input) and so it's
corrupt.
When I try to open it with Adobe Audition I get an error (cannot read file).

General
Complete name                            : C:\_audio.flac
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
File size                                : 759 MiB
Duration                                 : 1 h 31 min
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 160 kb/s
Track name                               : MILLENIUM_D1_VERBLENDUNG.Title0
Writing application                      : Lavf58.20.100

Audio
Format                                   : FLAC
Format/Info                              : Free Lossless Audio Codec
Duration                                 : 1 h 31 min
Bit rate mode                            : Variable
Bit rate                                 : 1 160 kb/s
Channel(s)                               : 6 channels
Channel layout                           : L R C LFE Ls Rs
Sampling rate                            : 48.0 kHz
Bit depth                                : 16 bits
Compression mode                         : Lossless
Stream size                              : 759 MiB (100%)
Writing library                          : Lavf58.20.100

_ffprobe.exe -v 0 -sexagesimal -show_entries format^=duration -of
compact^=p^=0^:nk^=1 _audio.flac
1:31:29.848938


5489.848938 - 1.001 = 5488.847938


_ffmpeg.exe -ss 1.001 -i _audio.flac -t 5488.847938 -codec copy
_audio_1.flac
ffmpeg version N-95216-ge6625ca41f Copyright (c) 2000-2019 the FFmpeg
developers
  built with gcc 9.2.1 (GCC) 20190918
  configuration: --enable-gpl --enable-version3 --enable-sdl2
--enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libdav1d --enable-libbluray --enable-libfreetype
--enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
--enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy
--enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx
--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
--enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp
--enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
--enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
--enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va
--enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
--enable-libopenmpt --enable-amf
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 59.101 / 58. 59.101
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 61.100 /  7. 61.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, flac, from '_audio.flac':
  Metadata:
    TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
    encoder         : Lavf58.20.100
  Duration: 01:31:29.85, start: 0.000000, bitrate: 1159 kb/s
    Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
Output #0, flac, to '_audio_1.flac':
  Metadata:
    TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
    encoder         : Lavf58.33.100
    Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
video:0kB audio:777322kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.001046%


I also tried -t as an input option.
Same problem.

Best
Felix


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

Carl Eugen Hoyos-2
Am Sa., 5. Okt. 2019 um 12:49 Uhr schrieb Felix Muster via ffmpeg-user
<[hidden email]>:

> I'm trying to trim 1.001 seconds from the beginning of a FLAC file.
> But the output has the wrong duration (same as the input) and so it's
> corrupt.
> When I try to open it with Adobe Audition I get an error (cannot read file).
>
> General
> Complete name                            : C:\_audio.flac
> Format                                   : FLAC
> Format/Info                              : Free Lossless Audio Codec
> File size                                : 759 MiB
> Duration                                 : 1 h 31 min
> Overall bit rate mode                    : Variable
> Overall bit rate                         : 1 160 kb/s
> Track name                               : MILLENIUM_D1_VERBLENDUNG.Title0
> Writing application                      : Lavf58.20.100
>
> Audio
> Format                                   : FLAC
> Format/Info                              : Free Lossless Audio Codec
> Duration                                 : 1 h 31 min
> Bit rate mode                            : Variable
> Bit rate                                 : 1 160 kb/s
> Channel(s)                               : 6 channels
> Channel layout                           : L R C LFE Ls Rs
> Sampling rate                            : 48.0 kHz
> Bit depth                                : 16 bits
> Compression mode                         : Lossless
> Stream size                              : 759 MiB (100%)
> Writing library                          : Lavf58.20.100

I don't remember an FFmpeg issue where this output was useful.

> _ffprobe.exe -v 0 -sexagesimal -show_entries format^=duration -of
> compact^=p^=0^:nk^=1 _audio.flac
> 1:31:29.848938
>
>
> 5489.848938 - 1.001 = 5488.847938
>
>
> _ffmpeg.exe -ss 1.001 -i _audio.flac -t 5488.847938 -codec copy
> _audio_1.flac
> ffmpeg version N-95216-ge6625ca41f Copyright (c) 2000-2019 the FFmpeg
> developers
>   built with gcc 9.2.1 (GCC) 20190918
>   configuration: --enable-gpl --enable-version3 --enable-sdl2
> --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass
> --enable-libdav1d --enable-libbluray --enable-libfreetype
> --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb
> --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy
> --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx
> --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265
> --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp
> --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
> --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom
> --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va
> --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
> --enable-libopenmpt --enable-amf
>   libavutil      56. 35.100 / 56. 35.100
>   libavcodec     58. 59.101 / 58. 59.101
>   libavformat    58. 33.100 / 58. 33.100
>   libavdevice    58.  9.100 / 58.  9.100
>   libavfilter     7. 61.100 /  7. 61.100
>   libswscale      5.  6.100 /  5.  6.100
>   libswresample   3.  6.100 /  3.  6.100
>   libpostproc    55.  6.100 / 55.  6.100
> Input #0, flac, from '_audio.flac':
>   Metadata:
>     TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
>     encoder         : Lavf58.20.100
>   Duration: 01:31:29.85, start: 0.000000, bitrate: 1159 kb/s
>     Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
> Output #0, flac, to '_audio_1.flac':
>   Metadata:
>     TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
>     encoder         : Lavf58.33.100
>     Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
> Stream mapping:
>   Stream #0:0 -> #0:0 (copy)
> Press [q] to stop, [?] for help
> video:0kB audio:777322kB subtitle:0kB other streams:0kB global headers:0kB
> muxing overhead: 0.001046%

While it is not generally possible to cut flac like this (you can instead do the
cutting when creating the first flac file or you can re-encode), feel free to
provide the input sample (I guess the issue should be reproducible with a
cut file).

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

FFmpeg-users mailing list
I cut the first ten seconds as a sample: _ffmpeg.exe -i _audio.flac -t 10 -codec copy _audio_2.flac
https://gofile.io/?c=pnLfN2

ffprobe still tells me a length of 1:31:29.848938

_ffmpeg -i _audio_2.flac -f null
ffmpeg version N-95216-ge6625ca41f Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20190918
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 35.100 / 56. 35.100
  libavcodec     58. 59.101 / 58. 59.101
  libavformat    58. 33.100 / 58. 33.100
  libavdevice    58.  9.100 / 58.  9.100
  libavfilter     7. 61.100 /  7. 61.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, flac, from '_audio_2.flac':
  Metadata:
    TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
    encoder         : Lavf58.33.100
  Duration: 01:31:29.85, start: 0.000000, bitrate: 1 kb/s
    Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
    encoder         : Lavf58.33.100
    Stream #0:0: Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s
    Metadata:
      encoder         : Lavc58.59.101 pcm_s16le
size=N/A time=00:00:10.08 bitrate=N/A speed= 530x    
video:0kB audio:5670kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

This gives me the correct length: 00:00:10.08

I think there is wrong metadata stored in the file?

_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

kumowoon1025
In reply to this post by FFmpeg-users mailing list
> _ffprobe.exe -v 0 -sexagesimal -show_entries format^=duration -of
> compact^=p^=0^:nk^=1 _audio.flac
> 1:31:29.848938
>
>
> 5489.848938 - 1.001 = 5488.847938
>
>

What is the point of doing this calculation?

> I'm trying to trim 1.001 seconds from the beginning of a FLAC file.
> But the output has the wrong duration (same as the input) and so it's
> corrupt.

It’s probably because flac is mostly a stream format, and you’re doing a stream copy. Re-encoding should fix all of this, it’s relatively inexpensive, and it’s lossless after all, but if you really don’t want this, maybe try putting it in an ogg.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

FFmpeg-users mailing list
> What is the point of doing this calculation?
I need to trim 1.001 seconds

> It’s probably because flac is mostly a stream format, and you’re doing a stream copy. Re-encoding should fix all of this, it’s relatively inexpensive, > and it’s lossless after all, but if you really don’t want this, maybe try putting it in an ogg.
Hey, great. That was it! Thank you.


_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

Carl Eugen Hoyos-2
In reply to this post by FFmpeg-users mailing list
Am Sa., 5. Okt. 2019 um 16:27 Uhr schrieb Felix Muster via ffmpeg-user
<[hidden email]>:

>
> I cut the first ten seconds as a sample: _ffmpeg.exe -i _audio.flac -t 10 -codec copy _audio_2.flac
> https://gofile.io/?c=pnLfN2
>
> ffprobe still tells me a length of 1:31:29.848938
>
> _ffmpeg -i _audio_2.flac -f null
> ffmpeg version N-95216-ge6625ca41f Copyright (c) 2000-2019 the FFmpeg developers
>   built with gcc 9.2.1 (GCC) 20190918
>   configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
>   libavutil      56. 35.100 / 56. 35.100
>   libavcodec     58. 59.101 / 58. 59.101
>   libavformat    58. 33.100 / 58. 33.100
>   libavdevice    58.  9.100 / 58.  9.100
>   libavfilter     7. 61.100 /  7. 61.100
>   libswscale      5.  6.100 /  5.  6.100
>   libswresample   3.  6.100 /  3.  6.100
>   libpostproc    55.  6.100 / 55.  6.100
> Input #0, flac, from '_audio_2.flac':
>   Metadata:
>     TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
>     encoder         : Lavf58.33.100
>   Duration: 01:31:29.85, start: 0.000000, bitrate: 1 kb/s
>     Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s16
> Stream mapping:
>   Stream #0:0 -> #0:0 (flac (native) -> pcm_s16le (native))
> Press [q] to stop, [?] for help
> Output #0, null, to 'pipe:':
>   Metadata:
>     TITLE           : MILLENIUM_D1_VERBLENDUNG.Title0
>     encoder         : Lavf58.33.100
>     Stream #0:0: Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s
>     Metadata:
>       encoder         : Lavc58.59.101 pcm_s16le
> size=N/A time=00:00:10.08 bitrate=N/A speed= 530x
> video:0kB audio:5670kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
>
> This gives me the correct length: 00:00:10.08
>
> I think there is wrong metadata stored in the file?

This is ticket #4905, this this may not be easy to fix.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

FFmpeg-users mailing list
To calculate by reencode is enough for me.

But is it possible to get a thousandth of a second?
0.00 is not precise enough for me.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

kumowoon1025
> To calculate by reencode is enough for me.
>
> But is it possible to get a thousandth of a second?
> 0.00 is not precise enough for me.
Use -ss as an output option. Everything would be a multiple of 1/48000, so that’s probably just a rounded representation, unless it was 0.96?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

FFmpeg-users mailing list
I use -ss and not -t.
But thanks for the info.

I can bypass the problem with -codec flac.
Then it is accurate.

But it is strange anyway:

_ffmpeg.exe -i _audio.flac -t 10 -codec copy _audio_2.flac
—> it shows me 9.98
_ffmpeg.exe -i audio_2.flac -f null -
—> but encode is 10.08

_ffmpeg.exe -i _audio.flac -t 20 -codec copy _audio_2.flac
—> it shows me 19.96
_ffmpeg.exe -i audio_2.flac -f null -
—> but encode is 20.06

And so on ...

But:
_ffmpeg.exe -i _audio.flac -t 10 -codec flac _audio_2.flac
—> 10.00
Always accurate.
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

Moritz Barsnick
On Thu, Oct 10, 2019 at 19:45:41 +0200, FFmpeg user discussions wrote:

> But it is strange anyway:
>
> _ffmpeg.exe -i _audio.flac -t 10 -codec copy _audio_2.flac
> —> it shows me 9.98
> _ffmpeg.exe -i audio_2.flac -f null -
> —> but encode is 10.08
>
> _ffmpeg.exe -i _audio.flac -t 20 -codec copy _audio_2.flac
> —> it shows me 19.96
> _ffmpeg.exe -i audio_2.flac -f null -
> —> but encode is 20.06
>
> And so on ...
>
> But:
> _ffmpeg.exe -i _audio.flac -t 10 -codec flac _audio_2.flac
> —> 10.00
> Always accurate.

With stream copy, ffmpeg will (I guess) cut at nearest audio packet
borders. When re-encoding, it can cut at the exact sample.

Considering that FLAV packets usually contain a lot of samples (I
believe I saw some ffmpeg default of 4096 samples per packet?), the
packet's size will obviously determine the possible precision.

This happens with ther codecs as well, I have experienced it quite
often.

(I don't know why encode and decode have a different opinion regarding
the length, though.)

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: trimmed audio has wrong duration

Carl Eugen Hoyos-2
Am Do., 10. Okt. 2019 um 19:56 Uhr schrieb Moritz Barsnick <[hidden email]>:

> Considering that FLAV packets usually contain a lot of samples (I
> believe I saw some ffmpeg default of 4096 samples per packet?), the
> packet's size will obviously determine the possible precision.

They can be very large, pathological samples exist.

As mentioned before, stream-copying flac has immanent issues,
including that the output file has wrong duration metadata.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".