Convert PCM file decoded with opus_demo to WAV - virtualbox

I downloaded the Opus codec from their git repo, ran ./autogen.sh, ./configure, make, and then encoded a sample file from the opus examples page with ./opus_demo -e voip 48000 1 8000 -cbr -bandwidth NB -complexity 0 -forcemono speech_orig.wav speech_encoded.bit.
I then tried to decode it with ./opus_demo -d 48000 1 speech_encoded.bit speech_48khz.wav. When I try to play it back with VLC, it doesn't play it (it shows as playing for less than a second with no sound/feedback).
I am running Ubuntu 14.04 32-bit on a virtual machine (VirtualBox). The only link I found that was even remotely related to my problem is this, which relates to something else than the opus_demo file.
This is the output from opus_demo shell commands:
$ ./opus_demo -e voip 48000 1 8000 -cbr -bandwidth NB -complexity 0 -forcemono speech_orig.wav speech_encoded.bit
libopus 1.1.1-beta-38-gfc0276f
Encoding 48000 Hz input at 8.000 kb/s in narrowband with 960-sample frames.
average bitrate: 8.000 kb/s
maximum bitrate: 8.000 kb/s
active bitrate: 8.000 kb/s
bitrate standard deviation: 0.000 kb/s
$ ./opus_demo -d 48000 1 speech_encoded.bit speech_48khz.wav
libopus 1.1.1-beta-38-gfc0276f
Decoding with 48000 Hz output (1 channels)
average bitrate: 8.000 kb/s
maximum bitrate: 8.000 kb/s
bitrate standard deviation: 0.000 kb/s
Thanks in advance for any help!

Solved it! Posting what I did for future readers, in case someone has the same problem.
The problem was that the files I was passing into the encoder (opus_demo -e) were .wav files. The encoder strictly requires .pcm files, and the decoder strictly outputs .pcm files. In order to convert .wav files to .pcm files, I downloaded ffmpeg for windows, and ran the following commands:
To convert a .wav file into a .pcm file:
ffmpeg -i input.wav -f s16le -acodec output.pcm
To convert a .pcm file into a .wav file:
ffmpeg -f s16le -ar 48k -ac 1 -i input.pcm output.wav

Related

MP4 file created using gstreamer doesn't be played on Window Media Player

I created mp4 file using gstreamer.
gst-launch-1.0 videotestsrc num-buffers=10 ! "video/x-raw, format=(string)NV12, width=(int)1280, height=(int)720, framerate=(fraction)30/1" ! videoconvert ! avenc_mpeg4 ! avmux_mp4 ! filesink location=/tmp/test.mp4
And i can play it using Mplayer , VLC etc.
But i can't play it on Windows Media Player.
I checked MP4 box. but it seems like it doesn't have problem.
How can i try other way?
[Mplayer]
$ mplayer test.mp4
MPlayer 1.3.0 (Debian), built with gcc-7 (C) 2000-2016 MPlayer Team
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing test.mp4.
libavformat version 57.83.100 (external)
libavformat file format detected.
[mov,mp4,m4a,3gp,3g2,mj2 # 0x7fc21b56d2a0]Protocol name not provided, cannot determine if input is local or a network protocol, buffers and access patterns cannot be configured optimally without knowing the protocol
[lavf] stream 0: video (mpeg4), -vid 0
VIDEO: [MP4V] 1280x720 24bpp 29.970 fps 11338.9 kbps (1384.1 kbyte/s)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
libavcodec version 57.107.100 (external)
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Clip info:
major_brand: isom
minor_version: 512
compatible_brands: isomiso2mp41
creation_time: 2020-04-09T11:11:51.000000Z
encoder: Lavf57.71.100
Load subtitles in ./
Audio: no sound
Starting playback...
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [vdpau] 1280x720 => 1280x720 Planar YV12
Movie-Aspect is 1.78:1 - prescaling to correct movie aspect.
VO: [vdpau] 1280x720 => 1280x720 Planar YV12
V: 0.3 0/ 0 ??% ??% ??,?% 0 0
Exiting... (End of file)
See https://support.microsoft.com/en-us/help/316992/file-types-supported-by-windows-media-player
MP4 Video file (.mp4, .m4v, .mp4v, .3g2, .3gp2, .3gp, .3gpp)
[..] Windows Media Player does not support the playback of the .mp4 file format. You can play back .mp4 media files in Windows Media Player when you install DirectShow-compatible MPEG-4 decoder packs [..]

webm to mp3 conversion very slow with avconv

I am using this
passthru("youtube-dl -o '../temp/%(title)s.%(ext)s' --restrict-
filenames --no-part --no-progress --newline --extract-audio --audio-format mp3 -w --audio-quality 0 http://www.youtube.com$vid");
as a part of my code where I download song from youtube-dl, but after downloading it takes 14-15 seconds to convert that to mp3. Is there any way to improve that and make the conversion faster ? Like make avconv use all cores. If so, then how ?
Thank you.
try this:
avconv -i File.webm -threads 2 -acodec libmp3lame -ab 128k -vn -f mp3 file.mp3
You can use 2 or more threads and change bitrate to improve speed of Your script.
Regards

I am using ffmpeg library in my program to record video and audio

I want to record video coming from a camcorder to a wmv file. I am using ffmpeg libraries and I have it saving the video as an "avi" file. However the requirements of the project is to output a wmv file. Can anyone help me discover how to set up the video and audio codecs?
You can configure for video codec as MPEG4 and audio codec as Windows media audio 2 to get the .wmv file format.
ffmpeg -i input.mp4 -b:v 2M -vcodec msmpeg4 -acodec wmav2 output.wmv
When you use ffmpeg to generate WMV format the output video quality may be slightly less than other format. So it is better to set the qscale value to get better quality video.

FFMPEG command for audio file streaming

I am trying to stream an audio file in mp3 format using the FFMPEG library to a remote computer, located on the same LAN as the sender. The command i used to stream at the sender is given below:
ffmpeg -re -f mp3 -i sender.mp3 -ar 8000 -f mulaw -f rtp rtp://10.14.35.23:1234
I got the below command on FFMPEG documentation page that generates audio and streams it to port number 1234 on remote computer
ffmpeg -re -f lavfi -i aevalsrc="sin(400*2*PI*t)" -ar 8000 -f mulaw -f rtp rtp://10.14.35.23:1234
I thought i had made relevant changes to this so that the mp3 streaming command will work, but only to know encounter the error which reads
"Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"
Can anyone tell me what is the wrong parameter here and how to rectify it?
I could figure out the way to stream an audio file using FFMPEG. The command for the same is given below:
ffmpeg -re -f mp3 -i sender.mp3 -acodec libmp3lame -ab 128k -ac 2 -ar 44100 -f rtp rtp://10.14.35.23
Here the audio file 'sender.mp3' is located in the same folder as ffmpeg.exe. In case of a different folder, the full path should be mentioned in the command.

how to use sox to compress mp3?

I'd like to reduce the file size of some mp3 audios with sox. I think I can reduce stereo to only 1 channel (i.e. mono), reduce the sample rate and reduce the bit-depth. I find it seems sox can do none of that. Is this true or did I have done it correctly?
$ sox -r 8000 -c 1 2008-12-28-2.MP3 foo.mp3
sox WARN formats: can't set sample rate 8000; using 44100
sox WARN formats: can't set 1 channels; using 2
The arguments should go before the output file:
sox 2008-12-28-2.MP3 -r 8000 -c 1 foo.mp3
They can also be supplied as effects:
sox 2008-12-28-2.MP3 foo.mp3 remix 1 rate 8000