Reputation: 1804
I am new to FFMPEG and I am suppose to scan all of my files for sample rate. I am not sure as to what this is because I am new to this and don't know how to even get started with FFMPEG's scanning. These live streams are mp3 streams, music tracks. I am familiar with PHP if that makes any difference.
Upvotes: 1
Views: 740
Reputation: 1899
Try this code
$var = shell_exec("mpg321 -t my_file.mp3 2>&1 | grep Hz | awk '{print $7}'
Upvotes: 0
Reputation: 163478
When you call FFMPEG with an input file, it will show you all of the data related to each stream:
ffmpeg -i yourfile.mp3
There is a separate executable typically bundled with FFMPEG though that does what you need, and that is ffprobe
. So on a Windows system, you would do something like this to redirect its standard output to a file:
ffprobe -i yourfile.mp3 -show_streams > file_stream_info.txt
In that file, you'll find something like this:
[STREAM]
index=0
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
codec_type=audio
codec_time_base=0/1
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=s16
sample_rate=44100
channels=2
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=1225/32
time_base=1/14112000
start_time=0.000
duration=210.688
nb_frames=N/A
[/STREAM]
All you have to do then is use whatever scripting language you're using (PHP?) to split this up into key/value pairs (read lines and run explode()
on them). I should also note that in most languages, there is a method to read standard output from something you're executing without writing a file, which will be far more efficient.
Upvotes: 2