Encoding a audio file using ffenc
I am trying to encode an audio file using gstreamer. I am using the command
gst launch filesrc location=s.pcm ! audio/x-raw-int, rate=4000, channels=2, endianness=1234, width=16, depth=16, signed=true ! ffenc_aac ! filesink location=file.wav
And i am getting an error message:-
Setting pipeline to PAUSED ... Pipeline is PREROLLING ... ERROR: from element /GstPipeline:pipeline0/GstFileSrc:filesrc0: Internal data flow error. Additional debug info: gstbasesrc.c(2625): gst_base_src_loop (): /GstPipeline:pipeline0/GstFileSrc:filesrc0: streaming task paused, reason not-negotiated (-4) ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ...
can any one guide me to overcome this issue
Don't confuse encoding with containers. You cannot have an AAC encoded WAV, WAV's are PCM. You can have a 4k WAV or you can have an AAC encoded file in an MP4 or M4A container. Both examples are below. Note that in these examples the AAC encoders get very picky if you try to change the sample rate below 48000.
Create raw audio file
gst-launch audiotestsrc num-buffers=100
! audio/x-raw-int, rate=48000, channels=2, endianness=1234, width=16, depth=16, signed=true
! filesink location=foo.pcm
Encode it as a WAV
gst-launch filesrc location=foo.pcm
! audio/x-raw-int, rate=48000, channels=2, endianness=1234, width=16, depth=16, signed=true
! audioresample
! audio/x-raw-int, rate=4000
! wavenc
! filesink location=foo.wav
Encode it as AAC and mux into mp4
dont really know why I had to encode then decode again, but nothing else worked, even though I could go directly from the audiotest src.
gst-launch filesrc location=foo.pcm
! audio/x-raw-int, rate=48000, channels=2, endianness=1234, width=16, depth=16, signed=true
! wavenc
! wavparse
! ffenc_aac
! mp4mux
! filesink location=foo.mp4
..alternately using faac
the pipeline was a lot cleaner and the output file was smaller
gst-launch filesrc location=foo.pcm
! audio/x-raw-int, rate=48000, channels=2, endianness=1234, width=16, depth=16, signed=true
! faac
! mp4mux
! filesink location=foo.mp4
or voaacenc
voaacenc wouldn't work below 48000 even though it looks to have the most flexible capabilities. I tried 8k,16k,48k,96k and 44100 which anecdotally changed the pitch of the test tone.
gst-launch filesrc location=foo.pcm
! audio/x-raw-int, rate=48000, channels=2, endianness=1234, width=16, depth=16, signed=true
! voaacenc
! mp4mux
! filesink location=foo.mp4
Low bit rate AAC
The lowest AAC bitrates I was successful with was 16000, here are those tests, again noting that faac produced the smallest file size.
gst-launch audiotestsrc num-buffers=100
! audio/x-raw-int, rate=16000, channels=2, endianness=1234, width=16, depth=16, signed=true
! ffenc_aac
! mp4mux
! filesink location=foo.mp4
gst-launch audiotestsrc num-buffers=100
! audio/x-raw-int, rate=16000, channels=2, endianness=1234, width=16, depth=16, signed=true
! faac
! mp4mux
! filesink location=foo.mp4
链接地址: http://www.djcxy.com/p/43930.html
上一篇: GStreamer opusdec:尝试解码Opus比特流失败
下一篇: 使用ffenc编码音频文件