Archive

Posts Tagged ‘audio’

Record audio in good quality

April 13, 2017 Leave a comment

Problem
I wanted to create some simple tutorial videos using a screen recording software (with gtk-recordMyDesktop to be precise), but the audio quality was terrible. There was a constant white noise in the background. I could reduce the noise with Audacity but 1) I couldn’t eliminate the noise, 2) it distorted my voice, and 3) the audio became weaker.

Solution
I had a cheap headphone / microphone that was connected with a jack plug. I think there was also some inference that caused the noise. So I bought a USB headset (Logitech H390) and the damn noise is gone! It works very well for me.

I tried it under Manjaro and here is how to make it work. Plug it and start Audacity. Next to the microphone icon there is a dropdown list. Select your headset and try to record some audio.

Try “pavucontrol” too. Under the Recording tab I had to select “Headset H390 Analog Mono”. Talk in the microphone and the sound feedback line should be moving.

How to record audio with gtk-recordMyDesktop? Start “pavucontrol” and “gtk-recordMyDesktop” too. In gtk-recordMyDesktop, go to Advanced -> Sound tab. Next to the device name I had “DEFAULT”. Change it to “pulse” (without quotes). Start recording with gtk-recordMyDesktop. Now switch to pavucontrol and go the Recording tab. At the bottom select “Show: Applications”. Now recordmydesktop should appear. Next to it there is a dropdown menu where select “Headset H390 Analog Mono”. It should do the trick.

Advertisements

media info

December 28, 2014 Leave a comment

Problem
You have a media file (audio, video, image) and you want to get some detailed information about it: duration, bit rate, resolution, etc. How to extract these pieces of information?

Solution
Use the MediaInfo project. You can install it via your package manager and you will get a command called “mediainfo”.

Example:

$ mediainfo movie.avi

Output:

General
Complete name                            : movie.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format profile                           : OpenDML
Format settings                          : rec
File size                                : 1.27 GiB
Duration                                 : 2h 29mn
Overall bit rate                         : 1 218 Kbps
Writing application                      : AVI-Mux GUI 1.17.8.3, Feb 16 201019:42:50

Video
ID                                       : 0
Format                                   : MPEG-4 Visual
Format profile                           : Advanced Simple@L5
Format settings, BVOP                    : 2
Format settings, QPel                    : No
Format settings, GMC                     : No warppoints
Format settings, Matrix                  : Default (H.263)
Muxing mode                              : Packed bitstream
Codec ID                                 : XVID
Codec ID/Hint                            : XviD
Duration                                 : 2h 29mn
Bit rate                                 : 1 086 Kbps
Width                                    : 720 pixels
Height                                   : 304 pixels
Display aspect ratio                     : 2.35:1
Frame rate                               : 23.976 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.207
Stream size                              : 1.13 GiB (89%)
Writing library                          : XviD 64

Audio
ID                                       : 1
Format                                   : MPEG Audio
Format version                           : Version 1
Format profile                           : Layer 3
Mode                                     : Joint stereo
Mode extension                           : MS Stereo
Codec ID                                 : 55
Codec ID/Hint                            : MP3
Duration                                 : 2h 29mn
Bit rate mode                            : Constant
Bit rate                                 : 128 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 136 MiB (11%)
Alignment                                : Aligned on interleaves
Interleave, duration                     : 747 ms (17.92 video frames)
Interleave, preload duration             : 216 ms
Title                                    : mp3
Writing library                          : LAME3.99r
Encoding settings                        : -m j -V 4 -q 2 -lowpass 17 -b 128

Python
There is a simple Python wrapper for it called pymediainfo. Its github page is here.

Categories: bash, python Tags: , , ,

[manjaro] sound is gone

November 8, 2014 Leave a comment

Problem
Sound is gone in Manjaro.

Solution
I could get it back with the graphical program “pavucontrol“. Under the Configuration tab it showed Off. Changing it back to Analog Stereo Duplex the sound came back.

Categories: manjaro Tags: ,

using gtk-recordmydesktop

Here I sum up how I use gtk-recordmydesktop. gtk-recordmydesktop produces huge .ogv files that I like to convert to much smaller .mp4 files (without quality loss).

My gtk-recordmydesktop settings:

  • video quality 100%
  • audio quality 100%
  • in Advanced -> Performance:
    • frames per second: 20
    • full shots at every frame: yes

Convert .ogv to .mp4:

/opt/ffmpeg/ffmpeg -i "input.ogv" -codec:v libx264 -quality good -cpu-used 0 -profile:v baseline -level 30 -y -maxrate 2000k -bufsize 2000k -threads 4 -codec:a copy -b:a 128k "output.mp4"

I record audio with a microphone but it always has some white noise. To get rid of it, extract the audio:

/opt/ffmpeg/ffmpeg -i file.mp4 -f wav output.wav

Open the .wav file with Audacity, remove the noise and save the result in .mp3 format. Finally, replace the audio in the .mp4 file:

/opt/ffmpeg/ffmpeg -i audio.mp3 -i video.mp4 -c copy final_video.mp4
Categories: bash Tags: , , , ,

Replace the audio track in a video

Problem
You have a video with an audio track (call it video.mp4). You have an audio file (e.g. audio.mp3) that you want to put on the video, replacing the original audio of the video file.

Solution
With Audacity, you can open both video.mp4 and audio.mp3 and you can synchronize the mp3 to match the original audio. Important points: speech/music should start at the same time, and its length should be the same or a little bit less than the original audio.

Once you have a good audio.mp3 file, do the replacement with the following command:

ffmpeg -i audio.mp3 -i video.mp4 -c copy final_video.mp4

Solution #2
Before the previous solution, I used Avidemux, but it tends to crash sometimes :) When I have such videos where Avidemux crashes, I use ffmpeg from the command-line.