Opened 11 years ago
Closed 11 years ago
#2912 closed defect (worksforme)
splitting the first minute from a wav file generated a slightly too long file (off by 160 samples)
Reported by: | Bernhard Wagner | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | ffmpeg |
Version: | 2.0.1 | Keywords: | |
Cc: | ffmpeg.org20130829@bernhardwagner.net | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
What you were trying to accomplish:
split the first minute from a wav file
The problem you encountered:
the resulting file was not the exact length expected.
I expected the file to have length 2646000 (= 60 * 44100) samples, but received length 2646160, i.e. 160 samples too many. I confirmed that sox generates a file of the expected length.
The exact command line you were using:
ffmpeg -i exil1211212315_02WaveGain.wav -ss 00:00:00 -t 00:01:00 -acodec copy outffmpeg2.wav
The full, uncut console output provided by ffmpeg -v 9 -loglevel 99 -i
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Aug 15 2013 10:56:46 with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --arch=x86_64 --enable-runtime-cpudetect
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.102 / 55. 18.102
libavformat 55. 12.100 / 55. 12.100
libavdevice 55. 3.100 / 55. 3.100
libavfilter 3. 79.101 / 3. 79.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument 'exil1211212315_02WaveGain.wav'.
Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '00:00:00'.
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '00:01:00'.
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'.
Reading option 'outffmpeg3.wav' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file exil1211212315_02WaveGain.wav.
Successfully parsed a group of options.
Opening an input file: exil1211212315_02WaveGain.wav.
[wav @ 0x7fae6881a600] Format wav probed with size=2048 and score=99
[wav @ 0x7fae6881a600] File position before avformat_find_stream_info() is 44
[wav @ 0x7fae6881a600] parser not found for codec pcm_s24le, packets or times may be invalid.
Last message repeated 1 times
[wav @ 0x7fae6881a600] max_analyze_duration 5000000 reached at 5010612 microseconds
[wav @ 0x7fae6881a600] File position after avformat_find_stream_info() is 1338128
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, wav, from 'exil1211212315_02WaveGain.wav':
Duration: 00:28:14.47, bitrate: 2116 kb/s
Stream #0:0, 326, 1/44100: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, s32, 2116 kb/s
Successfully opened the file.
Parsing a group of options: output file outffmpeg3.wav.
Applying option ss (set the start time offset) with argument 00:00:00.
Applying option t (record or transcode "duration" seconds of audio/video) with argument 00:01:00.
Applying option acodec (force audio codec ('copy' to copy stream)) with argument copy.
Successfully parsed a group of options.
Opening an output file: outffmpeg3.wav.
Successfully opened the file.
Output #0, wav, to 'outffmpeg3.wav':
Metadata:
ISFT : Lavf55.12.100
Stream #0:0, 0, 1/44100: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 44100 Hz, stereo, 2116 kb/s
Stream mapping:
Press [q] to stop, ? for help
No more output streams to write to, finishing.
size= 15505kB time=00:01:00.00 bitrate=2116.8kbits/s
video:0kB audio:15505kB subtitle:0 global headers:0kB muxing overhead 0.000642%
0 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0x7fae684046a0] Statistics: 4 seeks, 3883 writeouts
[AVIOContext @ 0x7fae68403e20] Statistics: 15892480 bytes read, 0 seeks
The input file is of this type, according to soxi:
Input File : 'exil1211212315_02WaveGain.wav'
Channels : 2
Sample Rate : 44100
Precision : 24-bit
Duration : 00:28:14.47 = 74726144 samples = 127085 CDDA sectors
File Size : 448M
Bit Rate : 2.12M
Sample Encoding: 24-bit Signed Integer PCM
Change History (8)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
Thanks!
ffmpeg -i exil1211212315_02.wav -af atrim=0:60 outffmpeg2.wav
The audio now has the correct length (2646000 samples). But at the same time the format of input and output files now differ (precision from 24 to 16 bit, Sample Encoding: from "24-bit Signed Integer PCM" to "16-bit Signed Integer PCM"):
Input File : 'exil1211212315_02.wav'
Channels : 2
Sample Rate : 44100
Precision : 24-bit
Duration : 00:28:14.47 = 74726144 samples = 127085 CDDA sectors
File Size : 448M
Bit Rate : 2.12M
Sample Encoding: 24-bit Signed Integer PCM
Input File : 'outffmpeg2.wav'
Channels : 2
Sample Rate : 44100
Precision : 16-bit
Duration : 00:01:00.00 = 2646000 samples = 4500 CDDA sectors
File Size : 10.6M
Bit Rate : 1.41M
Sample Encoding: 16-bit Signed Integer PCM
comment:3 by , 11 years ago
That is because you failed to specify encoder you want and instead default one is used.
comment:4 by , 11 years ago
Thank you. Ok, I changed it to:
ffmpeg -i exil1211212315_02.wav -af atrim=0:60 -acodec pcm_s24le outffmpeg2.wav
I wonder whether it would make sense to use the same encoding as the source file by default. That's how sox handles the situation (from the help output of sox):
FORMAT OPTIONS (fopts):
Input file format options need only be supplied for files that are headerless.
Output files will have the same format as the input file where possible and not
overriden by any of various means including providing output format options.
comment:6 by , 11 years ago
Cc: | added |
---|
comment:8 by , 11 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
Use atrim filter.
Test with latest version if this still happens.