[FFmpeg-user] generating silent audio duration is not accurate

Jeanne Rich jrich at laika.com
Fri Sep 20 01:12:36 CEST 2013


Hi, I'm trying to generate some silent audio - equivalent to 1 frame of video and a 48000 sample rate. I specify the duration with the -t option and set that to 0.041667 which is equivalent to 2000 audio samples. I am not doing anything fancy with the codec, simply creating pcm_s16le. The returning wav file has a duration of 0.042667 which is 2048 samples. Is this a bug? or am I doing something wrong? I also tried -frames:a 2000 and that gave me something that was 42 seconds long. 

I would really like to see this work accurately, at this point I am going to have to revert my code to use sox instead. 

-jeanne 

Below is the command: 

'ffmpeg' -loglevel debug '-ar' '48000' '-f' 's16le' '-ac' '2' '-acodec' 'pcm_s16le' '-i' '/dev/zero' '-f' 'wav' '-acodec' 'pcm_s16le' '-ar' '48000' '-ac' '2' '-t' '0.041667' '-y' '/laika/tmp/jrich/trans/bad1secsilence.wav' 
ffmpeg version 2.0.1 Copyright (c) 2000-2013 the FFmpeg developers 
built on Sep 11 2013 17:02:35 with gcc 4.1.2 (GCC) 
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/2.0.1 --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC' 
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 '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'. 
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'. 
Reading option '-f' ... matched as option 'f' (force format) with argument 's16le'. 
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '2'. 
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'pcm_s16le'. 
Reading option '-i' ... matched as input file with argument '/dev/zero'. 
Reading option '-f' ... matched as option 'f' (force format) with argument 'wav'. 
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'pcm_s16le'. 
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'. 
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '2'. 
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '0.041667'. 
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. 
Reading option '/laika/tmp/jrich/trans/bad1secsilence.wav' ... matched as output file. 
Finished splitting the commandline. 
Parsing a group of options: global . 
Applying option loglevel (set logging level) with argument debug. 
Applying option y (overwrite output files) with argument 1. 
Successfully parsed a group of options. 
Parsing a group of options: input file /dev/zero. 
Applying option ar (set audio sampling rate (in Hz)) with argument 48000. 
Applying option f (force format) with argument s16le. 
Applying option ac (set number of audio channels) with argument 2. 
Applying option acodec (force audio codec ('copy' to copy stream)) with argument pcm_s16le. 
Successfully parsed a group of options. 
Opening an input file: /dev/zero. 
[s16le @ 0x1ab5b20] File position before avformat_find_stream_info() is 0 
[s16le @ 0x1ab5b20] max_analyze_duration 5000000 reached at 5013333 microseconds 
[s16le @ 0x1ab5b20] File position after avformat_find_stream_info() is 974848 
Guessed Channel Layout for Input Stream #0.0 : stereo 
Input #0, s16le, from '/dev/zero': 
Duration: N/A, bitrate: 1536 kb/s 
Stream #0:0, 237, 1/48000: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s 
Successfully opened the file. 
Parsing a group of options: output file /laika/tmp/jrich/trans/bad1secsilence.wav. 
Applying option f (force format) with argument wav. 
Applying option acodec (force audio codec ('copy' to copy stream)) with argument pcm_s16le. 
Applying option ar (set audio sampling rate (in Hz)) with argument 48000. 
Applying option ac (set number of audio channels) with argument 2. 
Applying option t (record or transcode "duration" seconds of audio/video) with argument 0.041667. 
Successfully parsed a group of options. 
Opening an output file: /laika/tmp/jrich/trans/bad1secsilence.wav. 
Successfully opened the file. 
detected 4 logical cores 
[graph 0 input from stream 0:0 @ 0x1ac2fe0] Setting 'time_base' to value '1/48000' 
[graph 0 input from stream 0:0 @ 0x1ac2fe0] Setting 'sample_rate' to value '48000' 
[graph 0 input from stream 0:0 @ 0x1ac2fe0] Setting 'sample_fmt' to value 's16' 
[graph 0 input from stream 0:0 @ 0x1ac2fe0] Setting 'channel_layout' to value '0x3' 
[graph 0 input from stream 0:0 @ 0x1ac2fe0] tb:1/48000 samplefmt:s16 samplerate:48000 chlayout:0x3 
[audio format for output stream 0:0 @ 0x1ac35c0] Setting 'sample_fmts' to value 's16' 
[audio format for output stream 0:0 @ 0x1ac35c0] Setting 'sample_rates' to value '48000' 
[audio format for output stream 0:0 @ 0x1ac35c0] Setting 'channel_layouts' to value '0x3' 
[AVFilterGraph @ 0x1aadfa0] query_formats: 4 queried, 9 merged, 0 already done, 0 delayed 
Output #0, wav, to '/laika/tmp/jrich/trans/bad1secsilence.wav': 
Metadata: 
ISFT : Lavf55.12.100 
Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, stereo, s16, 1536 kb/s 
Stream mapping: 
Stream #0:0 -> #0:0 (pcm_s16le -> pcm_s16le) 
Press [q] to stop, [?] for help 
No more output streams to write to, finishing. 
size= 8kB time=00:00:00.04 bitrate=1551.0kbits/s 
video:0kB audio:8kB subtitle:0 global headers:0kB muxing overhead 0.976562% 
3 frames successfully decoded, 0 decoding errors 
[AVIOContext @ 0x1ac2340] Statistics: 4 seeks, 5 writeouts 
[AVIOContext @ 0x1ab6220] Statistics: 983040 bytes read, 0 seeks 


The ffprobe output is: 

ffprobe -show_streams -show_format /laika/tmp/jrich/trans/bad1secsilence.wav 
ffprobe version 2.0.1 Copyright (c) 2007-2013 the FFmpeg developers 
built on Sep 11 2013 17:02:35 with gcc 4.1.2 (GCC) 
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/2.0.1 --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC' 
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 
Input #0, wav, from '/laika/tmp/jrich/trans/bad1secsilence.wav': 
Metadata: 
encoder : Lavf55.12.100 
Duration: 00:00:00.04, bitrate: 1550 kb/s 
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 2 channels, s16, 1536 kb/s 
[STREAM] 
index=0 
codec_name=pcm_s16le 
codec_long_name=PCM signed 16-bit little-endian 
profile=unknown 
codec_type=audio 
codec_time_base=1/48000 
codec_tag_string=[1][0][0][0] 
codec_tag=0x0001 
sample_fmt=s16 
sample_rate=48000 
channels=2 
bits_per_sample=16 
id=N/A 
r_frame_rate=0/0 
avg_frame_rate=0/0 
time_base=1/48000 
start_pts=N/A 
start_time=N/A 
duration_ts=2048 
duration=0.042667 
bit_rate=1536000 
nb_frames=N/A 
nb_read_frames=N/A 
nb_read_packets=N/A 
DISPOSITION:default=0 
DISPOSITION:dub=0 
DISPOSITION:original=0 
DISPOSITION:comment=0 
DISPOSITION:lyrics=0 
DISPOSITION:karaoke=0 
DISPOSITION:forced=0 
DISPOSITION:hearing_impaired=0 
DISPOSITION:visual_impaired=0 
DISPOSITION:clean_effects=0 
DISPOSITION:attached_pic=0 
[/STREAM] 
[FORMAT] 
filename=/laika/tmp/jrich/trans/bad1secsilence.wav 
nb_streams=1 
format_name=wav 
format_long_name=WAV / WAVE (Waveform Audio) 
start_time=N/A 
duration=0.042667 
size=8272 
bit_rate=1550987 
TAG:encoder=Lavf55.12.100 
[/FORMAT] 




More information about the ffmpeg-user mailing list