2013-11-15 07:28 Gururak imported from Stackoverflow
Hi i built ffmpeg executable on Redhat5. I want to mix two Audio using the command multiple "ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT.mp3".
I enabled libflamemp3 library without any error.
[root@localhost ~]# ffmpeg -i /root/media/Katlalli.mp3 -i /root/media/Katlalli.mp3 -filter_complex amix=inputs=2:duration=first:dropout_transition=2 /root/media/OUTPutnew123.mp3
ffmpeg version 2.1 Copyright (c) 2000-2013 the FFmpeg developers
built on Nov 14 2013 03:17:10 with gcc 4.1.2 (GCC) 20080704 (Red Hat 4.1.2-46)
configuration: --enable-libmp3lame
libavutil 52. 48.100 / 52. 48.100
libavcodec 55. 39.100 / 55. 39.100
libavformat 55. 19.104 / 55. 19.104
libavdevice 55. 5.100 / 55. 5.100
libavfilter 3. 90.100 / 3. 90.100
libswscale 2. 5.101 / 2. 5.101
libswresample 0. 17.104 / 0. 17.104
[mp3 @ 0x193ef240] Estimating duration from bitrate, this may be inaccurate
Input #0, mp3, from '/root/media/Katlalli.mp3':
Metadata:
artist : Yograj Bhat
title : Katlalli Karadige
track : 3
album : Paramathma
album_artist : Puneet Rajkumar
genre : Kannada
composer : V.Harikrishna
date : 2011
Duration: 00:04:41.46, start: 0.000000, bitrate: 191 kb/s
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
Stream #0:1: Video: mjpeg, yuvj420p(pc), 200x200 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
title : thumbnail
comment : Cover (front)
[mp3 @ 0x194090a0] Estimating duration from bitrate, this may be inaccurate
Input #1, mp3, from '/root/media/Katlalli.mp3':
Metadata:
artist : Yograj Bhat
title : Katlalli Karadige
track : 3
album : Paramathma
album_artist : Puneet Rajkumar
genre : Kannada
composer : V.Harikrishna
date : 2011
Duration: 00:04:41.46, start: 0.000000, bitrate: 191 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s
Stream #1:1: Video: mjpeg, yuvj420p(pc), 200x200 [SAR 96:96 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
Metadata:
title : thumbnail
comment : Cover (front)
File '/root/media/OUTPutnew123.mp3' already exists. Overwrite ? [y/N] y
Output #0, mp3, to '/root/media/OUTPutnew123.mp3':
Metadata:
artist : Yograj Bhat
title : Katlalli Karadige
track : 3
album : Paramathma
album_artist : Puneet Rajkumar
genre : Kannada
composer : V.Harikrishna
date : 2011
Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp (default)
Stream #0:1: Video: none, q=2-31, 128 kb/s, 90k tbn
Metadata:
title : thumbnail
comment : Cover (front)
Stream mapping:
Stream #0:0 (mp3) -> amix:input0
Stream #1:0 (mp3) -> amix:input1
amix -> Stream #0:0 (libmp3lame)
Stream #0:1 -> #0:1 (mjpeg -> ?)
Encoder (codec none) not found for output stream #0:1
But when i try to combine two mp3 audio, "ffmpeg -i INPUT1 -i INPUT2 -i INPUT3 -filter_complex amix=inputs=3:duration=first:dropout_transition=3 OUTPUT.mp3".
I am getting error like
"Encoder (codec none) not found for output stream #0:1"
so please help me how to link or install "libmp3flame" on Redhat5.
I believe ffmpeg is trying to decode a PNG input video stream (the album art) and encode the output video stream to PNG output, but I assume you built ffmpeg without zlib support which is required for PNG encoding and decoding.
zlib is automatically detected if available, so you needed to install the zlib headers prior to ffmpeg compilation (zlib-devel
package for Red Hat 'n friends).
Alternatively you can keep your build and tell ffmpeg to ignore any video with the -vn
output option.
mjpeg
If you want to keep your build and also keep the album art then add -codec:v mjpeg
as an output option. See stream selection to see which of the two inputs ffmpeg will choose.
-codec:v copy
You can also stream copy the video with -codec:v copy
. This is probably preferable over re-encoding with -codec:v mjpeg
. See stream selection to see which of the two inputs ffmpeg will choose. If you add -map 0 -map 1
then both video streams will be included.
I filled a buffer with audio data and added it to a frame input node which is routed through an audio graph out to a device output node.
The problem is the audio skips and is at the wrong frequency. I use a key down event to trigger the audio graph to start and never stop the audio graph.
I followed the code at https://docs.microsoft.com/en-us/windows/uwp/audio-video-camera/audio-graphs
It's pretty much exact, so I'm not sure if their code is wrong, I screwed up the channel counting, or just made a simple mistake.
The frequency is proportional to the numbers I use though. 1000hz is clearly lower than 2000hz despite the frequencies not being right.
// For generating frequencies
namespace FG
{
///
/// Provides application-specific behavior to supplement the default Application class.
///
sealed partial class App : Application
{
// For audio nodes through which audio data flows
static AudioGraph audioGraph;
// Pushes audio data that is generated
static AudioFrameInputNode frameInputNode;
// Pitch in hz
static float pitch = 1000;
// For audio out
AudioDeviceOutputNode deviceOutputNode;
// Access to the underlying memory buffer
[ComImport]
[Guid("5B0D3235-4DBA-4D44-865E-8F1D0E4FD04D")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
unsafe interface IMemoryBufferByteAccess
{
void GetBuffer(out byte* buffer, out uint capacity);
}
double theta = 0;
///
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
///
public App()
{
this.InitializeComponent();
// Setup audio graph
InitAudioGraph().Wait();
// For audio playback
CreateDeviceOutputNode().Wait();
// of audio frames
CreateFrameInputNode();
frameInputNode.AddOutgoingConnection(deviceOutputNode);
this.Suspending += OnSuspending;
}
// Initializes AudioGraph
public async Task InitAudioGraph()
{
AudioGraphSettings settings = new AudioGraphSettings(AudioRenderCategory.Media);
/*
settings.EncodingProperties.Bitrate = 1411;
settings.EncodingProperties.BitsPerSample = 24;
settings.EncodingProperties.ChannelCount = 1;
settings.EncodingProperties.SampleRate = 48000;
*/
CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);
audioGraph = result.Graph;
}
// Creates an AudioDeviceOutputNode for sending audio to playback device
private async Task CreateDeviceOutputNode()
{
// Create a device output node
CreateAudioDeviceOutputNodeResult result = await audioGraph.CreateDeviceOutputNodeAsync();
/*
result.DeviceOutputNode.EncodingProperties.Bitrate = 1411;
result.DeviceOutputNode.EncodingProperties.BitsPerSample = 24;
result.DeviceOutputNode.EncodingProperties.ChannelCount = 1;
result.DeviceOutputNode.EncodingProperties.Subtype = "Float";
result.DeviceOutputNode.EncodingProperties.SampleRate = 48000;
*/
deviceOutputNode = result.DeviceOutputNode;
}
// Creates FrameInputNode for taking in audio frames
private void CreateFrameInputNode()
{
// Create the FrameInputNode at the same format as the graph, except explicitly set mono.
AudioEncodingProperties nodeEncodingProperties = audioGraph.EncodingProperties;
frameInputNode = audioGraph.CreateFrameInputNode(nodeEncodingProperties);
// Initialize the Frame Input Node in the stopped state
frameInputNode.Stop();
// Hook up an event handler so we can start generating samples when needed
// This event is triggered when the node is required to provide data
frameInputNode.QuantumStarted += node_QuantumStarted;
}
// For creating audio frames on the fly
private void node_QuantumStarted(AudioFrameInputNode sender, FrameInputNodeQuantumStartedEventArgs args)
{
// GenerateAudioData can provide PCM audio data by directly synthesizing it or reading from a file.
// Need to know how many samples are required. In this case, the node is running at the same rate as the rest of the graph
// For minimum latency, only provide the required amount of samples. Extra samples will introduce additional latency.
uint numSamplesNeeded = (uint)args.RequiredSamples;
if (numSamplesNeeded != 0)
{
AudioFrame audioData = GenerateAudioData(numSamplesNeeded);
frameInputNode.AddFrame(audioData);
}
}
// Generate audioframes for the audiograph
unsafe private AudioFrame GenerateAudioData(uint samples)
{
// Buffer size is (number of samples) * (size of each sample)
// We choose to generate single channel (mono) audio. For multi-channel, multiply by number of channels
uint bufferSize = samples * sizeof(float) * frameInputNode.EncodingProperties.ChannelCount;
AudioFrame frame = new Windows.Media.AudioFrame(bufferSize);
using (AudioBuffer buffer = frame.LockBuffer(AudioBufferAccessMode.Write))
using (IMemoryBufferReference reference = buffer.CreateReference())
{
byte* dataInBytes;
uint capacityInBytes;
float* dataInFloat;
// Get the buffer from the AudioFrame
((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacityInBytes);
// Cast to float since the data we are generating is float
dataInFloat = (float*)dataInBytes;
float amplitude = 0.3f;
int sampleRate = (int)audioGraph.EncodingProperties.SampleRate;
double sampleIncrement = ((pitch*(2*Math.PI))/sampleRate);
// Generate a 1kHz sine wave and populate the values in the memory buffer
int i = 0;
while (i < samples)
{
double sinValue = amplitude * Math.Sin((theta));
for(int j = 0; j < frameInputNode.EncodingProperties.ChannelCount; j++)
{
dataInFloat[i] = (float)sinValue;
i++;
}
theta += sampleIncrement;
}
}
return frame;
}
///
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
///
/// Details about the launch request and process.
protected override void OnLaunched(LaunchActivatedEventArgs e)
{
Frame rootFrame = Window.Current.Content as Frame;
// Do not repeat app initialization when the Window already has content,
// just ensure that the window is active
if (rootFrame == null)
{
// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
rootFrame.NavigationFailed += OnNavigationFailed;
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
{
//TODO: Load state from previously suspended application
}
// Place the frame in the current Window
Window.Current.Content = rootFrame;
}
if (e.PrelaunchActivated == false)
{
if (rootFrame.Content == null)
{
// When the navigation stack isn't restored navigate to the first page,
// configuring the new page by passing required information as a navigation
// parameter
rootFrame.Navigate(typeof(MainPage), e.Arguments);
}
// Ensure the current window is active
Window.Current.Activate();
}
}
///
/// Invoked when Navigation to a certain page fails
///
/// The Frame which failed navigation
/// Details about the navigation failure
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
{
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
}
///
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
///
/// The source of the suspend request.
/// Details about the suspend request.
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity
deferral.Complete();
}
internal static void setPitch(float value)
{
pitch = value;
}
internal static void StartNoise()
{
frameInputNode.Start();
audioGraph.Start();
}
internal static void StopNoise()
{
frameInputNode.Stop();
audioGraph.Stop();
}
}
}
Frequency skips and is too low. I expect the frequency to be constant and the right frequency.
I'm trying to integrate my station into a flutter mobile app but it doesn't play. I've tried all links in listen link tap. Is there any API to access my station through link and get current track info and play and pause the station from it ?
I have a question regarding the following piece of code that I found to measure how much noise is included in a piece of audio:
Sx = fft(x .* hann(length(x), 'periodic')) pk2rms = max(abs(Sx))/sqrt(sum(abs(Sx).^2)/length(Sx))
This code shall calculate the peak-to-rms ratio of a signal and shall be used to measure the noise that is included in an audio signal.
As far as I understand, the max(abs(Sx))
calculates the Peak, and the sqrt(sum(abs(Sx).^2)
calculates the RMS. But I don't get why this is the case. Why do I first have to apply FFT to calculate the Peak? Isn't the peak just the highest amplitude that is included in a signal? If that was true, I should take do max(abs(x))
without converting the signal into frequency-domain? And why do I have to divide the whole thing by the length of the signal?
I can imagine that the answers to my questions could be obvious to some of you experts, but I couldn't find proper answers until now.
Thank you very much in advantage!
C:\Users\Shoubhik Das>ffmpeg -i C:\Users\Shoubhik Das\Desktop\test123.mp4 -ss 00:00:03 -to 00:00:17 -c:v copy -c:a copy C:\Users\Shoubhik Das\Desktop output5.mp4
ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
built with gcc 9.1.1 (GCC) 20190716
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
C:\Users\Shoubhik: No such file or directory
My goal is to receive a video feed from wifi and display it on my screen. For this, I've created a couple of small programs and a bash script to automate them running. It works like this:
UDPBitmap/Plotter & ffplay -i - < UDPBitmap/pipe & python requester.py;
Translation: There is a C++ program called Plotter, its job is to receive packets on an assigned UDP port, process them and write it to pipe (named: UDPBitmap/pipe). The pipe is accessed by ffplay, and ffplay renders the video on screen. The python file is solely responsible for accessing and controlling the camera with various HTTP requests.
The above command works fine, everything works as expected. However, the resulting latency and framerate is a bit lower than what I've wanted. The bottleneck of this program is not the pipe, it is fast enough. Wifi transmission is also fast enough. The only thing left is ffplay.
Question:
What is the most efficient way to render a bitmap to screen, on Linux? Is there a de facto library for this that I can use?
Note:
Ran this command to clip from m3u8 based on start time in seconds and clip duration:
ffmpeg -i master.m3u8 -loglevel info -bsf:a aac_adtstoasc -vcodec copy -a codec copy -ss 240 -t 60 clip.mp4
Output from the command:
//reads initial ts files