Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File playback with switcher "might be a repeat question, sorry" #365

Open
TheSashmo opened this issue Dec 8, 2023 · 5 comments
Open

File playback with switcher "might be a repeat question, sorry" #365

TheSashmo opened this issue Dec 8, 2023 · 5 comments

Comments

@TheSashmo
Copy link

Sorry guys I am sure I asked this question before but for some reason I can't find it here. Maybe its deep in another thread.

What I would like to do is be able to record something, (which I can do) but then add it as a switchable source on my next session, example:

I was trying this, but it doesn't work. Ideally I'd like to not have to transcode it! Just choose that directory for playback. Adding to that, what audio source would I use for it, embedded?

/UltraGrid-1.8.6-x86_64.AppImage -t switcher -t decklink:0 -s embedded -t file:~/export.20231208/output.mp4 -c libavcodec:encoder=libx264:bitrate=25000k --audio-codec=MP3:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 127.0.0.1 --control-port 12345

@TheSashmo
Copy link
Author

So here is an update:

Works with no audio:
./UltraGrid-1.8.6-x86_64.AppImage -t switcher -t file:/root/export.20231208/output.mp4 -c libavcodec:encoder=libx264:bitrate=25000k --audio-codec=MP3:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 127.0.0.1 --control-port 12345 --audio-filter controlport_stats

Doesnt work:
./UltraGrid-1.8.6-x86_64.AppImage -t switcher -t decklink:device=0:codec=UYVY -s embedded -t file:/root/export.20231208/output.mp4 -c libavcodec:encoder=libx264:bitrate=25000k --audio-codec=MP3:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 127.0.0.1 --control-port 12345 --audio-filter controlport_stats

Crash output:
` ./UltraGrid-1.8.6-x86_64.AppImage -t switcher -t decklink:device=0:codec=UYVY -s embedded -t file:/root/export.20231208/output.mp4 -c libavcodec:encoder=libx264:bitrate=25000k --audio-codec=MP3:sample_rate=48000:bitrate=256k --audio-capture-format channels=16 -m 1316 -P 10000 127.0.0.1 --control-port 12345 --audio-filter controlport_stats
UltraGrid 1.8.6 (tags/v1.8.6 rev 6328048 built Oct 20 2023 14:53:58)

Display device : none
Capture device : switcher
Audio capture : embedded
Audio playback : none
MTU : 1316 B
Video compression: libavcodec:encoder=libx264:bitrate=25000k
Audio codec : MP3
Network protocol : UltraGrid RTP
Audio FEC : none
Video FEC : none

[lavcd aud.] Using audio encoder: libmp3lame
vidcap_switcher_init
[Decklink capture] Using codec: UYVY
[DeckLink capture] Using device DeckLink SDI Micro
[DeckLink capture] bmdDeckLinkConfigCapturePassThroughMode set to: 1885628787
The desired display mode is supported: 525i59.94 NTSC
[DeckLink capture] Enable video input: 525i59.94 NTSC
[DeckLink] Trying to autodetect format.
[DeckLink capture] Audio input set to: embedded
[DeckLink capture] EnableAudioInput: Decklink audio capture initialized sucessfully: 16 channels, 4 Bps, 48000 Hz, codec: PCM
[File cap.] Error while decoding frame (rc == -11): Resource temporarily unavailable.
Error decoding video frame (Resource temporarily unavailable)
Control socket listening on port 12345
Backtrace:
/tmp/.mount_UltraGhlchae/usr/bin/uv(+0xf8cbf)[0x5638ef7d8cbf]
/lib/x86_64-linux-gnu/libc.so.6(+0x43090)[0x7f42cc5b5090]
/tmp/.mount_UltraGhlchae/usr/bin/uv(float2int+0x3f)[0x5638ef77289f]
/tmp/.mount_UltraGhlchae/usr/bin/../lib/ultragrid/ultragrid_vidcap_file.so(+0x5f69)[0x7f42c2974f69]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8609)[0x7f42ccb3a609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7f42cc691353]

UltraGrid has crashed (Segmentation fault).

Please send a bug report to address [email protected].
You may find some tips how to report bugs in file doc/REPORTING_BUGS.md distributed with UltraGrid
(or available online at https://github.com/CESNET/UltraGrid/blob/master/doc/REPORTING-BUGS.md).
Segmentation fault (core dumped)`

@TheSashmo
Copy link
Author

Found the original thread. #316

The issue seems to be mainly with the -s embedded, if I don't pass that the video can play and can switch just fine. Whichever audio I pass it dosn't work. Ideally I'd like to pass the straight recording that was exported out ultragrid using the "e" option from the console.

@mpiatka
Copy link
Collaborator

mpiatka commented Dec 11, 2023

I can confirm the crash on the 1.8.6 version. However this seems to be already fixed on the continuous version.

To use the directory from UltraGrid recording as is without any processing you can use the import module instead of file. And yes, the audio source for that is embedded

@TheSashmo
Copy link
Author

Thanks @mpiatka I've been playing with this for a few days and not matter what I do, I can not make it work.

My goal is be able to record something that I am sending, and then at a later point use that file to switch to when there is no SDI coming in, you can call it running content until something is available on sdi. Here is what I am doing:

Step 1:
Source encoding, and in console enabling record. I get a output export folder: /root/export.20231222/

Step 2:
Using that source in my switcher command:
./UltraGrid-continuous-x86_64.AppImage -s embedded -t switcher -t decklink:connection=SDI:device=0 -t import:/root/export.20231222/:loop -c libavcodec:codec=H.264:encoder=libx264:bitrate=8000k:preset=ultrafast --audio-codec=MP3:sample_rate=48000:bitrate=128k --audio-capture-format channels=16 -f A:rs:200:250 -f V:rs:200:250 -m 1316 -P 25742 --control-port=2313 192.168.99.244

Error that I get once I try to switch sources:

[switcher] Switched from device 1 to device 2 (import:/root/export.20231222/:loop).
[lavc libx264 @ 0x7f27a0102440] frame I:1 Avg QP:57.98 size: 52597
[lavc libx264 @ 0x7f27a0102440] frame P:425 Avg QP:23.34 size: 30254
[lavc libx264 @ 0x7f27a0102440] mb I I16..4: 100.0% 0.0% 0.0%
[lavc libx264 @ 0x7f27a0102440] mb P I16..4: 6.3% 0.0% 0.0% P16..4: 5.8% 0.0% 0.0% 0.0% 0.0% skip:87.9%
[lavc libx264 @ 0x7f27a0102440] field mbs: intra: 100.0% inter:100.0% skip:100.0%
[lavc libx264 @ 0x7f27a0102440] coded y,uvDC,uvAC intra: 30.8% 20.0% 17.0% inter: 3.0% 2.7% 1.7%
[lavc libx264 @ 0x7f27a0102440] i16 v,h,dc,p: 47% 24% 27% 1%
[lavc libx264 @ 0x7f27a0102440] i8c dc,h,v,p: 76% 15% 9% 1%
[lavc libx264 @ 0x7f27a0102440] kb/s:7031.20
[lavc] Using codec: H.264, encoder: libx264
[lavc] No direct decoder format for: H.264. Trying to convert with swscale instead.
[lavc] Setting bitrate to 8000.0 kbps.
[lavc] Setting codec parameter preset to veryfast
[lavc] Setting codec parameter tune to zerolatency,fastdecode
[lavc] Auto-enabling interlaced DCT which may not be supported by HW decoders.
[lavc] Use ':disable_interlaced_dct' or ':safe' to disable.
[lavc] Auto-enabling intra-refresh which may not be supported by HW decoders.
[lavc] Use ':disable_intra_refresh' or ':safe' to disable.
[lavc] Setting codec parameter intra-refresh to 1
[lavc] Setting thread count to 0, type: (other)
[lavc] Setting codec parameter preset to ultrafast
[lavc libx264 @ 0x7f274001e080] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[lavc libx264 @ 0x7f274001e080] profile Main, level 4.0, 4:2:0, 8-bit
[lavc] Selected pixfmt: yuv420p
[lavc] Failed to find a way to convert H.264 to yuv420p
[lavc] Attempting to use swscale to convert from vaapi to yuv420p.
Could not allocate raw picture buffer
[lavc] Failed to get sws input conversion.
[lavc] Using codec: H.264, encoder: libx264
[lavc] No direct decoder format for: H.264. Trying to convert with swscale instead.
[lavc] Setting bitrate to 8000.0 kbps.
[lavc] Setting codec parameter preset to veryfast
[lavc] Setting codec parameter tune to zerolatency,fastdecode
[lavc] Auto-enabling interlaced DCT which may not be supported by HW decoders.
[lavc] Use ':disable_interlaced_dct' or ':safe' to disable.
[lavc] Auto-enabling intra-refresh which may not be supported by HW decoders.
[lavc] Use ':disable_intra_refresh' or ':safe' to disable.
[lavc] Setting codec parameter intra-refresh to 1
[lavc] Setting thread count to 0, type: (other)
[lavc] Setting codec parameter preset to ultrafast
[lavc libx264 @ 0x7f273000dd40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[lavc libmp3lame @ 0x7f27900ec0c0] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790154b80] Queue input is backward in time
[lavc libmp3lame @ 0x7f27901bd380] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790225c00] Queue input is backward in time
[lavc libmp3lame @ 0x7f279028e440] Queue input is backward in time
[lavc libmp3lame @ 0x7f27902f6c40] Queue input is backward in time
[lavc libmp3lame @ 0x7f279035f440] Queue input is backward in time
[lavc libmp3lame @ 0x7f27903c7c80] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790430400] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790498c80] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790501440] Queue input is backward in time
[lavc libmp3lame @ 0x7f2790569cc0] Queue input is backward in time
[lavc libmp3lame @ 0x7f27900ea040] Queue input is backward in time
[lavc libmp3lame @ 0x7f279063a980] Queue input is backward in time
[lavc libmp3lame @ 0x7f27906a2fc0] Queue input is backward in time
[lavc libmp3lame @ 0x7f27900eb9c0] Queue input is backward in time
[lavc libx264 @ 0x7f273000dd40] profile Main, level 4.0, 4:2:0, 8-bit
[lavc] Selected pixfmt: yuv420p
[lavc] Failed to find a way to convert H.264 to yuv420p
[lavc] Attempting to use swscale to convert from vaapi to yuv420p.
Could not allocate raw picture buffer
[lavc] Failed to get sws input conversion.
[lavc] Using codec: H.264, encoder: libx264
[lavc] No direct decoder format for: H.264. Trying to convert with swscale instead.

If I try to switch back to source 1 I get this error and crash:

[switcher] Switched from device 2 to device 1 (decklink:connection=SDI:device=0).
[DeckLink capture] Audio frame too small!
Backtrace:essage repeated 7 times
/tmp/.mount_UltraGkIgEgA/usr/bin/uv(crash_signal_handler+0x97)[0x56014548f6f7]
/lib/x86_64-linux-gnu/libc.so.6(+0x43090)[0x7ff2258f8090]
/tmp/.mount_UltraGkIgEgA/usr/bin/../lib/ultragrid/ultragrid_vcompress_libavcodec.so(to_lavc_vid_conv+0x22)[0x7ff21bb5a6f2]
/tmp/.mount_UltraGkIgEgA/usr/bin/../lib/ultragrid/ultragrid_vcompress_libavcodec.so(+0x327b5)[0x7ff21bb667b5]
/tmp/.mount_UltraGkIgEgA/usr/bin/uv(+0xc8e9a)[0x56014550de9a]
/tmp/.mount_UltraGkIgEgA/usr/bin/uv(_ZN9wp_worker3runEv+0x94)[0x560145504b34]
/tmp/.mount_UltraGkIgEgA/usr/bin/uv(_ZN9wp_worker10enter_loopEPv+0x1c)[0x560145504c7c]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x8609)[0x7ff2260fb609]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x43)[0x7ff2259d4353]

UltraGrid has crashed (Segmentation fault).

Please send a bug report to address [email protected].
You may find some tips how to report bugs in file doc/REPORTING_BUGS.md distributed with UltraGrid
(or available online at https://github.com/CESNET/UltraGrid/blob/master/doc/REPORTING-BUGS.md).
Segmentation fault (core dumped)

FYI using continuous version and tried without encoding audio as well, and the result is the same.

MartinPulec added a commit that referenced this issue Jan 3, 2024
Fixed a crash in situation where compressing stream with properties A,
then B but init fails and then again A.

This can occur when using switcher for 1->2->1 when compress reconf
fails for 2. But because `saved_desc` is set if reconf succeeds and
was already set on first configure, the state is inconsistent because
partially de/configured for 2 but it looks like it is still correctly
configured to input 1 because `saved_desc` was not cleared.

refers to GH-365
@mpiatka
Copy link
Collaborator

mpiatka commented Jan 3, 2024

Well, the problem is that --record saves compressed video if a compression is specified. The import source then imports the video frames already compressed which the libavcodec module cannot understand.

There are 2 ways to deal with the problem:

  1. Record the loop as uncompressed video. This could be done by using --record without specifying any -c <compression. Since uncompressed video is quite large this is only suitable for short loops. This can be then played with the import capturer.
  2. Record the video compressed and then use the commands described in the wiki to mux it into a mp4 container (this doesn't do any actual transcoding so it should be pretty quick). The mp4 can then be used with the file capturer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants