04-07-2015 03:29 PM
I am trying to make my code play a sound when a button is pressed.
At the moment I am using the play sound file block, but this block only accepts files in a .WAV format.
I am creating this program for someone who is not great with computers. Their easiest way to record sounds to be played saves them in an MP4 format.
Having to make them convert the files to .WAV would be very difficult and frustraiting for them.
What I am asking is if there is a way to play a MP4 file in labview, or a way to programatically convert a MP4 file into a .WAV file for the play sound file block.
Thanks for your time.
04-07-2015 10:11 PM
When you say "MP4", do you mean "MP4", which is an MPEG-4 Video format, or "MP3", which is an MPEG-2 Level III audio format? I don't think LabVIEW has a native MP3 reader (perhaps because it is proprietary) -- there is probably software out there to convert MP3 to WAV, which LabVIEW can read.
Bob Schor
04-08-2015 07:02 AM
You can try the .net function Play Sound, it should handle all the system can handle.
/Y
04-08-2015 03:26 PM
When I record a sound with the program it says it is in an MP4 format. I do not actually know much about what MP4 actually means and how it is different than MP3.
Whatever it is I need the recorded sound to play from it. The program does have an option to convert the sound file to MP3, which I assume means the audio MP3 you mentioned.
From what I have found so far it looks like the only way to do it is to somehow convert it into a .WAV to run in labview rather than run as a MP3 or MP4.
04-08-2015 05:36 PM
This might work.
04-16-2018 11:10 PM
Do you have an example MP4 file?
In any case, you can use ffmpeg to extract the audio component of the file, automatically convert it to WAV, and then playback the WAV using the LabVIEW sound VIs. The attached (quick and dirty) VI can read an MP4, then play it back with a button press. Just make sure ffmpeg.exe is in the same directory as the VI. The key part is the conversion to WAV using ffmpeg, with the command:
ffmpeg.exe -i input_file.mp4 -acodec pcm_s16le -ar 44100 output_file.wav
This will read the input MP4 file, set the output audio codec to a signed, 16-bit, little endian PCM wave with a 44100Hz sample rate, then write to an output wave file.