[FFmpeg-user] Send audio to Axis encoder and change http_post header
Mark Umansky
umansky at torcrobotics.com
Tue Oct 21 14:26:37 CEST 2014
Hello,
I am trying to send audio data to an Axis encoder using the VAPIX API: http://www.axis.com/files/manuals/vapix_audio_52913_en_1307.pdf
Essentially I send audio to it by pointing something at the address of the encoder: http://<ip address/ axis-cgi/audio/transmit.cgi, which is an HTTP POST command. I am sending it microphone audio from my computer in an expected format.
The sample header they have in their documentation has the following header:
POST /axis-cgi/audio/transmit.cgi HTTP/1.0
Content-Type: audio/basic
Content-Length: 9999999
Connection: Keep-Alive
Cache-Control: no-cache
Authorization: Basic cm9vdDpwYXNz
When I execute my command, I get this as my header:
Transfer-Encoding: chunked
User-Agent: Lavf/56.7.101
Accept: */*
Connection: close
Host: 192.168.0.90
Icy-MetaData: 1
The "connection: close" is what I think is preventing any data from getting to the encoder as it errors out after one frame.
Full log output is below, any help would be appreciated if I am on the right (or wrong) track here.
Thanks.
Full log output:
ffmpeg started on 2014-10-21 at 08:21:29
Report written to "ffmpeg-20141021-082129.log"
Command line:
ffmpeg -v debug -y -re -f dshow -i "audio=Internal Microphone (Conexant 2" -c:a pcm_mulaw -ac 1 -ar 16000 -b:a 128k -f flv http://192.168.0.90/axis-cgi/audio/transmit.cgi -report
ffmpeg version N-66521-g3edb9aa Copyright (c) 2000-2014 the FFmpeg developers
built on Sep 27 2014 22:10:25 with gcc 4.9.1 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 54. 7.101 / 54. 7.101
libavcodec 56. 1.101 / 56. 1.101
libavformat 56. 7.101 / 56. 7.101
libavdevice 56. 1.100 / 56. 1.100
libavfilter 5. 1.102 / 5. 1.102
libswscale 3. 1.100 / 3. 1.100
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 1.100 / 53. 1.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-re' ... matched as option 're' (read input at native frame rate) with argument '1'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'dshow'.
Reading option '-i' ... matched as input file with argument 'audio=Internal Microphone (Conexant 2'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'pcm_mulaw'.
Reading option '-ac' ... matched as option 'ac' (set number of audio channels) with argument '1'.
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '16000'.
Reading option '-b:a' ... matched as option 'b' (video bitrate (please use -b:v)) with argument '128k'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'flv'.
Reading option 'http://192.168.0.90/axis-cgi/audio/transmit.cgi' ... matched as output file.
Reading option '-report' ... matched as option 'report' (generate a report) with argument '1'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Applying option report (generate a report) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file audio=Internal Microphone (Conexant 2.
Applying option re (read input at native frame rate) with argument 1.
Applying option f (force format) with argument dshow.
Successfully parsed a group of options.
Opening an input file: audio=Internal Microphone (Conexant 2.
[dshow @ 0000000002b0a500] All info found
Guessed Channel Layout for Input Stream #0.0 : stereo
Input #0, dshow, from 'audio=Internal Microphone (Conexant 2':
Duration: N/A, start: 80438.353000, bitrate: 1411 kb/s
Stream #0:0, 1, 1/10000000: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Successfully opened the file.
Parsing a group of options: output file http://192.168.0.90/axis-cgi/audio/transmit.cgi.
Applying option c:a (codec name) with argument pcm_mulaw.
Applying option ac (set number of audio channels) with argument 1.
Applying option ar (set audio sampling rate (in Hz)) with argument 16000.
Applying option b:a (video bitrate (please use -b:v)) with argument 128k.
Applying option f (force format) with argument flv.
Successfully parsed a group of options.
Opening an output file: http://192.168.0.90/axis-cgi/audio/transmit.cgi.
[http @ 0000000002af3700] request: POST /axis-cgi/audio/transmit.cgi HTTP/1.1
Transfer-Encoding: chunked
User-Agent: Lavf/56.7.101
Accept: */*
Connection: close
Host: 192.168.0.90
Icy-MetaData: 1
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0000000002b83540] Setting 'time_base' to value '1/44100'
[graph 0 input from stream 0:0 @ 0000000002b83540] Setting 'sample_rate' to value '44100'
[graph 0 input from stream 0:0 @ 0000000002b83540] Setting 'sample_fmt' to value 's16'
[graph 0 input from stream 0:0 @ 0000000002b83540] Setting 'channel_layout' to value '0x3'
[graph 0 input from stream 0:0 @ 0000000002b83540] tb:1/44100 samplefmt:s16 samplerate:44100 chlayout:0x3
[audio format for output stream 0:0 @ 0000000002b849c0] Setting 'sample_fmts' to value 's16'
[audio format for output stream 0:0 @ 0000000002b849c0] Setting 'sample_rates' to value '16000'
[audio format for output stream 0:0 @ 0000000002b849c0] Setting 'channel_layouts' to value '0x4'
[audio format for output stream 0:0 @ 0000000002b849c0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0000000002c09980] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
0.500000 0.500000
[auto-inserted resampler 0 @ 0000000002b84e00] ch:2 chl:stereo fmt:s16 r:44100Hz -> ch:1 chl:mono fmt:s16 r:16000Hz
Output #0, flv, to 'http://192.168.0.90/axis-cgi/audio/transmit.cgi':
Metadata:
encoder : Lavf56.7.101
Stream #0:0, 0, 1/1000: Audio: pcm_mulaw ([8][0][0][0] / 0x0008), 16000 Hz, mono, s16, 128 kb/s
Metadata:
encoder : Lavc56.1.101 pcm_mulaw
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_mulaw (native))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Unknown error
No more output streams to write to, finishing.
[flv @ 0000000002b77560] Failed to update header with correct duration.
[flv @ 0000000002b77560] Failed to update header with correct filesize.
size= 8kB time=00:00:00.49 bitrate= 131.8kbits/s
video:0kB audio:8kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.955912%
Input file #0 (audio=Internal Microphone (Conexant 2):
Input stream #0:0 (audio): 1 packets read (88200 bytes); 1 frames decoded (22050 samples);
Total: 1 packets (88200 bytes) demuxed
Output file #0 (http://192.168.0.90/axis-cgi/audio/transmit.cgi):
Output stream #0:0 (audio): 1 frames encoded (7984 samples); 1 packets muxed (7984 bytes);
Total: 1 packets (7984 bytes) muxed
1 frames successfully decoded, 0 decoding errors
[AVIOContext @ 0000000002b83460] Statistics: 0 seeks, 2 writeouts
Conversion failed!
More information about the ffmpeg-user
mailing list