Subject: | regex for audio data not working |
Date: | Sun, 27 Nov 2016 04:19:05 +0000 (UTC) |
To: | "bug-Media-Info-Ffmpeg [...] rt.cpan.org" <bug-Media-Info-Ffmpeg [...] rt.cpan.org> |
From: | Scott Givan <sgivan [...] yahoo.com> |
Hi,
I'm using Media::Info::Ffmpeg to probe audio files. I wasn't getting much information about the file -- the return value ($finfo, below) from get_media_info() was:
Dump $finfo
$VAR1 = [
200,
'OK',
{
'duration' => '192.7'
},
{
'func.raw_output' => 'ffmpeg version 3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/us$
/share/man --arch=x86_64 --optflags=\'-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-st$
ong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic\' --extra-ldflags=\'
blah, blah, blah
I traced the problem to the regex parsing the "Stream" line for the Audio track. I changed the regex to make it work for my file:original line 74: if ($stderr =~ /\s*Stream[^:]+: Audio: (.+)/m) {new line 74: if ($stderr =~ /\s*Stream.+: Audio: (.+)/m) {
FYI, this is the relevant line in the ffmpeg output (for the values missing from above):Stream #0:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 262 kb/s (default)
Now I get the output I need:
Dump $finfo
$VAR1 = [
200,
'OK',
{
'audio_bitrate' => 268288,
'audio_format' => 'AAC',
'duration' => '192.7',
'audio_rate' => '44100'
},
{
'func.raw_output' => 'ffmpeg version 3.1.5 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 6.2.1 (GCC) 20160916 (Red Hat 6.2.1-2)
configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr
/share/man --arch=x86_64 --optflags=\'-O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-str
ong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic\' --extra-ldflags=\'
blah, blah, blah Scott Givan
@sgivan