tensorflow/io

Audio files fail to read after *any* ffmpeg command

MATTYGILO opened this issue · 0 comments

I get this error:
2023-03-19 20:17:07.037266: W tensorflow/core/framework/op_kernel.cc:1780] OP_REQUIRES failed at audio_video_mp3_kernels.cc:238 : INVALID_ARGUMENT: read 229026 from 0 failed: 0
InvalidArgumentError: {{function_node _wrapped__IteratorGetNext_output_types_2_device/job:localhost/replica:0/task:0/device:CPU:0}} read 439006 from 0 failed: 0
[[{{node IO>AudioDecodeMP3}}]] [Op:IteratorGetNext]

when running these:

import tensorflow as tf
import tensorflow_io as tfio

path = "127562-0002.mp3"

audio = tf.io.read_file(path)
audio = tfio.audio.decode_mp3(audio)

Use this file as an example:
127562-0002.zip

It fails for the whole dataset

Note:
The original dataset had audio files of varying length.The original files work fine for reading. However, I split into 5 second clips using this ffmpeg command:

ffmpeg -i input_file.mp3 -ac 1 -ar 44100 -f segment -segment_time 5 -c:a libmp3lame -q:a 2 output_%03d.mp3

In fact I have tried many different ffmpeg commands and whenever they are processed from ffmeg they fail to read in tfio. Here is my ffprobe if it helps:

ffprobe version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2007-2021 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
  configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 70.100 / 56. 70.100
  libavcodec     58.134.100 / 58.134.100
  libavformat    58. 76.100 / 58. 76.100
  libavdevice    58. 13.100 / 58. 13.100
  libavfilter     7.110.100 /  7.110.100
  libswscale      5.  9.100 /  5.  9.100
  libswresample   3.  9.100 /  3.  9.100
  libpostproc    55.  9.100 / 55.  9.100
Input #0, mp3, from 127562-0002.mp3':
  Metadata:
    title           :  Audio recording
    genre           : Background
    artist          : Bob Smith
    album           : Background sounds
    TIT1            : rjweat
    comment         :  Nothing to say
    copyright       : Bob Smith
    encoder         : Lavf58.29.100
  Duration: 00:00:04.99, start: 0.011021, bitrate: 88 kb/s
  Stream #0:0: Audio: mp3, 48000 Hz, mono, fltp, 88 kb/s

As you can see the file is a valid mp3 file. So why is tensorflow failing to read it?