How to play .flv(h.264 aac) file without playbin2 in gstreamer? - flv

I've got a FLV file and the gstreamer playbin2 could work well, but if I try to manually construct the pipeline, the result is negative.
Can anyone show me what's wrong with my pipeline? Or, how to construct the pipe-line to play FLV file correctly while not using the playbin2?
The target FLV file is also uploaded to dropbox, the url is:
https://dl.dropbox.com/u/5391695/1.flv
I've try to view the dot file generated by the playbin2 method, please view it at
https://dl.dropbox.com/u/5391695/playbin2.png
The following command 1,2 both work, but command 3,4 don't work at all.
1. media information from gst-discover
gst-discoverer-0.10 1.flv
Analyzing file:///home/gst/debug/1.flv
Done discovering file:///home/gst/debug/1.flv
Topology:
container: Flash
audio: MPEG-4 AAC
video: H.264
Properties:
Duration: 0:11:31.762000000
Seekable: yes
Tags:
duration: 691762000000
encoder: PFree FLV Lib
video codec: H.264
audio codec: MPEG-4 AAC
2. playbin2
gst-launch-0.10 -v playbin2 uri=file:///home/gst/debug/1.flv
Setting pipeline to PAUSED ...
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: ring-buffer-max-size = 0
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: buffer-size = -1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: buffer-duration = -1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: use-buffering = FALSE
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: download = FALSE
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: uri = "file:///home/gst/debug/1.flv"
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: connection-speed = 0
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0: source = (GstFileSrc) source
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstTypeFindElement:typefind.GstPad:src: caps = video/x-flv
Pipeline is PREROLLING ...
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFlvDemux:flvdemux0.GstPad:sink: caps = video/x-flv
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFlvDemux:flvdemux0.GstPad:video: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)33, height=(int)10, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-buffers = 5
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-time = 0
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-bytes = 2097152
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFlvDemux:flvdemux0.GstPad:audio: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0.GstPad:sink0: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)33, height=(int)10, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0.GstPad:sink1: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0.GstPad:sink1: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0.GstPad:src1: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstH264Parse:h264parse0.GstPad:src: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)512, height=(int)288, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80, parsed=(boolean)true, alignment=(string)au
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstH264Parse:h264parse0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)33, height=(int)10, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstAacParse:aacparse0.GstPad:src: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstAacParse:aacparse0.GstPad:sink: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFaad:faad0.GstPad:sink: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstFaad:faad0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)512, height=(int)288, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80, parsed=(boolean)true, alignment=(string)au
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)512, height=(int)288, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80, parsed=(boolean)true, alignment=(string)au
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-buffers = 5
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-time = 0
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/GstMultiQueue:multiqueue0: max-size-bytes = 2097152
/GstPlayBin2:playbin20/GstInputSelector:inputselector0.GstSelectorPad:sink0: always-ok = FALSE
/GstPlayBin2:playbin20/GstInputSelector:inputselector1.GstSelectorPad:sink0: always-ok = FALSE
/GstPlayBin2:playbin20/GstInputSelector:inputselector1: active-pad = (GstSelectorPad) sink0
/GstPlayBin2:playbin20/GstInputSelector:inputselector0: active-pad = (GstSelectorPad) sink0
/GstPlayBin2:playbin20/GstInputSelector:inputselector0.GstSelectorPad:sink0: tags = ((GstTagList*) 0xb5828cb0)
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: ts-offset = 0
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstAutoVideoSink:videosink/GstXImageSink:videosink-actual-sink-ximage: ts-offset = 0
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/ffdec_h264:ffdec_h2640.GstPad:sink: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)512, height=(int)288, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80, parsed=(boolean)true, alignment=(string)au
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstTee:audiotee: alloc-pad = (GstPad) src0
/GstPlayBin2:playbin20/GstInputSelector:inputselector1.GstSelectorPad:sink0: tags = ((GstTagList*) 0xb4e30e90)
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20.GstDecodePad:src1: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20.GstDecodePad:src1.GstProxyPad:proxypad8: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0.GstGhostPad:src1: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0.GstGhostPad:src1.GstProxyPad:proxypad11: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstInputSelector:inputselector1.GstSelectorPad:sink0: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstInputSelector:inputselector1.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:audio_sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:audio_sink.GstProxyPad:proxypad12: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:audio_sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstTee:audiotee.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstTee:audiotee.GstPad:src0: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstTee:audiotee.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstStreamSynchronizer:streamsynchronizer0.GstPad:sink_1: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstStreamSynchronizer:streamsynchronizer0.GstPad:src_1: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin.GstGhostPad:sink.GstProxyPad:proxypad21: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstQueue:aqueue.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstQueue:aqueue.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv.GstGhostPad:sink.GstProxyPad:proxypad19: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv/GstAudioConvert:conv.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv/GstAudioConvert:conv.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv/GstAudioResample:resample.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv/GstAudioResample:resample.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv.GstGhostPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstPlaySinkAudioConvert:aconv.GstGhostPad:src.GstProxyPad:proxypad20: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink.GstGhostPad:sink.GstProxyPad:proxypad18: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)2
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20/ffdec_h264:ffdec_h2640.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20.GstDecodePad:src0: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0/GstDecodeBin2:decodebin20.GstDecodePad:src0.GstProxyPad:proxypad9: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0.GstGhostPad:src0: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstURIDecodeBin:uridecodebin0.GstGhostPad:src0.GstProxyPad:proxypad10: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstInputSelector:inputselector0.GstSelectorPad:sink0: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstInputSelector:inputselector0.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:video_sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:video_sink.GstProxyPad:proxypad13: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink.GstGhostPad:video_sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstStreamSynchronizer:streamsynchronizer0.GstPad:sink_0: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstStreamSynchronizer:streamsynchronizer0.GstPad:src_0: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin.GstGhostPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin.GstGhostPad:sink.GstProxyPad:proxypad17: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin.GstGhostPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstQueue:vqueue.GstPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstQueue:vqueue.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
Redistribute latency...
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv.GstGhostPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv.GstGhostPad:sink.GstProxyPad:proxypad15: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv.GstGhostPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstFFMpegCsp:conv.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstFFMpegCsp:conv.GstPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstVideoScale:scale.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstVideoScale:scale.GstPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstVideoBalance:videobalance.GstPad:src: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstVideoBalance:videobalance.GstPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstFFMpegCsp:conv2.GstPad:src: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv/GstFFMpegCsp:conv2.GstPad:sink: caps = video/x-raw-yuv, width=(int)512, height=(int)288, framerate=(fraction)15/1, format=(fourcc)I420, interlaced=(boolean)false, pixel-aspect-ratio=(fraction)1/1
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv.GstGhostPad:src: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstPlaySinkVideoConvert:vconv.GstGhostPad:src.GstProxyPad:proxypad16: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstAutoVideoSink:videosink.GstGhostPad:sink: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstAutoVideoSink:videosink.GstGhostPad:sink.GstProxyPad:proxypad14: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstAutoVideoSink:videosink.GstGhostPad:sink: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:vbin/GstAutoVideoSink:videosink/GstXImageSink:videosink-actual-sink-ximage.GstPad:sink: caps = video/x-raw-rgb, bpp=(int)32, depth=(int)24, endianness=(int)4321, red_mask=(int)65280, green_mask=(int)16711680, blue_mask=(int)-16777216, width=(int)512, height=(int)288, framerate=(fraction)15/1, pixel-aspect-ratio=(fraction)1/1, interlaced=(boolean)false
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
/GstPlayBin2:playbin20/GstPlaySink:playsink: volume = 1.000000
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: volume = 1.000000
/GstPlayBin2:playbin20/GstPlaySink:playsink: mute = FALSE
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: mute = FALSE
/GstPlayBin2:playbin20/GstPlaySink:playsink: volume = 1.000000
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: volume = 1.000000
/GstPlayBin2:playbin20/GstPlaySink:playsink: mute = FALSE
/GstPlayBin2:playbin20/GstPlaySink:playsink/GstBin:abin/GstAutoAudioSink:audiosink/GstPulseSink:audiosink-actual-sink-pulse: mute = FALSE
New clock: GstPulseSinkClock
3. filesrc->flvdemux->ffdec_h264
gst-launch-0.10 -v filesrc location=1.flv ! flvdemux ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:video: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)33, height=(int)10, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:audio: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
ERROR: from element /GstPipeline:pipeline0/GstFlvDemux:flvdemux0: Internal data stream error.
Additional debug info:
gstflvdemux.c(2442): gst_flv_demux_loop (): /GstPipeline:pipeline0/GstFlvDemux:flvdemux0:
stream stopped, reason not-linked
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:audio: caps = NULL
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:video: caps = NULL
Freeing pipeline ...
4. filesrc->flvdemux->h264parse->ffdec_h264
gst-launch-0.10 -v filesrc location=1.flv ! flvdemux ! queue ! h264parse ! ffdec_h264 ! ffmpegcolorspace ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:video: caps = video/x-h264, stream-format=(string)avc, pixel-aspect-ratio=(fraction)1/1, width=(int)33, height=(int)10, framerate=(fraction)15/1, codec_data=(buffer)014d401fffe10019674d401f9661404012d80880000003008000000f478c18c54001000468eebc80
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:audio: caps = audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)22050, channels=(int)2, codec_data=(buffer)139056e5a54800
ERROR: from element /GstPipeline:pipeline0/GstFlvDemux:flvdemux0: Internal data stream error.
Additional debug info:
gstflvdemux.c(2442): gst_flv_demux_loop (): /GstPipeline:pipeline0/GstFlvDemux:flvdemux0:
stream stopped, reason not-linked
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:audio: caps = NULL
/GstPipeline:pipeline0/GstFlvDemux:flvdemux0.GstPad:video: caps = NULL
Freeing pipeline ...

Nowadays you should be using gstreamer-1, and with that you can use this pipeline:
gst-launch-1.0 filesrc location=1.flv ! \
flvdemux ! \
h264parse ! avdec_h264 ! videoconvert ! autovideosink
There is still no sound like this. To get video and sound, you need a pipeline like this:
gst-launch-1.0 filesrc location=1.flv ! \
decodebin name=decode ! videoconvert ! autovideosink \
decode. ! audioconvert ! autoaudiosink
OK, that was lazy: I used decodebin. If you know the codecs used, you can construct the full pipeline by hand, of course:
gst-launch-1.0 filesrc location=1.flv ! \
flvdemux name=demux ! queue ! h264parse ! avdec_h264 ! videoconvert ! autovideosink \
demux. ! queue ! aacparse ! avdec_aac ! autoaudiosink

try adding a caps video/x-h264 after your demuxer.

Related

AURenderCallbackStruct in Swift

I have an Objective-C example to an AURenderCallbackStruct, and I would like to do one in swift. I read it's not possible, is that correct?
Thank you.
You can format a callback function in Swift 4 like the following.
func recordingCallback(
inRefCon:UnsafeMutableRawPointer,
ioActionFlags:UnsafeMutablePointer<AudioUnitRenderActionFlags>,
inTimeStamp:UnsafePointer<AudioTimeStamp>,
inBusNumber:UInt32,
inNumberFrames:UInt32,
ioData:UnsafeMutablePointer<AudioBufferList>?) -> OSStatus {
return noErr
}
Note this must be a global function and not inside of a class.
You can then set your callback function with the following code:
var callbackStruct = AURenderCallbackStruct()
callbackStruct.inputProc = recordingCallback
callbackStruct.inputProcRefCon = nil
status = AudioUnitSetProperty(remoteIOUnit!,
kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
bus1,
&callbackStruct,
UInt32(MemoryLayout<AURenderCallbackStruct>.size));
if (status != noErr) {
return status // Do something with the error
}
Source
It's possible. Use the following code for your Audio Unit settings.
init() {
var status: OSStatus
do {
try AVAudioSession.sharedInstance().setPreferredIOBufferDuration(preferredIOBufferDuration)
} catch let error as NSError {
print(error)
}
var desc: AudioComponentDescription = AudioComponentDescription()
desc.componentType = kAudioUnitType_Output
desc.componentSubType = kAudioUnitSubType_VoiceProcessingIO
desc.componentFlags = 0
desc.componentFlagsMask = 0
desc.componentManufacturer = kAudioUnitManufacturer_Apple
let inputComponent: AudioComponent = AudioComponentFindNext(nil, &desc)
status = AudioComponentInstanceNew(inputComponent, &audioUnit)
checkStatus(status)
var flag = UInt32(1)
status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, kInputBus, &flag, UInt32(sizeof(UInt32)))
checkStatus(status)
status = AudioUnitSetProperty(audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, kOutputBus, &flag, UInt32(sizeof(UInt32)))
checkStatus(status)
var audioFormat: AudioStreamBasicDescription! = AudioStreamBasicDescription()
audioFormat.mSampleRate = 8000
audioFormat.mFormatID = kAudioFormatLinearPCM
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked
audioFormat.mFramesPerPacket = 1
audioFormat.mChannelsPerFrame = 1
audioFormat.mBitsPerChannel = 16
audioFormat.mBytesPerPacket = 2
audioFormat.mBytesPerFrame = 2
status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, kInputBus, &audioFormat, UInt32(sizeof(UInt32)))
checkStatus(status)
try! AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayAndRecord)
status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &audioFormat, UInt32(sizeof(UInt32)))
checkStatus(status)
// Set input/recording callback
var inputCallbackStruct = AURenderCallbackStruct(inputProc: recordingCallback, inputProcRefCon: UnsafeMutablePointer(unsafeAddressOf(self)))
AudioUnitSetProperty(audioUnit, AudioUnitPropertyID(kAudioOutputUnitProperty_SetInputCallback), AudioUnitScope(kAudioUnitScope_Global), 1, &inputCallbackStruct, UInt32(sizeof(AURenderCallbackStruct)))
// Set output/renderar/playback callback
var renderCallbackStruct = AURenderCallbackStruct(inputProc: playbackCallback, inputProcRefCon: UnsafeMutablePointer(unsafeAddressOf(self)))
AudioUnitSetProperty(audioUnit, AudioUnitPropertyID(kAudioUnitProperty_SetRenderCallback), AudioUnitScope(kAudioUnitScope_Global), 0, &renderCallbackStruct, UInt32(sizeof(AURenderCallbackStruct)))
flag = 0
status = AudioUnitSetProperty(audioUnit, kAudioUnitProperty_ShouldAllocateBuffer, kAudioUnitScope_Output, kInputBus, &flag, UInt32(sizeof(UInt32)))
}

iOS: Audio Unit RemoteIO not working on iPhone

I'm trying to create my own custom sound effects Audio Unit based on the input from the mic. This application allows simultaneous input/output from the microphone to speaker. I can apply effects and work using the simulator, but when I try to test on the iPhone I can't hear anything. I paste my code if anyone can help me:
- (id) init{
self = [super init];
OSStatus status;
// Describe audio component
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
// Get component
AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);
// Get audio units
status = AudioComponentInstanceNew(inputComponent, &audioUnit);
checkStatus(status);
// Enable IO for recording
UInt32 flag = 1;
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&flag,
sizeof(flag));
checkStatus(status);
// Enable IO for playback
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
kOutputBus,
&flag,
sizeof(flag));
checkStatus(status);
// Describe format
AudioStreamBasicDescription audioFormat;
audioFormat.mSampleRate = 44100.00;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBytesPerFrame = 2;
// Apply format
status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&audioFormat,
sizeof(audioFormat));
checkStatus(status);
status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
kOutputBus,
&audioFormat,
sizeof(audioFormat));
checkStatus(status);
// Set input callback
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = recordingCallback;
callbackStruct.inputProcRefCon = self;
status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
kInputBus,
&callbackStruct,
sizeof(callbackStruct));
checkStatus(status);
// Set output callback
callbackStruct.inputProc = playbackCallback;
callbackStruct.inputProcRefCon = self;
status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Global,
kOutputBus,
&callbackStruct,
sizeof(callbackStruct));
checkStatus(status);
// Allocate our own buffers (1 channel, 16 bits per sample, thus 16 bits per frame, thus 2 bytes per frame).
// Practice learns the buffers used contain 512 frames, if this changes it will be fixed in processAudio.
tempBuffer.mNumberChannels = 1;
tempBuffer.mDataByteSize = 512 * 2;
tempBuffer.mData = malloc( 512 * 2 );
// Initialise
status = AudioUnitInitialize(audioUnit);
checkStatus(status);
return self;
}
This callback is called when new audio data from the microphone is available. But never enter here when I test on the iPhone:
static OSStatus recordingCallback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) {
AudioBuffer buffer;
buffer.mNumberChannels = 1;
buffer.mDataByteSize = inNumberFrames * 2;
buffer.mData = malloc( inNumberFrames * 2 );
// Put buffer in a AudioBufferList
AudioBufferList bufferList;
bufferList.mNumberBuffers = 1;
bufferList.mBuffers[0] = buffer;
// Then:
// Obtain recorded samples
OSStatus status;
status = AudioUnitRender([iosAudio audioUnit],
ioActionFlags,
inTimeStamp,
inBusNumber,
inNumberFrames,
&bufferList);
checkStatus(status);
// Now, we have the samples we just read sitting in buffers in bufferList
// Process the new data
[iosAudio processAudio:&bufferList];
// release the malloc'ed data in the buffer we created earlier
free(bufferList.mBuffers[0].mData);
return noErr;
}
I solved my problem. I simply needed to initialize the AudioSession before playing/recording. I did so with the following code:
OSStatus status;
AudioSessionInitialize(NULL, NULL, NULL, self);
UInt32 sessionCategory = kAudioSessionCategory_PlayAndRecord;
status = AudioSessionSetProperty (kAudioSessionProperty_AudioCategory,
sizeof (sessionCategory),
&sessionCategory);
if (status != kAudioSessionNoError)
{
if (status == kAudioServicesUnsupportedPropertyError) {
NSLog(#"AudioSessionInitialize failed: unsupportedPropertyError");
}else if (status == kAudioServicesBadPropertySizeError) {
NSLog(#"AudioSessionInitialize failed: badPropertySizeError");
}else if (status == kAudioServicesBadSpecifierSizeError) {
NSLog(#"AudioSessionInitialize failed: badSpecifierSizeError");
}else if (status == kAudioServicesSystemSoundUnspecifiedError) {
NSLog(#"AudioSessionInitialize failed: systemSoundUnspecifiedError");
}else if (status == kAudioServicesSystemSoundClientTimedOutError) {
NSLog(#"AudioSessionInitialize failed: systemSoundClientTimedOutError");
}else {
NSLog(#"AudioSessionInitialize failed! %ld", status);
}
}
AudioSessionSetActive(TRUE);
...

aurioTouch2 recording issue. I need to add data from one AudioBufferList to another

I investigate aurioTouch2 sample code. But I wanna record everything in file. aurioTouch doesn't provide this possibility. I tried to record data using this code in FFTBufferManager.cpp in void FFTBufferManager::GrabAudioData(AudioBufferList *inBL)
ExtAudioFileRef cafFile;
AudioStreamBasicDescription cafDesc;
cafDesc.mBitsPerChannel = 16;
cafDesc.mBytesPerFrame = 4;
cafDesc.mBytesPerPacket = 4;
cafDesc.mChannelsPerFrame = 2;
cafDesc.mFormatFlags = 0;
cafDesc.mFormatID = 'ima4';
cafDesc.mFramesPerPacket = 1;
cafDesc.mReserved = 0;
cafDesc.mSampleRate = 44100;
CFStringRef refH;
refH = CFStringCreateWithCString(kCFAllocatorDefault, "/var/mobile/Applications/BD596ECF-A6F2-41EB-B4CE-3A9644B1C26A/Documents/voice2.caff", kCFStringEncodingUTF8);
CFURLRef destinationURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
refH,
kCFURLPOSIXPathStyle,
false);
OSType status = ExtAudioFileCreateWithURL(
destinationURL, // inURL
'caff', // inFileType
&cafDesc, // inStreamDesc
NULL, // inChannelLayout
kAudioFileFlags_EraseFile, // inFlags
&cafFile // outExtAudioFile
); // returns 0xFFFFFFCE
ExtAudioFileWrite(cafFile, mNumberFrames, inBL);
And this works well, but I use AudioBufferList *inBL, and this is only small part of all audio data (about 1 second). This functions is called every 1 second to analize new audion data from microphone. So it would be great, if I can add data from one AudioBufferList to another AudioBufferList.
Or may be anybody know other approach.
You whould set up new AudioUnit to record audio (with its own callback function).
OSStatus status;
// Describe audio component
AudioComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_RemoteIO;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
// Get component
AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc);
// Get audio units
status = AudioComponentInstanceNew(inputComponent, &mAudioUnit);
// Enable IO for recording
UInt32 flag = 1;
status = AudioUnitSetProperty(mAudioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&flag,
sizeof(flag));
// Enable IO for playback
status = AudioUnitSetProperty(mAudioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
kOutputBus,
&flag,
sizeof(flag));
// Describe format
AudioStreamBasicDescription audioFormat={0};
audioFormat.mSampleRate = kSampleRate;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBytesPerFrame = 2;
// Apply format
status = AudioUnitSetProperty(mAudioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&audioFormat,
sizeof(audioFormat));
status = AudioUnitSetProperty(mAudioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
kOutputBus,
&audioFormat,
sizeof(audioFormat));
// Set input callback
AURenderCallbackStruct callbackStruct;
callbackStruct.inputProc = recordingCallback;
callbackStruct.inputProcRefCon = (__bridge void *)self;
status = AudioUnitSetProperty(mAudioUnit,
kAudioOutputUnitProperty_SetInputCallback,
kAudioUnitScope_Global,
kInputBus,
&callbackStruct,
sizeof(callbackStruct));
// Disable buffer allocation for the recorder (optional - do this if we want to pass in our own)
flag = 0;
status = AudioUnitSetProperty(mAudioUnit,
kAudioUnitProperty_ShouldAllocateBuffer,
kAudioUnitScope_Output,
kInputBus,
&flag,
sizeof(flag));
// On initialise le fichier audio
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *destinationFilePath = [[NSString alloc] initWithFormat: #"%#/output.caf", documentsDirectory];
NSLog(#">>> %#\n", destinationFilePath);
CFURLRef destinationURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (__bridge CFStringRef)destinationFilePath, kCFURLPOSIXPathStyle, false);
OSStatus setupErr = ExtAudioFileCreateWithURL(destinationURL, kAudioFileCAFType, &audioFormat, NULL, kAudioFileFlags_EraseFile, &mAudioFileRef);
CFRelease(destinationURL);
NSAssert(setupErr == noErr, #"Couldn't create file for writing");
setupErr = ExtAudioFileSetProperty(mAudioFileRef, kExtAudioFileProperty_ClientDataFormat, sizeof(AudioStreamBasicDescription), &audioFormat);
NSAssert(setupErr == noErr, #"Couldn't create file for format");
setupErr = ExtAudioFileWriteAsync(mAudioFileRef, 0, NULL);
NSAssert(setupErr == noErr, #"Couldn't initialize write buffers for audio file");
CheckError(AudioUnitInitialize(mAudioUnit), "AudioUnitInitialize");
CheckError(AudioOutputUnitStart(mAudioUnit), "AudioOutputUnitStart");

Strange sluggish sound recording from AudioUnit

The following code sounds very sluggish. What's wrong?
AudioStreamBasicDescription audioFormat;
audioFormat.mSampleRate = 22050.0;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBytesPerFrame = 2;
audioFormat.mBytesPerPacket = 2;
audioFormat.mBitsPerChannel = 16;
audioFormat.mReserved = 0;
audioFormat.mFormatFlags = kLinearPCMFormatFlagIsBigEndian |
kLinearPCMFormatFlagIsSignedInteger |
kLinearPCMFormatFlagIsPacked;
//NSString* recordFilePath=[NSTemporaryDirectory() stringByAppendingPathComponent: #"recordedFile.caf"];
NSString* recordFilePath=#"/recordedFile.caf";
NSURL *toURL = [NSURL fileURLWithPath:recordFilePath];
ExtAudioFileCreateWithURL((CFURLRef)toURL,
kAudioFileCAFType,
&audioFormat,
NULL,
kAudioFileFlags_EraseFile,
&extAudioFile);
ExtAudioFileSetProperty(extAudioFile,
kExtAudioFileProperty_ClientDataFormat,
sizeof(AudioStreamBasicDescription),
&audioUnitOutputFormat);
ExtAudioFileSeek(extAudioFile, 0);
[self EnableAudioInputiPhone];
Is the actual recording sample rate 44100, contrary to your specified file format?

Play iphone audio in down "ipod" mic

It only plays in ear mic!
I use Remote IO to playback
OSStatus status; // Describe audio component AudioComponentDescription desc; desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_RemoteIO; desc.componentFlags = 0; desc.componentFlagsMask = 0; desc.componentManufacturer = kAudioUnitManufacturer_Apple; // Get component AudioComponent inputComponent = AudioComponentFindNext(NULL, &desc); // Get audio units status = AudioComponentInstanceNew(inputComponent, &audioUnit); // Enable IO for recording UInt32 flag = 1; status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Input,
kInputBus,
&flag,
sizeof(flag)); // Enable IO for playback status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_EnableIO,
kAudioUnitScope_Output,
kOutputBus,
&flag,
sizeof(flag)); // Describe format audioFormat.mSampleRate = 44100; audioFormat.mFormatID = kAudioFormatLinearPCM; audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagIsPacked; audioFormat.mFramesPerPacket = 1; audioFormat.mChannelsPerFrame = 1; audioFormat.mBitsPerChannel = 16; audioFormat.mBytesPerPacket = 2; audioFormat.mBytesPerFrame = 2;
// Apply format status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Output,
kInputBus,
&audioFormat,
sizeof(audioFormat));
status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input,
kOutputBus,
&audioFormat,
sizeof(audioFormat)); AURenderCallbackStruct callbackStruct; // Set output callback callbackStruct.inputProc = playbackCallback; callbackStruct.inputProcRefCon = self; status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_SetRenderCallback,
//kAudioUnitScope_Global,
kAudioUnitScope_Output,
kOutputBus,
&callbackStruct,
sizeof(callbackStruct)); // Set input callback
callbackStruct.inputProc = recordingCallback; callbackStruct.inputProcRefCon = self; status = AudioUnitSetProperty(audioUnit,
kAudioOutputUnitProperty_SetInputCallback,
//kAudioUnitScope_Global,
kAudioUnitScope_Input,
kInputBus,
&callbackStruct,
sizeof(callbackStruct));
// Disable buffer allocation for the recorder (optional - do this if we want to pass in our own) flag = 0; status = AudioUnitSetProperty(audioUnit,
kAudioUnitProperty_ShouldAllocateBuffer,
kAudioUnitScope_Output,
kInputBus,
&flag,
sizeof(flag)); /* // TODO: Allocate our own buffers if we want
*/ // Initialise status = AudioUnitInitialize(audioUnit); AudioUnitSetParameter(audioUnit, kHALOutputParam_Volume,
kAudioUnitScope_Input, kInputBus,
1, 0);
Before playing audio file, set the AVAudioSession to AVAudioSessionCategoryPlayback
AVAudioSession * audioSession;
[audioSession setCategory:AVAudioSessionCategoryPlayback error: &error];
//Activate the session
[audioSession setActive:YES error: &error];