How to make Safari play local audio resource? - audio

This is macOS / Safari.
I can play this file by opening in Safari: https://learnwithecho.com/assets/test.m4a
But if I save that file locally:
wget https://learnwithecho.com/assets/test.m4a
And spin up a web server:
php -S 0.0.0.0:8888
And load the same file locally:
open http://localhost:8888/test.m4a
Then I get this error:
Failed to load resource: Plug-in handled load
How can I serve this file locally so it properly plays in Safari?
Here is mediainfo for the file:
General
Complete name : assets/test.m4a
Format : MPEG-4
Format profile : Apple audio with iTunes info
Codec ID : M4A (isom/iso2)
File size : 26.3 KiB
Duration : 2 s 24 ms
Overall bit rate mode : Constant
Overall bit rate : 106 kb/s
Writing application : Lavf55.33.100
Audio
ID : 1
Format : AAC LC
Format/Info : Advanced Audio Codec Low Complexity
Codec ID : mp4a-40-2
Duration : 2 s 24 ms
Duration_LastFrame : -20 ms
Bit rate mode : Constant
Bit rate : 102 kb/s
Channel(s) : 1 channel
Channel layout : C
Sampling rate : 44.1 kHz
Frame rate : 43.066 FPS (1024 SPF)
Compression mode : Lossy
Stream size : 25.2 KiB (96%)
Default : Yes
Alternate group : 1

Okay, this is the dumbest thing I found out.
macOS / Safari (at least version 13.0.3) does not support playing media resources on localhost using RELATIVE URLs.
The same media WILL play if you use an ABSOLUTE URL like http://localhost...
This is undocumented Safari behavior.

Related

How do I adjust the video resolution?

I'm trying to adjust the resolution of the incoming H.264 RTSP stream. I am running on Windows 10 for now, but will eventually move this to Linux. I am creating the LibVLC object passing in several command line args, but nothing I have tried affects the resulting screen resolution.
When I open the same RTSP steam in the VLC media player app, the resolution is 2560x1980, which is the native resolution I want in my app. But, when my app runs, it's only 640x480. FYI - this is not a Windows UI app. It's a service that is just taking screenshots. So, there is not media control on a form to adjust.
Here is what I have right now:
Core.Initialize();
LibVLC libVLC = new LibVLC("--no-audio", "--no-spu", "--sout-transcode-venc=x264", "--sout-x264-preset=ultrafast", "--sout-x264-profile=high", "--sout-x264-tune=film", "--video-filter=scene", "--scene-format=jpeg", "--scene-prefix=MyVision", "--scene-path=C:\\temp\\", "--scene-ratio=100", $"--rtsp-user={rtspUser}", $"--rtsp-pwd={rtspPassword}");
player = new MediaPlayer(libVLC);
var media = new Media(libVLC, _rtspEndpoint, FromType.FromLocation);
player.Play(media);
Some of the x264 options are just ones that I tested that I saw in the VLC App. They did not adjust the resolution.
Here is the log file:
VLC media player - 3.0.7.1 Vetinari
Copyright © 1996-2019 the VideoLAN team
revision 3.0.7.1-0-gf3940db4af
configured with ../extras/package/win32/../../../configure '--enable-update-check' '--enable-lua' '--enable-faad' '--enable-flac' '--enable-theora' '--enable-avcodec' '--enable-merge-ffmpeg' '--enable-dca' '--enable-mpc' '--enable-libass' '--enable-schroedinger' '--enable-realrtsp' '--enable-live555' '--enable-dvdread' '--enable-shout' '--enable-goom' '--enable-caca' '--enable-qt' '--enable-skins2' '--enable-sse' '--enable-mmx' '--enable-libcddb' '--enable-zvbi' '--disable-telx' '--enable-nls' '--host=x86_64-w64-mingw32' '--with-breakpad=https://win.crashes.videolan.org' 'host_alias=x86_64-w64-mingw32' 'PKG_CONFIG_LIBDIR=/home/jenkins/workspace/vlc-release/windows/vlc-release-win32-x64/contrib/x86_64-w64-mingw32/lib/pkgconfig'
creating audio output
looking for audio output module matching "any": 6 candidates
using default device
display name changed: VLC media player (LibVLC 3.0.7.1)
version 2 session control unavailable
volume from -65.250000 dB to +0.000000 dB with 0.031250 dB increments
using audio output module "mmdevice"
keeping audio output
Creating an input for 'rtsp://192.168.1.108:554/h264Preview_01_sub'
using timeshift granularity of 50 MiB
using timeshift path: C:\Users\dwjen\AppData\Local\Temp
`rtsp://192.168.1.108:554/h264Preview_01_sub' gives access `rtsp' demux `any' path `192.168.1.108:554/h264Preview_01_sub'
creating demux: access='rtsp' demux='any' location='192.168.1.108:554/h264Preview_01_sub' file='\\192.168.1.108:554\h264Preview_01_sub'
looking for access_demux module matching "rtsp": 15 candidates
version 2016.11.28
RTP subsession 'video/H264'
selecting program id=0
RTP subsession 'audio/MPEG4-GENERIC'
setup start: 0.000000 stop:0.000000
We have a timeout of 60 seconds
play start: 0.000000 stop:0.000000
using access_demux module "live555"
looking for packetizer module matching "any": 25 candidates
found NAL_SPS (sps_id=0)
found NAL_PPS (pps_id=0 sps_id=0)
using packetizer module "h264"
looking for video decoder module matching "any": 19 candidates
using ffmpeg Lavc58.6.103
CPU flags: 0x0007d3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
audio is disabled, not selecting ES 0x1
looking for meta reader module matching "any": 2 candidates
Trying Lua scripts in C:\Users\dwjen\AppData\Roaming\vlc\lua\meta\reader
Trying Lua scripts in C:\Source\BlueMetal\Internal\VideoTest\RtspSnapshots\bin\Debug\netcoreapp2.2\libvlc\win-x64\lua\meta\reader
Trying Lua playlist script C:\Source\BlueMetal\Internal\VideoTest\RtspSnapshots\bin\Debug\netcoreapp2.2\libvlc\win-x64\lua\meta\reader\filename.luac
no meta reader modules matched
`rtsp://192.168.1.108:554/h264Preview_01_sub' successfully opened
Buffering 0%
Buffering 3%
Buffering 7%
restarting module due to input format change
removing module "avcodec"
looking for video decoder module matching "any": 19 candidates
using ffmpeg Lavc58.6.103
CPU flags: 0x0007d3db
allowing 6 thread(s) for decoding
codec (h264) started
using frame thread mode with 6 threads
using video decoder module "avcodec"
available hardware decoder output format 119 (cuda)
available hardware decoder output format 53 (dxva2_vld)
available hardware decoder output format 118 (d3d11va_vld)
available hardware decoder output format 174 (d3d11)
available software decoder output format 0 (yuv420p)
tk->rtpSource->hasBeenSynchronizedUsingRTCP()
trying format d3d11va_vld
looking for text renderer module matching "any": 3 candidates
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for video converter module matching "any": 24 candidates
32x32 (32x32) chroma: YUVA -> 16x16 (16x16) chroma: RGBA with scaling using Bicubic (good quality)
using video converter module "swscale"
looking for video converter module matching "any": 24 candidates
YUVP to YUVA converter
using video converter module "yuvp"
Deinterlacing available
deinterlace -1, mode auto, is_needed 0
looking for vout window module matching "any": 3 candidates
no vout window modules matched
Opening vout display wrapper
looking for vout display module matching "any": 12 candidates
creating Vout EventThread
Win32VoutCreateWindow
inclinometer not found. (hr=0x80070490)
created video sub-window
Vout EventThread running
Created the D3D11 device type 1 level b100.
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
supports colorspace RGB Rec.709 gamma:22 range:FULL
supports colorspace RGB Rec.709 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:STUDIO
supports colorspace RGB Rec.2020 gamma:22 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:FULL
supports colorspace RGB Rec.2020 gamma:2084 range:STUDIO
Output max luminance: 270.0, colorspace RGB Rec.709 gamma:22 range:FULL, bits per pixel 8
using colorspace RGB Rec.709 gamma:22 range:FULL
Using pixel format VA_NV12 for chroma DX11
Direct3D11 resources created
Direct3D11 device adapter successfully initialized
Direct3D11 Open Succeeded
using vout display module "direct3d11"
D3D11 pool succeed with 40 surfaces (640x512) context 0x00000209797c34e0
original format sz 640x480, of (0,0), vsz 640x480, 4cc DX11, sar 1:1, msk r0x0 g0x0 b0x0
VoutDisplayEvent 'window state' 0
VoutDisplayEvent 'window state' 0
Adding 'scene' as interactive
looking for video filter module matching "scene,chain": 46 candidates
Trying to use chroma I420 as middle man
looking for video converter module matching "any": 24 candidates
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978091e80) appended to chain
looking for video filter module matching "scene,chain": 46 candidates
using video filter module "scene"
Filter 'scene' (00000209780917a0) appended to chain
using video filter module "chain"
Filter 'scene' (0000020978091b10) appended to chain
Adding a filter to compensate for format changes
looking for video converter module matching "any": 24 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
looking for video converter module matching "any": 24 candidates
using video converter module "i420_nv12"
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (00000209780921f0) appended to chain
removing module "chain"
removing module "d3d11_filters"
Filter 0000020978091e80 removed from chain
removing module "scene"
Filter 00000209780917a0 removed from chain
Filter 0000020978091b10 removed from chain
removing module "d3d11_filters"
removing module "i420_nv12"
Filter 00000209780921f0 removed from chain
Adding 'scene' as interactive
looking for video filter module matching "scene,chain": 46 candidates
Trying to use chroma I420 as middle man
looking for video converter module matching "any": 24 candidates
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978091e80) appended to chain
looking for video filter module matching "scene,chain": 46 candidates
using video filter module "scene"
Filter 'scene' (0000020978092560) appended to chain
using video filter module "chain"
Filter 'scene' (00000209780921f0) appended to chain
Adding a filter to compensate for format changes
looking for video converter module matching "any": 24 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
looking for video converter module matching "any": 24 candidates
using video converter module "i420_nv12"
using video converter module "d3d11_filters"
Filter 'd3d11_filters' (0000020978090d50) appended to chain
removing module "freetype"
looking for text renderer module matching "any": 3 candidates
VoutDisplayEvent 'resize' 640x480
Using DWrite backend
DWrite_GetFamily(): family name: Arial
DWrite_ParseFamily(): using font at index 0 with weight 400 for bold: 0, italic: 0
DWrite_ParseFamily(): using font at index 1 with weight 700 for bold: 1, italic: 0
DWrite_ParseFamily(): using font at index 2 with weight 400 for bold: 0, italic: 1
DWrite_ParseFamily(): using font at index 3 with weight 700 for bold: 1, italic: 1
using text renderer module "freetype"
looking for hw decoder module matching "any": 2 candidates
different 0 device p vs P
different 1 device p vs P
failed to read the 2 Display Adapter registry key (2)
can't find adapter in registry
Reusing Direct3D11 device
CreateDevice succeed
- 'MPEG-2 variable-length decoder' is supported
- 'MPEG-2 inverse discrete cosine transform' is supported
- 'VC-1 variable-length decoder' is supported
- 'VC-1 variable-length decoder 2 (Intel)' is supported
- 'VC-1 variable-length decoder (Intel)' is supported
- 'Windows Media Video 9 IDCT' is supported
- 'VC-1 inverse discrete cosine transform' is supported
- 'H.264 variable-length decoder, no film grain technology' is supported
- 'H.264 stereo high profile, mbs flag set' is supported
- 'H.264 stereo high profile' is supported
- 'H.264 multiview high profile' is supported
- 'Unknown decoder 0xc528916c-0xc0af-0x4645-0x8cb2372b6d4adc2a' is supported
- 'Unknown decoder 0x91cd2d6e-0x897b-0x4fa1-0xb0d751dc88010e0a' is supported
- 'VP8' is supported
- 'Unknown decoder 0x442b942a-0xb4d9-0x4940-0xbc45a882e5f919f3' is supported
- 'Unknown decoder 0x97688186-0x56a8-0x4094-0xb543fc9daaa49f4b' is supported
- 'Unknown decoder 0x1424d4dc-0x7cf5-0x4bb1-0x9cd7b63717a72a6b' is supported
- 'Unknown decoder 0xc346e8a3-0xcbed-0x4d27-0x87cca70eb4dc8c27' is supported
- 'Unknown decoder 0xffc79924-0x5eaf-0x4666-0xa73606190f281443' is supported
- 'Unknown decoder 0xf416f7bd-0x098a-0x4cf1-0xa11bce54959ca03d' is supported
- 'Unknown decoder 0xbf44dacd-0x217f-0x4370-0xa383d573bc56707e' is supported
- 'Unknown decoder 0x2364d06a-0xf67f-0x4186-0xaed062b99e1784f1' is supported
- 'Unknown decoder 0x464bdb3c-0x91c4-0x4e9b-0x896f225496ac4ed6' is supported
- 'Unknown decoder 0x28566328-0xf041-0x4466-0x8b148f5831e78f8b' is supported
- 'Unknown decoder 0x6b4a94db-0x54fe-0x4ae1-0x9be47a7dad004600' is supported
- 'Unknown decoder 0x8c56eb1e-0x2b47-0x466f-0x8d337dbcd63f3df2' is supported
- 'HEVC Main profile' is supported
- 'Unknown decoder 0x75fc75f7-0xc589-0x4a07-0xa25b72e03b0383b3' is supported
- 'HEVC Main 10 profile' is supported
- 'Unknown decoder 0x07cfaffb-0x5a2e-0x4b99-0xb62ae4ca53b6d5aa' is supported
- 'VP9 profile 0' is supported
- 'VP9 profile 2' is supported
- 'VP9 profile Intel' is supported
- 'Unknown decoder 0x80a3a7bd-0x89d8-0x4497-0xa2b82126af7e6eb8' is supported
- 'Unknown decoder 0x8de911c4-0xc898-0x4364-0x97151de6b3fe773d' is supported
- 'Unknown decoder 0x50925b7b-0xe931-0x4978-0xa12a586630f095f9' is supported
- 'Unknown decoder 0xb69c20e0-0x2508-0x8790-0x0305875499e0a2d0' is supported
- 'Unknown decoder 0x49761bec-0x4b63-0x4349-0xa5ff87ffdf088466' is supported
Trying to use 'H.264 variable-length decoder, no film grain technology' as input
NV12 output is supported for decoder H.264 variable-length decoder, no film grain technology.
Using output format NV12 for decoder H.264 variable-length decoder, no film grain technology
va_pool_SetupDecoder id 27 640x480 count: 24
using external surface pool
ID3D11VideoDecoderOutputView succeed with 24 surfaces (640x480)
we got 9 decoder configurations
configuration[0] ConfigBitstreamRaw 2
configuration[1] ConfigBitstreamRaw 1
configuration[2] ConfigBitstreamRaw 2
configuration[3] ConfigBitstreamRaw 2
configuration[4] ConfigBitstreamRaw 2
configuration[5] ConfigBitstreamRaw 2
configuration[6] ConfigBitstreamRaw 2
configuration[7] ConfigBitstreamRaw 1
configuration[8] ConfigBitstreamRaw 1
DxCreateDecoderSurfaces succeed
using hw decoder module "d3d11va"
Using D3D11VA (Intel(R) UHD Graphics P630, vendor 8086(Intel), device 3e94, revision 0) for hardware decoding
Buffering 19%
auto hiding mouse cursor
Buffering 32%
Buffering 46%
Buffering 59%
Buffering 75%
Buffering 89%
tk->rtpSource->hasBeenSynchronizedUsingRTCP()
Stream buffering done (1026 ms in 2238 ms)
buffer deadlock prevented
Decoder wait done in 0 ms
looking for encoder module matching "any": 24 candidates
using encoder module "jpeg"
looking for video converter module matching "any": 24 candidates
640x480 (640x480) chroma: I420 -> 640x480 (640x480) chroma: J420 with scaling using Bicubic (good quality)
using video converter module "swscale"
So, all of the resulting screen shots from the stream are 640x480 and I need them to be based on the size of the incoming video stream if possible.
Try this method on the MediaPlayer
bool TakeSnapshot(uint num, string filePath, uint width, uint height)
I just figured out what the issue was. The RTSP stream has a preview and a main feed. I was consuming the preview feed in my code, which is 640x480. Once I switched to the correct (main) feed, everything is working as expected.

Youtube Red audio stops for downloaded videos

I am uploading videos to Youtube, and on my Android phone I am downloading them using Youtube Red. I am playing these downloaded videos in the background, when the screen is off.
This works with the wast majority of the videos, except the ones that I am uploading.
I did read the recommended upload formats, I tried several codecs, but no luck. My audios stop the second I am shutting off the screen.
What I finally found using youtube-dl -F is that my videos do not have audio-only tracks with webm extension, only as m4a (after Youtube processed them).
So my question is: what makes Youtube create webm audio files for some videos, but not for the others? Is there a way to force this (I suppose not). Is there a way to suggest it? As I mentioned, I tried a wide variety of codecs - video and audio, and the combinations - when generating my files to be uplaoded.
A sample output for a file which works:
format code extension resolution note
249 webm audio only DASH audio 52k , opus # 50k, 73.58KiB
250 webm audio only DASH audio 66k , opus # 70k, 92.62KiB
251 webm audio only DASH audio 114k , opus #160k, 161.14KiB
171 webm audio only DASH audio 115k , vorbis#128k, 161.27KiB
140 m4a audio only DASH audio 127k , m4a_dash container, mp4a.40.2#128k, 180.79KiB
and the output for one file which does not:
format code extension resolution note
139 m4a audio only DASH audio 49k , m4a_dash container, mp4a.40.5# 48k (22050Hz), 1.20MiB
140 m4a audio only DASH audio 129k , m4a_dash container, mp4a.40.2#128k (44100Hz), 3.20MiB

How to detect if a file is encoded using mp3PRO?

I have a folder which contains lot of MP3 files, some of them are encoded using mp3PRO.
Since this format is now obsolete, I'd like to convert them back to MP3 (converters can be found easily).
Is there is a way to detect programatically if a file is encoded using mp3PRO format ? (eg : by looking at file header or specific signatures using an hex editor)
The official player is able to detect if file is encoded using mp3PRO (the logo is highlighted or not) so I suppose this is technically possible.
What I found so far is that bitrate of mp3PRO file appears to be pretty low (50% of non encoded file) : eg : a 128 kbps file will appears as 64kbps. However a 320 kbps file will appears as 160 kpbs (which are pretty common) so it cannot be used as a rule.
Here is what I found out and how I fixed it. I wrote in here in case somebody would need it :
MP3Pro files does not contains any special flag in the mp3 header that would help to recognize them.
They are technically very similar to usual mp3 files, except they are encoded half the bit and sample rate (eg : a 128kpbs 44100hz file will be encoded as a 64kps 22050hz file, resulting in mp3pro file being approx half the size of original file).
This has been made for compatibility, so default players can play them without any change.
They also contains some SBR data, which allow to synthetically rebuild the lost audio part (high frequencies) and to play them it was before the mp3 pro conversion.
Detecting the SBR data seems very hard if not impossible : it would require to decode the actual mp3 frames. Also there is no documentation to be found about mp3pro format.
What I did (which works but required some manual effort) : I added all files to be checked to playlist of an mp3 player (foobar 2000 in my case) then sorted the files on the sample rate column : most 22050 hz mp3 files were indeed mp3 pro files.
They were converted back to mp3 using winamp + the mp3pro plugin made for it, available here : http://www.wav-mp3.com/mp3pro-to-mp3.htm

Determine whether an audio file is encoded in Apple Lossless (ALAC)

There are a number of audio files that have .m4a suffix and these are encoded in one of AAC or Apple Lossless (ALAC). I want to choose only audio files encoded in Apple Lossless of them. Is there any way to determine this? I tried FFmpeg, but it says all of them are encoded in AAC.
Edit: I am currently on Windows.
If you have the FFmpeg package, you should have ffprobe.
Give this a try:
ffprobe -v error -select_streams a:0 -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 file.m4a
-v error: to hide the startup text
-select_streams a:0: to select the first audio track
-show_entries stream=codec_name: to display only the codec type
-of default=noprint_wrappers=1:nokey=1: to remove extra formatting
This will print out just aac or alac. Perfect for scripting.
Here is a file that has a description of M4A (best I could find so far) on page 67:
http://iweb.dl.sourceforge.net/project/audiotools/audio%20formats%20reference/2.14/audioformats_2.14_letter.pdf
A typical M4A begins with an 'ftyp' atom indicating its file type...
10.2.1 the ftyp atom
[0 31] ftyp Length [32 63] 'ftyp' (0x66747970)
[64 95] Major Brand [96 127] Major Brand Version
[128 159] Compatible Brand₁ ...
The 'Major Brand' and 'Compatible Brand' elds are ASCII strings.
'Major Brand Version' is an integer.
At first I figured 'ftyp' would be where format is determined, but judging by this list that is more like the file type itself (already known as m4a):
http://www.ftyps.com/index.html
http://www.ftyps.com/what.html Describes a bit more of the format.
If ftyp doesn't differentiate, then I think that the 'Major Brand' field might refer to the fourcc's on this page:
http://wiki.multimedia.cx/index.php?title=QuickTime_container
The one for Apple Lossless being 'alac' and AAC is probably 'mp4a'
Apple's Lossless format open source page indicates that the ftype is 'alac' (slightly contradictory to above)
http://alac.macosforge.org/trac/browser/trunk/ALACMagicCookieDescription.txt
So far what I can tell is that the 4 bytes following ftyp are always (in a smallish sample size) 'M4A '.
Somewhere in the first ~200 (hex) bytes or so there is an ascii 'mp4a' for AAC compression or an 'alac' for Apple Lossless. The 'alac' always seems to come in pairs ~30 bytes apart ('mp4a' only once).
Sorry that's not more specific, if I find the exact location or prefix I'll update again. (My guess is the earlier part of the header has a size specified somewhere.)
You can do it with Core Audio.
Something like:
CFStringRef pathToFile;
CFURLRef inputFileURL = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, pathToFile, kCFURLPOSIXPathStyle, false);
ExtAudioFileRef inputFile;
ExtAudioFileOpenURL(inputFileURL, &inputFile);
AudioStreamBasicDescription fileDescription;
UInt32 propertySize = sizeof(fileDescription);
ExtAudioFileGetProperty(inputFile,
kExtAudioFileProperty_FileDataFormat,
&propertySize,
&fileDescription);
if(fileDescription.mFormatID == kAudioFormatAppleLossless){
// file is apple lossless
}
On a Mac, you select the file you want and then right click. Find "Get Info" and click that and a window will pop up with extra information about the file you selected. It should say next to "Codecs:" "AAC" or "Apple Lossless"
I hope I helped those Mac users out there that had the same question (and possibly Windows users in some way even though I am not familiar with the OS.)
try using http://sourceforge.net/projects/mediainfo/
"MediaInfo is a convenient unified display of the most relevant technical and tag data for video and audio files." - sourceforge project description
This is how info is displayed.
General
Complete name : C:\Downloads\recit24bit.m4a
Format : MPEG-4
Format profile : Apple audio with iTunes info
Codec ID : M4A
File size : 2.62 MiB
Duration : 9s 9ms
Overall bit rate : 2 441 Kbps
Track name : 24 bit recital ALAC Test File
Performer : N\A
Comment : Test File
Audio
ID : 1
Format : ALAC
Codec ID : alac
Codec ID/Info : Apple Lossless Format
Duration : 9s 9ms
Bit rate mode : Variable
Bit rate : 2 438 Kbps
Channel(s) : 2 channels
Sampling rate : 22.7 KHz
Bit depth : 24 bits
Stream size : 2.62 MiB (100%)
Language : English
Check audio section for codec/encoding details.

Beaglebone Black Video Capture: Error "select timeout"

Hey I'm following Derek Molloy's tutorial:
http://derekmolloy.ie/beaglebone/beaglebone-video-capture-and-image-processing-on-embedded-linux-using-opencv/#comment-30209
Using a Logitech c310 webcam, that is supported by the Linux UVC drivers.
root#beaglebone:/boneCV# v4l2-ctl --all
Driver Info (not using libv4l2):
Driver name : uvcvideo
Card type : UVC Camera (046d:081b)
Bus info : usb-musb-hdrc.1.auto-1
Driver version: 3.8.13
Capabilities : 0x84000001
Video Capture
Streaming
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line: 1280
Size Image : 614400
Colorspace : SRGB
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Video input : 0 (Camera 1: ok)
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
Priority: 2
So we can see it is read by the Beagleboard no problem.
When I try to capture the video, I simply get this error:
root#beaglebone:/boneCV# ./capture -f -c 600 -o > output.raw
Force Format 1
select timeout
Looking at other threads, people don't seem to know how to answer this question, can anyone with experience on this project help me out?
If you compare the image size of YUYV and that of MJPEG you will notice that the former is much larger than the latter. BBB has limited bandwidth on its USB port so thats why you cannot operate your camera in YUYV format. MJPEG outputs compressed video stream. Different opencv versions tend to change the resolution that you set with v4l2-ctl command so you have to change the resolution in the boneCV code. I'm not sure how its done in c++ but in python, check Changing camera resolution in opencv code. According to Matthew, Bandwidth limitations he tested and found out the bandwidth to be 13.2MB/s.
Well I can say the issue is resolved. After rebooting and trying the camera again after several hours, it magically seems to work.
The only thing I changed is the capture call to be simpler it is now:
./capture -o > output.raw
I haven't converted the raw file to mpeg4 yet, since I'm installing ffmpeg as I type this, however I can confirm that grabbing still images is working. The filesize of the output.raw is confirmation that it is indeed capturing video as well. If anyone finds this and is stuck, I will be glad to give assistance as much as I can.
Strangely, it only seems to capture video after using the picture grabber program first. So there must be something the grabber is initializing that isn't happening in the capture.
UPDATE: Ok it turns out that the YUYV video mode is not working but the mjpeg does, putting it into grabber mode initialized mjpeg mode and that's why it worked. Not sure why YUYV doesn't work yet.

Resources