错误的文件描述符使用ffmpeg解码mp3到管道

时间:2017-01-23 11:25:14

标签: ffmpeg

任何FFMpeg专家都能帮助我解决以下问题吗?

我尝试将播客转换为PCM并将其下采样为16KHz单声道,然后将其转录到语音识别系统进行转录。命令行

ffmpeg -i http://media.blubrry.com/conlangery/content.blubrry.com/conlangery/Conlangery01.mp3 -f s16le -ac 1 -ar 16000 pipe:0

失败

av_interleaved_write_frame():错误的文件描述符

这里有什么问题,如何解决?

修改

完整的错误消息是

ffmpeg version N-83189-gd5d474aea5-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 5.4.1 (Debian 5.4.1-4) 20161202
  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg
  libavutil      55. 44.100 / 55. 44.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 62.100 / 57. 62.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 69.100 /  6. 69.100
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, mp3, from 'http://media.blubrry.com/conlangery/content.blubrry.com/conlangery/Conlangery01.mp3':
  Metadata:
    track           : 1
    album           : Conlangery Podcast
    title           : Conlangery 01
    artist          : George Corley
    date            : 2011
  Duration: 00:44:58.08, start: 0.025057, bitrate: 128 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : LAME3.98r
Output #0, s16le, to 'pipe:0':
  Metadata:
    track           : 1
    album           : Conlangery Podcast
    title           : Conlangery 01
    artist          : George Corley
    date            : 2011
    encoder         : Lavf57.62.100
    Stream #0:0: Audio: pcm_s16le, 16000 Hz, mono, s16, 256 kb/s
    Metadata:
      encoder         : Lavc57.75.100 pcm_s16le
Stream mapping:
  Stream #0:0 -> #0:0 (mp3 (native) -> pcm_s16le (native))
Press [q] to stop, [?] for help
av_interleaved_write_frame(): Bad file descriptor
Error writing trailer of pipe:0: Bad file descriptorsize=       1kB time=00:00:00.02 bitrate= 256.0kbits/s speed=95.2x    
video:0kB audio:1kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%
Conversion failed!
Traceback (most recent call last):
  File "./PodcastTranscriber.py", line 206, in <module>
    PodcastTranscriber('http://conlangery.com/feed/',upload)()        
  File "./PodcastTranscriber.py", line 101, in __call__
    self.process(item)
  File "./PodcastTranscriber.py", line 136, in process
    (audio,errors)=mp3.run(stdout=subprocess.PIPE)
  File "/usr/local/lib/python2.7/site-packages/ffmpy.py", line 105, in run
    raise FFRuntimeError(self.cmd, self.process.returncode, out[0], out[1])
ffmpy.FFRuntimeError: `ffmpeg -i http://media.blubrry.com/conlangery/content.blubrry.com/conlangery/Conlangery01.mp3 -f s16le -ac 1 -ar 16000 pipe:0` exited with status 1

调用代码是

def process(self,item):
    """Downloads the audio and transcribes it"""
    audio_url=None
    print item['title']
    for link in item.links:
        if link['rel']=='enclosure':
            audio_url=link['href']
    if audio_url is not None:
        pubDate=to_date(item.published_parsed)
        if self.lastUploadDate is None or pubDate>self.lastUploadDate:
            self.lastUploadDate=pubDate
        mp3=ffmpy.FFmpeg(inputs={audio_url:None},
                         outputs={'pipe:0':['-f','s16le','-ac','1','-ar','16000']})
        (audio,errors)=mp3.run(stdout=subprocess.PIPE)
        sphinx=subprocess.Popen(['java','-jar','transcriber.jar'],
                                stdin=audio,
                                stdout=subprocess.PIPE)
        wiki=threading.Thread(target=self.callback,args=(item,sphinx.stdout))
        wiki.start()
        #mp3.start()
        #mp3.join()
        sphinx.stdin.close()
        wiki.join()
        sphinx.wait()

0 个答案:

没有答案