LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-21-2023, 06:02 PM   #1
Jason_25
Member
 
Registered: Nov 2001
Posts: 183

Rep: Reputation: 23
Capture audio and video from HDMI device with the same program using ALSA?


I would like to capture audio and video from an HDMI capture device with the same program while using the ALSA audio system.

I have tried this in the past with VLC but it was not possible due to an ALSA bug. So I had to run two instances of VLC, one for audio and one for video.

I had this working with MPV up until a few days ago. Now there is no option to allow audio to sync with video with the existing capture card. No matter the command line options or settings it is always delayed. It has worked for years before this. Rebooting to fix is not an option. So I have purchased a new HDMI capture device. The new device only captures YUY2 at 5 fps so I changed to MJPEG and capture at 30 fps. Unfortunately, MPV now no longer can add the audio with --audio-file at start and cannot add audio through the IPC interface after it is running. It either cannot find the ALSA device or thinks I am giving it a video device. Without the video option for MJPEG audio works fine but video is at 5 fps. Posting on the Github issue tracker for MPV is unavailable to me because I have not compiled the latest version and I will not be able to continue using Github at all from the end of next month so I need to get used to having zero support from now on from all open source projects.

This does not have working audio:
Code:
mpv --demuxer-lavf-format=video4linux2 --demuxer-lavf-o-set=input_format=mjpeg av://v4l2:/dev/video0 --audio-file=av://alsa:plughw:2,0
This has working audio at 5 fps:
Code:
mpv av://v4l2:/dev/video0 --audio-file=av://alsa:plughw:2,0
I understand mplayer cannot capture from 2 separate devices at all. It is also not practical to move away from ALSA because of how complex the arrangement of audio devices is on this media system and because it will introduce all new problems. Everything with audio is working well except this problem.

Is there alternative software that will function? Or am I faced with tearing it all down and dealing with Pipewire or Pulseaudio? Or replacing the capture device with one that will do YUY2 at 30 fps like the old one? Or am I missing something with the mpv commands?
 
Old 08-22-2023, 09:31 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,552

Rep: Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610
I think it's difficult to find an off-the shelf answer to this, I would examine the options
  1. Capture video and save to video file.
  2. Capture audio as an audio file.
  3. Open a video editor, and lay the sound over the video.
Once you synchronise the start correctly, they should synch fairly well. If not, correct it.

For a once off, this should be fine. If you're planning this on an industrial scale, I admit there will be issues stemming from the fact that there is more work (=time) in processing video than audio.
 
Old 08-22-2023, 05:25 PM   #3
Jason_25
Member
 
Registered: Nov 2001
Posts: 183

Original Poster
Rep: Reputation: 23
I think I have it figured out. The Fire Stick itself needed to be rebooted. Whatever audio system Android uses was the culprit here. I can vaguely remember this happening now in the past and it threw me off then too. I see that the Fire stick apparently also has a lip sync tool in the settings but I have never had to use that.

This makes sense now because I could not understand how a capture device could have as much as 5 seconds delayed audio when it is supposed to dutifully transmit audio along with the video. If the capture device was buffering audio then it also should be buffering video. Both devices were doing the same thing so could not be broken. Also when hardware fails it does not lose a feature it simply stops working altogether. I also had made no software changes at all.

I went through a huge amount of command line combinations testing this. Always fun when your bash history gets filled up twice or so. I have learned a lot and may be able to still use the second capture device somewhere. The lip sync has never been perfect so I may be able to improve on that now in some way.
 
Old 08-23-2023, 04:21 AM   #4
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,552

Rep: Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610
So Your problem is solved by rebooting something not mentioned in Post #1?

Never mind, mark it solved and let's move on.
 
Old 08-23-2023, 09:36 AM   #5
Jason_25
Member
 
Registered: Nov 2001
Posts: 183

Original Poster
Rep: Reputation: 23
The Fire Stick is connected to the HDMI capture device. Usually you do not suspect a commercial device of having audio delay/lip sync problems. That would be like a DVD player with delayed audio. I have never seen something like that. Yet the problem is so bad that on at least some versions of the Fire Stick there is a lip sync adjustment option. My Fire Stick has no such option. Unfortunately it looks like I will need to reboot the Fire Stick each time I want to watch something now. I could also try resetting the Fire Stick, replacing it with the same one, or trying the newer 4k version as I think that version has the lip sync adjustments built in but I am not sure it will work with a capture device.
 
Old 08-24-2023, 03:57 AM   #6
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 17,552

Rep: Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610Reputation: 2610
It sounds to me that this isn't a linux/PC problem, this is a (proprietary?) Firestick problem. Nothing to do, so I'll move on.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Virtual video capture device doesn't show up in Skype or flash capture websites hmbx Linux - Newbie 0 08-10-2015 01:44 AM
LXer: Soul Capture 2.0.0 has now been released audio/video capture LXer Syndicated Linux News 0 04-01-2013 12:01 PM
[ProLiant MicroServer, ATI R6xx HDMI, Digital Out, HDMI] No HDMI sound at all vnatius Linux - Hardware 15 08-16-2012 01:09 PM
HDMI Audio doesn't work - Debian Squeeze (Intel HDMI) felipefv Linux - Hardware 8 02-06-2012 09:47 AM
Wanted capture device for VCR device with Audio and Video outs only k_graham Linux - Newbie 2 06-18-2009 11:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 11:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration