Skip to content
This repository has been archived by the owner on Jun 10, 2020. It is now read-only.

ffprobe parsing may fail for different metadata formats #12

Open
atruskie opened this issue Jan 16, 2018 · 0 comments
Open

ffprobe parsing may fail for different metadata formats #12

atruskie opened this issue Jan 16, 2018 · 0 comments
Labels

Comments

@atruskie
Copy link
Member

The line here https://github.com/QutBioacoustics/baw-audio-tools/blob/master/lib/baw-audio-tools/audio_ffmpeg.rb#L182 fails to parse output from ffprobe like:

ffprobe -sexagesimal -print_format default -show_error -show_streams -show_format "D:\TEMP\20110412_150000.wav"
ffprobe version 3.4.1 Copyright (c) 2007-2017 the FFmpeg developers
  built with gcc 7.2.0 (GCC)
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda --enable-cuvid --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth --enable-libmfx
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, wav, from 'D:\TEMP\20110412_150000.wav':
  Metadata:
    date            : 2007-01-01
    creation_time   : 00:50:48
    time_reference  : 0
    coding_history  : Format=PCM,Mode=STEREO,Sample frequency=44100Hz,Size of the sample=16bit ZOOM Handy Recorder H2

                    :
  Duration: 00:15:15.03, bitrate: 1411 kb/s
    Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, 2 channels, s16, 1411 kb/s
[STREAM]
index=0
codec_name=pcm_s16le
codec_long_name=PCM signed 16-bit little-endian
profile=unknown
codec_type=audio
codec_time_base=1/44100
codec_tag_string=[1][0][0][0]
codec_tag=0x0001
sample_fmt=s16
sample_rate=44100
channels=2
channel_layout=unknown
bits_per_sample=16
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/44100
start_pts=N/A
start_time=N/A
duration_ts=40353020
duration=0:15:15.034467
bit_rate=1411200
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=D:\TEMP\20110412_150000.wav
nb_streams=1
nb_programs=0
format_name=wav
format_long_name=WAV / WAVE (Waveform Audio)
start_time=N/A
duration=0:15:15.034467
size=161412914
bit_rate=1411207
probe_score=99
TAG:date=2007-01-01
TAG:creation_time=00:50:48
TAG:time_reference=0
TAG:coding_history=Format=PCM,Mode=STEREO,Sample frequency=44100Hz,Size of the sample=16bit ZOOM Handy Recorder H2


[/FORMAT]

Parsing this sort of output results in the following exception:

The error was:

Error: no implicit conversion from nil to integer

Backtrace: /home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_ffmpeg.rb:182:in `[]'
/home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_ffmpeg.rb:182:in `block in parse_ffprobe_output'
/home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_ffmpeg.rb:176:in `each'
/home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_ffmpeg.rb:176:in `parse_ffprobe_output'
/home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_base.rb:121:in `info_ffmpeg'
/home/ubuntu/bioacoustics/workers/baw-workers_production/vendor/bundle/ruby/2.3.0/bundler/gems/baw-audio-tools-d8b0f4e2796c/lib/baw-audio-tools/audio_base.rb:94:in `info'
/home/ubuntu/bioacoustics/workers/baw-workers_production/lib/baw-workers/file_info.rb:21:in `audio_info'
@atruskie atruskie added the bug label Jan 16, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant