Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg Non monotonous DTS, Previous DTS is always the same, audio microphone streaming [closed]
5 février, par adrien gonzalezI'm using ffmpeg to stream audio from a microphone using rtp. I'm on Raspberry and use an external sound card (HifiBerry DAC + ADC Pro). My goal is to stream audio with the lowest latency possible to others Raspberry reading this audio with ffplay. I try not to compress the audio flux and leave it untouched as wav 48000 Hz. I encounter often some Non Monotonous DTS errors. When this happens I have a latency of hundred of milliseconds adding itself. I tried to add the +igndts flag but it is not changing anything. Also tried +genpts flag.
What is weird is that the previous DTS is always the same (201165 is the example below) and does not seems to change. I looked on forums for answers but I'm unable to find one.
Here is my bash command :
ffmpeg -guess_layout_max 0 -re -f alsa -i hw -acodec pcm_s16le -ac 1 -payload_type 10 -f rtp rtp://192.168.1.152:5003
And the result from the terminal :
ffmpeg version 5.1.6-0+deb12u1+rpt1 Copyright (c) 2000-2024 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr --extra-version=0+deb12u1+rpt1 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 Input #0, alsa, from 'hw': Duration: N/A, start: 1738663653.066577, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s Stream mapping: Stream #0:0 -> #0:0 (pcm_s16le (native) -> pcm_s16le (native)) Press [q] to stop, [?] for help Output #0, rtp, to 'rtp://192.168.1.152:5003': Metadata: encoder : Lavf59.27.100 Stream #0:0: Audio: pcm_s16le, 48000 Hz, mono, s16, 768 kb/s Metadata: encoder : Lavc59.37.100 pcm_s16le SDP: v=0 o=- 0 0 IN IP4 127.0.0.1 s=No Name c=IN IP4 192.168.1.152 t=0 0 a=tool:libavformat LIBAVFORMAT_VERSION m=audio 5003 RTP/AVP 10 b=AS:768 [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201160; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201155; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201149; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201142; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201134; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201124; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201114; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201102; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201089; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201075; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201060; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201044; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201027; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 201009; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 200990; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 200970; changing to 201165. This may result in incorrect timestamps in the output file. [rtp @ 0x558b48ea90] Non-monotonous DTS in output stream 0:0; previous: 201165, current: 200949; changing to 201165. This may result in incorrect timestamps in the output file.
I tried to add the +igndts flag but it is not changing anything. Also tried +genpts flag. I expected the DTS to restore itself but I still have the same issue
-
FFMPEG commands isn't working in Android Q
5 février, par Krupali ShingalaTry this command for merge two audio files, but its not working in Android 10.0(Q) while targeting sdk 29. But, this command is completely working on targeting sdk 24 to 28.
I am using this library of FFMPEG implementation 'nl.bravobit:android-ffmpeg:1.1.7'
"-y", "-i", path1, "-i", path2, "-filter_complex", "[0:0][1:0] amix=inputs=2:duration=longest", "-c:a", "libmp3lame", savedPath my Error log: 2019-09-28 13:48:32.037 16041-16166/com.merger.cut E/FFmpeg: Exception while trying to run: [/data/user/0/com..merger.cut/files/ffmpeg, -y, -i, /storage/emulated/0/Music/song1.mp3, -i, /storage/emulated/0/Music/song2.mp3, -filter_complex, [0:0][1:0] amix=inputs=2:duration=longest, -c:a, libmp3lame, /storage/emulated/0/merger/Merge_1569658695254.mp3] java.io.IOException: Cannot run program "/data/user/0/com.merger.cut/files/ffmpeg": error=13, Permission denied at java.lang.ProcessBuilder.start(ProcessBuilder.java:1050) at nl.bravobit.ffmpeg.ShellCommand.run(ShellCommand.java:15) at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:43) at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:12) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) Caused by: java.io.IOException: error=13, Permission denied at java.lang.UNIXProcess.forkAndExec(Native Method) at java.lang.UNIXProcess.
(UNIXProcess.java:133) at java.lang.ProcessImpl.start(ProcessImpl.java:141) at java.lang.ProcessBuilder.start(ProcessBuilder.java:1029) at nl.bravobit.ffmpeg.ShellCommand.run(ShellCommand.java:15) at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:43) at nl.bravobit.ffmpeg.FFcommandExecuteAsyncTask.doInBackground(FFcommandExecuteAsyncTask.java:12) at android.os.AsyncTask$3.call(AsyncTask.java:378) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) 2019-09-28 13:48:32.146 16041-16041/com.merger.cut E/FFMPEG :: on finish Give me solution for above problem.
-
How to force timecode change ffmpeg convert video to audio
4 février, par little starI'm having problem to force timecode change while converting a video to an audio using ffmpeg.
This is the command I'm trying:
ffmpeg.exe -i source.MP4 -vn -map 0:d -timecode 01:20:10:00 -y target.mov
This is showing the Time code of first frame as the source one, it is not overwriting it. How can I force it to change on one command? So I want to convert video to audio and force timecode change , is that possible?
-
The problem with the AudioDispatcher, the analysis in audioDispatcherFactory is not running, TarsosDSP
4 février, par roman_gor_I'm making an application for sound analysis and spotlight control. The colors of the spotlight change to the beat of the music. I use the TarsosDSP library for this, additionally downloaded the FFmpeg-Kit library to convert audio to WAV format, PCM 16L to work with audioDispatcher. The problem is that when audio is transmitted in the correct format, dispatcher starts and immediately ends. The boolean Process method is not executed, but the process Finished() method is executed. I found out that the stream starts, the file is not empty, it is converted to the correct format, BUT the getFrameLength() method, when interacting with the AudioStream to which I pass the filePath, returns the file path value -1, that is, in fact, it is not filled in. I've already searched through everything, and the github library code, and all the neural networks, I don't know how to solve this issue. The problem is with AudioDispatcher and AudioDispatcherFactory.from Pipe()?
private void playAndAnalyzeAudio(String filePath, Uri uri) { if (mediaPlayer != null) mediaPlayer.release(); mediaPlayer = MediaPlayer.create(requireContext(), uri); new Thread(() -> { extractAudio(inputFilePath, outputFilePath); getActivity().runOnUiThread(() -> { mediaPlayer = MediaPlayer.create(requireContext(), uri); if (mediaPlayer != null) { mediaPlayer.start(); // Start music after analyze startSendingData(); // Start data sending } }); }).start(); } private void analyzeAudio(String filePath) { try { AudioDispatcher audioDispatcher = AudioDispatcherFactory.fromPipe(filePath, 44100, 1024, 0); MFCC mfcc = new MFCC(1024, 44100, 13, 50, 20, 10000); audioDispatcher.addAudioProcessor(mfcc); Log.d("AUDIO_ANALYSIS", "Начинаем анализ аудиофайла..." + audioDispatcher); audioDispatcher.addAudioProcessor(new AudioProcessor() { @Override public boolean process(AudioEvent audioEvent) { Log.d("AUDIO_ANALYSIS", "Обрабатываем аудио..."); float[] amplitudes = audioEvent.getFloatBuffer(); Log.d("AUDIO_ANALYSIS", "Размер буфера: " + amplitudes.length); float[] mfccs = mfcc.getMFCC(); if (mfccs == null) { Log.e("AUDIO_ANALYSIS", "MFCC не сгенерировался!"); return true; } float currentBass = mfccs[0] + mfccs[1]; float totalEnergy = 0; for (float amp : amplitudes) { totalEnergy += Math.abs(amp); } Log.d("AUDIO_ANALYSIS", "Bass Energy: " + currentBass + ", Total Energy: " + totalEnergy); if (currentBass > BASS_THRESHOLD || totalEnergy > ENERGY_THRESHOLD) { changeColor(); Log.d("SONG", "Color wac changed on a : " + currentColor); brightness = MAX_BRIGHTNESS; } else { brightness *= 0.9f; } return true; } @Override public void processingFinished() { getActivity().runOnUiThread(() -> Toast.makeText(requireContext(), "Анализ завершён", Toast.LENGTH_SHORT).show()); } }); File file = new File(filePath); if (!file.exists() || file.length() == 0) { Log.e("AUDIO_ANALYSIS", "Error: file is empty! " + filePath); return; } else { Log.d("AUDIO_ANALYSIS", "File is, size: " + file.length() + " byte."); } Log.d("AUDIO_ANALYSIS", "Start of analyzing: " + filePath); File ffmpegFile = new File(getContext().getCacheDir(), "ffmpeg"); if (!ffmpegFile.setExecutable(true)) { Log.e("AUDIO_ANALYSIS", "You don't have any roots for ffmpeg!"); } else Log.e("AUDIO_ANALYSIS", "You have roots for ffmpeg!"); new Thread(() -> { Log.d("AUDIO_ANALYSIS", "Start dispatcher..."); audioDispatcher.run(); Log.d("AUDIO_ANALYSIS", "Dispatcher end."); }).start(); } catch (Exception e) { e.printStackTrace(); Toast.makeText(requireContext(), "Error of analyzing", Toast.LENGTH_SHORT).show(); } } public void extractAudio(String inputFilePath, String outputFilePath) { File outputFile = new File(outputFilePath); if (outputFile.exists()) { outputFile.delete(); // Удаляем существующий файл } // Строим команду для извлечения аудио String command = "-i " + inputFilePath + " -vn -acodec pcm_s16le -ar 44100 -ac 2 " + outputFilePath; // Используем FFmpegKit для выполнения команды FFmpegKit.executeAsync(command, session -> { if (session.getReturnCode().isSuccess()) { Log.d("AUDIO_EXTRACT", "Аудио извлечено успешно: " + outputFilePath); analyzeAudio(outputFilePath); // Продолжаем анализировать аудио } else { Log.e("AUDIO_EXTRACT", "Ошибка извлечения аудио: " + session.getFailStackTrace()); } }); }
Sorry about the number of lines, i tried to describe the problem very detailed. I tried to change AudioDispatcherFactory.fromPipe() on a AudioDispatcherFactory.fromFile(), but this method don't available in Android, only in Java, how i see the error "Javax.sound..., unexpected error, method don't available" I tried to change String command in executeAudio() method, to change arguments of fromPipe() method, but in did not to bring success. I want that my audio file will be correct analyze with audiodispatcher and then, that data from analyze will be transfered to arduino. Now in Logs I see "Color: null, value: 0.0.
-
Which StackExchange should be a configuration/compilation question ? [migrated]
4 février, par LerennI asked a question yesterday on a configuration/compilation error regarding FFMPEG with NVCC that threw up some C++ errors.
Being a source code error, I thought that the StackOverflow part was appropriate but apparently not. Could you help me find on which StackExchange I should post my question ?
Here is my old post: Configuration error when configuring the FFMPEG compilation with NVCC/CUDA
Thank you !!