Parsix Posted yesterday at 11:41 PM Posted yesterday at 11:41 PM how to view video stream from "Tee pseudo-muxer" in ffmpeg inside gui form? capture from camera Quote ffmpeg -f dshow -i video="WebCamera":audio="Microphone (WebCamera)" -vcodec libx264 -framerate 30 -s 1280x720 -b:a 320k -ar 48000 -ac 2 -t 10 "E:\0-Dev-Projects\0-TestArea\Camera\ffmpeg\output.mkv" I want to have a live view while recording from the camera. I used WebcamDS (DirectShow webcam) but it doesn't support x265 with synchronized audio in mp4 output format
KaFu Posted 12 hours ago Posted 12 hours ago Google AI give me this: ffmpeg -f dshow -framerate 30 -video_size 1280x720 -i video="WebCamera":audio="Microphone (WebCamera)" -filter_complex "[0:v]split=2[v1][v2]" -map "[v1]" -map 0:a -vcodec libx264 -b:a 320k -ar 48000 -ac 2 -t 10 "E:\0-Dev-Projects\0-TestArea\Camera\ffmpeg\output.mkv" -map "[v2]" -f matroska - | ffplay -i - Parsix 1 OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2025-May-18) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Parsix Posted 12 hours ago Author Posted 12 hours ago (edited) The problem is the display in the autoit form. this worked Quote ffmpeg -f dshow -i video="WebCamera":audio="Microphone (WebCamera)" -vcodec libx264 -framerate 30 -s 1280x720 -b:a 320k -ar 48000 -ac 2 -y "E:\0-Dev-Projects\0-TestArea\Camera\ffmpeg\TEST-1.mkv" -f matroska -c copy - | ffplay -f matroska -x 760 -y 360 - Edited 12 hours ago by Parsix KaFu 1
Solution UEZ Posted 5 hours ago Solution Posted 5 hours ago (edited) Try this: expandcollapse popup;Code by UEZ build 2026-06-26 #include <AutoItConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPIError.au3> Global $iW = 1280, $iH = 720 Global $sFFMPEG = '"...\FFMPEG\bin\ffmpeg.exe"' Global $sMPV = '"...\MPV\mpv.exe"' Global $sOutFile = "C:\Temp\WebCamRec.mkv" Global $aVid, $aAud _GetDShowDevices($sFFMPEG, $aVid, $aAud) If $aVid[0] = 0 Then Exit MsgBox(16, "Error", "No video capture device found") Global $sVideo = $aVid[1] ; first WebCam Global $sAudio = ($aAud[0] > 0) ? $aAud[1] : "" ; first micro, if availabe Global $sInput = '-f dshow -rtbufsize 256M -video_size 1280x720 -framerate 30 -pixel_format nv12 ' & _ '-use_wallclock_as_timestamps 1 -i video="' & $sVideo & '"' If $sAudio <> "" Then $sInput &= ' -f dshow -use_wallclock_as_timestamps 1 -i audio="' & $sAudio & '"' Global $sAudioMap = ($sAudio <> "") ? '-map 1:a -c:a aac -ar 48000 -ac 2 ' : '' Global $bHasAudio = ($sAudio <> "") Global $sInput = '-f dshow -rtbufsize 256M -video_size 1280x720 -framerate 30 -pixel_format nv12 ' & _ '-use_wallclock_as_timestamps 1 -i video="' & $sVideo & '"' If $bHasAudio Then $sInput &= ' -f dshow -use_wallclock_as_timestamps 1 -i audio="' & $sAudio & '"' Global $sAudioMap = $bHasAudio ? ('-map 1:a -c:a aac -ar 48000 -ac 2 ') : '' Global $hGUI = GUICreate("WebCam + Live Preview + Record", $iW, $iH + 40, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPCHILDREN)) Global $idStop = GUICtrlCreateButton("Stop", 10, $iH + 6, 80, 26) Global $hChild = GUICreate("", $iW, $iH, 0, 0, $WS_CHILD, -1, $hGUI) GUISetState(@SW_SHOW, $hChild) GUISwitch($hGUI) GUISetState(@SW_SHOW, $hGUI) Global $wid = Number($hChild) If FileExists($sOutFile) Then FileDelete($sOutFile) Global $sUDP = "udp://127.0.0.1:1234?pkt_size=1316" Global $sCmd = $sFFMPEG & ' ' & $sInput & ' ' & _ '-filter_complex "[0:v]split[rec][tmp];[tmp]fps=30[prev]" ' & _ '-map "[rec]" -c:v libx264 -pix_fmt yuv420p ' & $sAudioMap & '"' & $sOutFile & '" ' & _ '-map "[prev]" -c:v mpeg2video -q:v 5 -an -f mpegts ' & $sUDP Global $iPID = Run($sCmd, "", @SW_HIDE, $STDIN_CHILD) Global $sMpvPipe = "\\.\pipe\mpv_preview" Global $sMpvCmd = $sMPV & ' --wid=' & $wid & ' --no-audio --no-osc --force-window=yes ' & _ '--profile=low-latency --demuxer-lavf-format=mpegts ' & _ '--input-ipc-server=' & $sMpvPipe & ' "' & $sUDP & '"' Global $iPIDmpv = Run($sMpvCmd, "") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $idStop _StopAll($iPID, $iPIDmpv) ExitLoop EndSwitch WEnd GUIDelete($hGUI) Func _GetDShowDevices($sFFMPEG, ByRef $aVideo, ByRef $aAudio) Local $sExe = StringReplace($sFFMPEG, '"', '') Local $iPID = Run('"' & $sExe & '" -hide_banner -list_devices true -f dshow -i dummy', "", @SW_HIDE, $STDERR_CHILD) Local $sOut = "" While 1 $sOut &= StderrRead($iPID) If @error Then ExitLoop WEnd Local $aV[1] = [0], $aA[1] = [0], $sType = "" Local $aLines = StringSplit(StringStripCR($sOut), @LF) For $i = 1 To $aLines[0] Local $sLine = $aLines[$i] If StringInStr($sLine, "(video)") Then $sType = "v" If StringInStr($sLine, "(audio)") Then $sType = "a" If StringInStr($sLine, "Alternative name") Then ContinueLoop Local $aM = StringRegExp($sLine, '"([^"]+)"', 1) If @error Then ContinueLoop If $sType = "v" Then _ArrayAdd_($aV, $aM[0]) ElseIf $sType = "a" Then _ArrayAdd_($aA, $aM[0]) EndIf Next $aVideo = $aV $aAudio = $aA EndFunc Func _ArrayAdd_(ByRef $a, $v) ReDim $a[$a[0] + 2] $a[0] += 1 $a[$a[0]] = $v EndFunc Func _StopAll($iPID, $iPIDmpv) ; ffmpeg If ProcessExists($iPID) Then StdinWrite($iPID, "q") StdinWrite($iPID) ; close stdin ProcessWaitClose($iPID, 5) ; give it up to 5s to flush If ProcessExists($iPID) Then ProcessClose($iPID) ; fallback only EndIf ; mpv: Local $h = FileOpen($sMpvPipe, 2) If $h <> -1 Then FileWrite($h, '{"command":["quit"]}' & @LF) FileClose($h) EndIf ProcessWaitClose($iPIDmpv, 2) If ProcessExists($iPIDmpv) Then ProcessClose($iPIDmpv) EndFunc mpv can be found here: https://sourceforge.net/projects/mpv-player-windows/files/ Adjust the pathes to ffmpeg and mpv! Edited 1 hour ago by UEZ Parsix 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Parsix Posted 2 hours ago Author Posted 2 hours ago Invalid input file index: 1. Failed to set value '1:a' for option 'map': Invalid argument Error parsing options for output file C:\temp\WebCamRec.mkv. Error opening o
UEZ Posted 1 hour ago Posted 1 hour ago 39 minutes ago, Parsix said: Invalid input file index: 1. Failed to set value '1:a' for option 'map': Invalid argument Error parsing options for output file C:\temp\WebCamRec.mkv. Error opening o Made some updates - please try again. Parsix 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Parsix Posted 1 hour ago Author Posted 1 hour ago this error : [in#0 @ 000001ff3283f740] Could not set video options [in#0 @ 000001ff32845780] Error opening input: I/O error Error opening input file video=WebCamera. Error opening input files: I/O error i modify to this and not have error (ffmpeg) Global $sAudioMap = ($sAudio <> "") ? '-map 0:a -c:a aac -ar 48000 -ac 2 ' : '' $sInput = '-f dshow -i video="Camera":audio="Microphone (Camera)" -rtbufsize 256M -video_size 1280x720 -framerate 30 -pixel_format nv12 -use_wallclock_as_timestamps 1' Global $sCmd = $sFFMPEG & ' ' & $sInput & ' ' & _ '-filter_complex "[0:v]split[rec][tmp];[tmp]fps=30[prev]" ' & _ '-map "[rec]" -c:v libx264 -pix_fmt yuv420p ' & $sAudioMap & '"' & $sOutFile & '" ' & _ '-map "[prev]" -c:v mpeg2video -q:v 5 -an -f mpegts ' & $sUDP but mpv.exe not work
Parsix Posted 47 minutes ago Author Posted 47 minutes ago (edited) Sorry, access was blocked by the firewall. The playback was successful, but the playback speed is very slow and there is a lot of delay. Thank you Dear UEZ, all the best to you always. Edited 35 minutes ago by Parsix
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now