Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
'ffmpeg' is not recognized as an internal or external command, operable program or batch file [closed]
15 mai, par Mark S.I am trying to convert group of images
.png
to video.webm
on Windows 10:ffmpeg -i %03d.png output.webm
But I am getting this error:
'ffmpeg' is not recognized as an internal or external command, operable program or batch file.
-
Flutter : How to use "ffmpeg_kit_flutter" to merge videos ?
15 mai, par Hani Kanakrii am using "ffmpeg_kit_flutter" to merge two videos with code
import 'dart:io'; import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart'; import 'package:ffmpeg_kit_flutter/abstract_session.dart'; import 'package:ffmpeg_kit_flutter/return_code.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:wechat_assets_picker/wechat_assets_picker.dart'; import '/features/merge_videos/cubit/merge_videos_state.dart'; class MergeVideosCubit extends Cubit
{ MergeVideosCubit(this.originalFile) : super(InitialMergeVideos()); final File? originalFile; Future selectVideo(BuildContext context) async { final List ? videos = await AssetPicker.pickAssets( context, pickerConfig: const AssetPickerConfig(requestType: RequestType.video), ); if (videos != null && videos.isNotEmpty) { for (AssetEntity asset in videos) { File? videoFile = await asset.file; if (videoFile != null) { print('Selected Asset Path: ${videoFile.path}'); mergeVideos(originalFile!.path, videoFile.path); } } } } Future mergeVideos(String inputPath1, String inputPath2) async { final String outputPath = "/storage/emulated/0/merged_video_${now()}.mp4"; // final String command = // '-i $inputPath1 -i $inputPath2 -filter_complex "[0:v][0:a][1:v][1:a] concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -y $outputPath'; final String command = '-i $inputPath1 -i $inputPath2 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[outv]" -map "[outv]" -y $outputPath'; print("FFmpeg process starting with command: $command"); print(command); print("LOADING LOADING LOADING LOADING LOADING LOADING LOADING MERGE"); emit(LoadMergeVideos()); await FFmpegKit.execute(command).then((value) async { await value.getDuration(); var id = await value.getSessionId(); print(value); print(id); print(await value.getDuration()); }); await FFmpegKit.executeAsync(command, (session) async { final returnCode = await session.getReturnCode(); await session.getSessionId(); print(await session.getSessionId()); if (ReturnCode.isSuccess(returnCode)) { print("SUCCESS: Video merged successfully at $outputPath"); print("SUCCESS SUCCESS SUCCESS SUCCESS SUCCESS SUCCESS MERGE"); emit(SuccessMergeVideos()); } else if (ReturnCode.isCancel(returnCode)) { print("CANCELLED: Video merging was cancelled."); print("CANCEL CANCEL CANCEL CANCEL CANCEL CANCEL CANCEL MERGE"); emit(CancelMergeVideos()); } else { print("ERROR: Failed to merge videos."); print("ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR MERGE"); emit(ErrorMergeVideos()); final failLog = await session.getFailStackTrace(); print("FFmpeg Failure Log: $failLog"); } }); } String now() { final DateTime now = DateTime.now(); return "${now.year}${now.month}${now.day}_${now.hour}${now.minute}${now.second}"; } } The console when i run the code
D/EGL_emulation(23858): app_time_stats: avg=2379.66ms min=5.87ms max=23160.09ms count=10 I/PhotoManager(23858): uri: content://media/external/file I/PhotoManager(23858): projection: _display_name, _data, _id, title, bucket_id, bucket_display_name, width, height, orientation, date_added, date_modified, mime_type, datetaken, duration, media_type, relative_path I/PhotoManager(23858): selection: _id = ? I/PhotoManager(23858): selectionArgs: 1000000039 I/PhotoManager(23858): sortOrder: null I/PhotoManager(23858): sql: _id = 1000000039 I/PhotoManager(23858): cursor count: 1 I/flutter (23858): Selected Asset Path: /storage/emulated/0/Movies/VID_20240512_115116.mp4 I/flutter (23858): FFmpeg process starting with command: -i /storage/emulated/0/Movies/VID_20240512_115128.mp4 -i /storage/emulated/0/Movies/VID_20240512_115116.mp4 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[outv]" -map "[outv]" -y /storage/emulated/0/merged_video_2024513_122719.mp4 I/flutter (23858): -i /storage/emulated/0/Movies/VID_20240512_115128.mp4 -i /storage/emulated/0/Movies/VID_20240512_115116.mp4 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[outv]" -map "[outv]" -y /storage/emulated/0/merged_video_2024513_122719.mp4 I/flutter (23858): LOADING LOADING LOADING LOADING LOADING LOADING LOADING MERGE I/flutter (23858): Instance of 'FFmpegSession' I/flutter (23858): 1 I/flutter (23858): 246 I/flutter (23858): 2 I/flutter (23858): ERROR: Failed to merge videos. I/flutter (23858): ERROR ERROR ERROR ERROR ERROR ERROR ERROR ERROR MERGE D/EGL_emulation(23858): app_time_stats: avg=87.27ms min=4.92ms max=319.92ms count=13 I/flutter (23858): FFmpeg Failure Log: null
In "mergeVideos" function the "returnCode" it return value "1" when i look in the package code
getState() async { try { return _platform .abstractSessionGetState(this.getSessionId()) .then((state) { switch (state) { case 0: return SessionState.created; case 1: return SessionState.running; case 2: return SessionState.failed; case 3: default: return SessionState.completed; } }); } on PlatformException catch (e, stack) { print("Plugin getState error: ${e.message}"); return Future.error("getState failed.", stack); } }
Which mean its keep running but in my code it does not wait until complete merging
how can i fix that??!
but i think my problem is in command(concat)
-i /storage/emulated/0/Movies/VID_20240512_115128.mp4 -i /storage/emulated/0/Movies/VID_20240512_115116.mp4 -filter_complex "[0:v][1:v]concat=n=2:v=1:a=0[outv]" -map "[outv]" -y /storage/emulated/0/merged_video_2024513_122719.mp4
(This is my command when i run the code)??
-
Is there a way to concatenate mp4 video files in ffmpeg without video resolution switching ? [closed]
15 mai, par Micery999So i tried this command from windows
(echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txt ffmpeg -safe 0 -f concat -i list.txt -c copy output.mp4
while making a batch file
Then i concatenate two video's and as soon as the one video ended. It changes resolution, then the video player started to glitch out pixel's like in vlc.
Even if i typed
ffmpeg -safe 0 -f concat -i list.txt -vf scale=640:360 -c copy output.mp4
Nothing happened.
-
Problems with Python's azure.cognitiveservices.speech when installing together with FFmpeg in a Linux web app
15 mai, par Kakobo kakoboI need some help. I'm building an web app that takes any audio format, converts into a .wav file and then passes it to 'azure.cognitiveservices.speech' for transcription.I'm building the web app via a container Dockerfile as I need to install ffmpeg to be able to convert non ".wav" audio files to ".wav" (as azure speech services only process wav files). For some odd reason, the 'speechsdk' class of 'azure.cognitiveservices.speech' fails to work when I install ffmpeg in the web app. The class works perfectly fine when I install it without ffpmeg or when i build and run the container in my machine.
I have placed debug print statements in the code. I can see the class initiating, for some reason it does not buffer in the same when when running it locally in my machine. The routine simply stops without any reason.
Has anybody experienced a similar issue with azure.cognitiveservices.speech conflicting with ffmpeg?
Here's my Dockerfile:
# Use an official Python runtime as a parent imageFROM python:3.11-slim #Version RunRUN echo "Version Run 1..." Install ffmpeg RUN apt-get update && apt-get install -y ffmpeg && # Ensure ffmpeg is executablechmod a+rx /usr/bin/ffmpeg && # Clean up the apt cache by removing /var/lib/apt/lists saves spaceapt-get clean && rm -rf /var/lib/apt/lists/* //Set the working directory in the container WORKDIR /app //Copy the current directory contents into the container at /app COPY . /app //Install any needed packages specified in requirements.txt RUN pip install --no-cache-dir -r requirements.txt //Make port 80 available to the world outside this container EXPOSE 8000 //Define environment variable ENV NAME World //Run main.py when the container launches CMD ["streamlit", "run", "main.py", "--server.port", "8000", "--server.address", "0.0.0.0"]`and here's my python code:
def transcribe_audio_continuous_old(temp_dir, audio_file, language): speech_key = azure_speech_key service_region = azure_speech_region time.sleep(5) print(f"DEBUG TIME BEFORE speechconfig") ran = generate_random_string(length=5) temp_file = f"transcript_key_{ran}.txt" output_text_file = os.path.join(temp_dir, temp_file) speech_recognition_language = set_language_to_speech_code(language) speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region) speech_config.speech_recognition_language = speech_recognition_language audio_input = speechsdk.AudioConfig(filename=os.path.join(temp_dir, audio_file)) speech_recognizer = speechsdk.SpeechRecognizer(speech_config=speech_config, audio_config=audio_input, language=speech_recognition_language) done = False transcript_contents = "" time.sleep(5) print(f"DEBUG TIME AFTER speechconfig") print(f"DEBUG FIle about to be passed {audio_file}") try: with open(output_text_file, "w", encoding=encoding) as file: def recognized_callback(evt): print("Start continuous recognition callback.") print(f"Recognized: {evt.result.text}") file.write(evt.result.text + "\n") nonlocal transcript_contents transcript_contents += evt.result.text + "\n" def stop_cb(evt): print("Stopping continuous recognition callback.") print(f"Event type: {evt}") speech_recognizer.stop_continuous_recognition() nonlocal done done = True def canceled_cb(evt): print(f"Recognition canceled: {evt.reason}") if evt.reason == speechsdk.CancellationReason.Error: print(f"Cancellation error: {evt.error_details}") nonlocal done done = True speech_recognizer.recognized.connect(recognized_callback) speech_recognizer.session_stopped.connect(stop_cb) speech_recognizer.canceled.connect(canceled_cb) speech_recognizer.start_continuous_recognition() while not done: time.sleep(1) print("DEBUG LOOPING TRANSCRIPT") except Exception as e: print(f"An error occurred: {e}") print("DEBUG DONE TRANSCRIPT") return temp_file, transcript_contents
The transcript this callback works fine locally, or when installed without ffmpeg in the linux web app. Not sure why it conflicts with ffmpeg when installed via container dockerfile. The code section that fails can me found on note #NOTE DEBUG"
-
How to stream webcam video over RTSP using ffmpeg on Windows 10 ? [closed]
15 mai, par let me down slowlyI am trying to stream my laptop's webcam using RTSP protocol using
ffmpeg
. I am trying to simulate an actual IP Camera. I have already tried different tools already including usingVidGear
python package, andgstreamer
but could not get it working. Note: I am on Windows 10. I have tried this command:ffmpeg -f dshow -s 320x240 -rtbufsize 2147.48M -r 30 -vcodec mjpeg -i video="HD Camera" -f rtsp -rtsp_transport tcp rtsp://localhost:8554/mystream
It turns on the webcam with but prints these logs to the console:
ffmpeg version 7.0-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 [mjpeg @ 0000026201ae9fc0] unable to decode APP fields: Invalid data found when processing input Input #0, dshow, from 'video=HD Camera': Duration: N/A, start: 1285415.793302, bitrate: N/A Stream #0:0: Video: mjpeg (Baseline) (MJPG / 0x47504A4D), yuvj422p(pc, bt470bg/unknown/unknown), 320x240, 30 fps, 30 tbr, 10000k tbn Stream mapping: Stream #0:0 -> #0:0 (mjpeg (native) -> mpeg4 (native)) Press [q] to stop, [?] for help [mjpeg @ 0000026201afe9c0] unable to decode APP fields: Invalid data found when processing input [swscaler @ 0000026201b5cc40] deprecated pixel format used, make sure you did set range correctly [swscaler @ 00000262068c57c0] deprecated pixel format used, make sure you did set range correctly [swscaler @ 0000026201b5cc40] deprecated pixel format used, make sure you did set range correctly Last message repeated 1 times [mjpeg @ 0000026201afe9c0] unable to decode APP fields: Invalid data found when processing input Last message repeated 8 times
I tried opening
rtsp://localhost:8554/mystream
but it showsVLC is unable to open the MRL 'rtsp://localhost:8554/mystream'. Check the log for details.
Killing the running process outputs these additional logs
[out#0/rtsp @ 0000026201aeaf80] Could not write header (incorrect codec parameters ?): Immediate exit requested [vf#0:0 @ 0000026201af4100] Error sending frames to consumers: Immediate exit requested [vf#0:0 @ 0000026201af4100] Task finished with error code: -1414092869 (Immediate exit requested) [vf#0:0 @ 0000026201af4100] Terminating thread with return code -1414092869 (Immediate exit requested) [out#0/rtsp @ 0000026201aeaf80] Nothing was written into output file, because at least one of its streams received no packets. frame= 0 fps=0.0 q=0.0 Lsize= 0KiB time=N/A bitrate=N/A speed=N/A Exiting normally, received signal 2.
Output of the command
ffmpeg -list_devices true -f dshow -i dummy
:built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 [dshow @ 00000140f18d4200] "HD Camera" (video) [dshow @ 00000140f18d4200] Alternative name "@device_pnp_\\?\usb#vid_05c8&pid_03ea&mi_00#6&d0a8c55&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global" [dshow @ 00000140f18d4200] "Microphone (Realtek(R) Audio)" (audio) [dshow @ 00000140f18d4200] Alternative name "@device_cm_{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave_{06840D8D-1151-4D9C-B865-2FE01BFB9FD2}" [in#0 @ 00000140f18ba640] Error opening input: Immediate exit requested Error opening input file dummy.
Output of the command
ffmpeg -f dshow -list_options true -i video="HD Camera"
:built with gcc 13.2.0 (Rev5, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 59. 8.100 / 59. 8.100 libavcodec 61. 3.100 / 61. 3.100 libavformat 61. 1.100 / 61. 1.100 libavdevice 61. 1.100 / 61. 1.100 libavfilter 10. 1.100 / 10. 1.100 libswscale 8. 1.100 / 8. 1.100 libswresample 5. 1.100 / 5. 1.100 libpostproc 58. 1.100 / 58. 1.100 [dshow @ 000002670b4c12c0] DirectShow video device options (from video devices) [dshow @ 000002670b4c12c0] Pin "Capture" (alternative pin name "Capture") [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=1280x720 fps=30 max s=1280x720 fps=30 [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=640x480 fps=30 max s=640x480 fps=30 [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=640x360 fps=30 max s=640x360 fps=30 [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=352x288 fps=30 max s=352x288 fps=30 [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=320x240 fps=30 max s=320x240 fps=30 [dshow @ 000002670b4c12c0] vcodec=mjpeg min s=176x144 fps=30 max s=176x144 fps=30 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=1280x720 fps=10 max s=1280x720 fps=10 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=640x480 fps=30 max s=640x480 fps=30 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=640x360 fps=30 max s=640x360 fps=30 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=352x288 fps=30 max s=352x288 fps=30 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=320x240 fps=30 max s=320x240 fps=30 [dshow @ 000002670b4c12c0] pixel_format=yuyv422 min s=176x144 fps=30 max s=176x144 fps=30 [in#0 @ 000002670b4aa200] Error opening input: Immediate exit requested Error opening input file video=HD Camera.
Please help me solve the issue or suggest a better approach.