ffmpeg 0.5 flv to wav conversion creates wav files that other programs won't open
I am using the following command to convert FLV files to audio files to feed into julian, a speech to text program.
cat ./jon2.flv | ffmpeg -i - -vn -acodec pcm_s16le -ar 16000 -ac 1 -f wav - | cat - > jon2.wav
The cat's are there for debugging purposes as the final use will be a running program that will pipe FLV into ffmpeg's stdin and the stdout going to julian.
The resulting wave files are identified by "file" as:
jon3.wav: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, mono 16000 Hz
VLC (based on ffmpeg) plays the file, but no other tools will open/see the data. They show empty wav files or won't open/play. For example Sound Booth from CS4.
Has anyone else had similar problems? Julian requires wav files 16bit mono at 16000 Hz. Julian does seem to read the file, but doesn't seem to go through the ent开发者_运维技巧ire file (may be unrelated).
Thanks,
-rr
Try having ffmpeg directly operate on the input/output files, instead of piping data into and out of ffmpeg:
ffmpeg -i INPUT_FILE.FLV -vn -acodec pcm_s16le -ar 16000 -ac 1 -f wav OUTPUT_FILE.WAV
The problem may be that because you are feeding ffmpeg a stream, and asking it to write a stream, it either does not know the input stream's length, or, more likely, it cannot go back and rewrite the length data in the header of the output file.
The problem is likely that with RIFF, bytes 4 through 7 is where the file length (bytes) is stored which, at the time it is being written, is not yet known. VLC likely ignores the value from the RIFF header allowing it to play there, but not play elsewhere.
The only solution I found was to modify the target to ignore the length from the RIFF header as well.
The structure of the Wave File Header is described here: http://www.sonicspot.com/guide/wavefiles.html
精彩评论