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

[BUG] CDG files fail to play to completion in latest bookworm pi release #323

Closed
vicwomg opened this issue Mar 21, 2024 · 8 comments
Closed

Comments

@vicwomg
Copy link
Owner

vicwomg commented Mar 21, 2024

Describe the bug
In the latest bookworm release, cdg files will play for a couple of seconds, then terminate early. This is NOT reproducible on bullseye. I imagine that other transcoded files such as avi, mpeg, mkv will experience the same.

For now please use Bullseye

To Reproduce
Install a fresh bookworm image, install pikaraoke. Add CDG files and try to play them.

Platform (please complete the following information):

  • OS: Raspberry Pi OS
  • OS version: Bookworm
  • Browser: Chromium

Additional context
Looks like bookworm installs ffmpeg version 5.1.4-0+rpt3+deb12u1 while bullseye installs ffmpeg version 4.3.6-0+deb11u1+rpt5 so that might be the major difference.

Discovered in #317

Seeing this in the ffmpeg log when this issue occurs. I believe the GPU is running out of memory while converting CDG:

[h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145its/s speed=7.18x    bitrate=N/A speed=   0x    
[h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable.08 bitrate= 192.8kbits/s speed=5.63x    
[2024-07-16 17:52:20] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[2024-07-16 17:52:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable
[2024-07-16 17:52:24] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable.08 bitrate= 192.8kbits/s speed=3.74x    
[2024-07-16 17:52:27] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[2024-07-16 17:52:28] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable
[2024-07-16 17:52:31] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
Error submitting video frame to the encoder=  869 fps= 29 q=-0.0 size=    2002kB time=00:01:25.08 bitrate= 192.8kbits/s speed= 2.8x    
[2024-07-16 17:52:32] DEBUG: [FFMPEG] [aac @ 0xafaab0] Qavg: 614.068
[2024-07-16 17:52:32] DEBUG: [FFMPEG] [aac @ 0xafaab0] 2 frames left in the queue on closing
[2024-07-16 17:52:32] DEBUG: [FFMPEG] Conversion failed!
@vicwomg
Copy link
Owner Author

vicwomg commented Mar 25, 2024

I seem to have better luck with the non rp3 version of 5.1.4: sudo apt-get install ffmpeg=7:5.1.4-0+deb12u1

Edit: song seems to get further but still terminates after 2m (the rpt3 version terminates at 40s). When hosting on the pi and running splash screen on another machine, the song completes.

@Anderen2
Copy link

This also fails on RPi 5 with bookworm, with both rpt3 and deb12u1 versions of ffmpeg 5.1.4.

When running with "./pikaraoke -l 0" for debug-output I got the following output:

[2024-04-27 23:11:19] INFO: Playing CDG/MP3 file: /home/a2/pikaraoke-songs/ZMSS03-09 - Summer Nights - Grease.mp3
[2024-04-27 23:11:19] DEBUG: COMMAND: ffmpeg -i /home/a2/pikaraoke-songs/ZMSS03-09 - Summer Nights - Grease.mp3 -copyts -i /home/a2/pikaraoke-songs/ZMSS03-09 - Summer Nights - Grease.cdg -filter_complex [1:v]fps=fps=25[s0] -map 0:a -map [s0] -f mp4 -b:v 5M -acodec aac -listen 1 -movflags frag_keyframe+default_base_moof -pix_fmt yuv420p -vcodec h264_v4l2m2m http://0.0.0.0:5556/1714252279
[2024-04-27 23:11:19] DEBUG: Killing ffmpeg process
[2024-04-27 23:11:20] DEBUG: [FFMPEG] ffmpeg version 5.1.4-0+rpt3+deb12u1 Copyright (c) 2000-2023 the FFmpeg developers
[2024-04-27 23:11:20] DEBUG: [FFMPEG] built with gcc 12 (Debian 12.2.0-14)
[2024-04-27 23:11:20] DEBUG: [FFMPEG] configuration: --prefix=/usr --extra-version=0+rpt3+deb12u1 --toolchain=hardened --incdir=/usr/include/aarch64-linux-gnu --enable-gpl --disable-stripping --disable-mmal --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sand --enable-sdl2 --disable-sndio --enable-libjxl --enable-neon --enable-v4l2-request --enable-libudev --enable-epoxy --libdir=/usr/lib/aarch64-linux-gnu --arch=arm64 --enable-pocketsphinx --enable-librsvg --enable-libdc1394 --enable-libdrm --enable-vout-drm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libavutil      57. 28.100 / 57. 28.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libavcodec     59. 37.100 / 59. 37.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libavformat    59. 27.100 / 59. 27.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libavdevice    59.  7.100 / 59.  7.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libavfilter     8. 44.100 /  8. 44.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libswscale      6.  7.100 /  6.  7.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libswresample   4.  7.100 /  4.  7.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] libpostproc    56.  6.100 / 56.  6.100
[2024-04-27 23:11:20] DEBUG: [FFMPEG] [mp3 @ 0x55560abf8d80] Estimating duration from bitrate, this may be inaccurate
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Input #0, mp3, from '/home/a2/pikaraoke-songs/ZMSS03-09 - Summer Nights - Grease.mp3':
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Duration: 00:03:45.04, start: 0.000000, bitrate: 127 kb/s
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
[2024-04-27 23:11:20] DEBUG: Stream ready!
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Input #1, cdg, from '/home/a2/pikaraoke-songs/ZMSS03-09 - Summer Nights - Grease.cdg':
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Duration: 00:03:45.07, start: 0.000000, bitrate: 57 kb/s
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Stream #1:0: Video: cdgraphics, pal8, 300x216, 300 fps, 300 tbr, 300 tbn
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Stream mapping:
[2024-04-27 23:11:20] INFO: Song ending: ZMSS03-09 - Summer Nights - Grease
[2024-04-27 23:11:20] DEBUG: Killing ffmpeg process
[2024-04-27 23:11:20] DEBUG: ffmpeg process killed
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Stream #1:0 (cdgraphics) -> fps:default (graph 0)
[2024-04-27 23:11:20] DEBUG: [FFMPEG] Stream #0:0 -> #0:0 (mp3 (mp3float) -> aac (native))
[2024-04-27 23:11:21] DEBUG: [FFMPEG] fps:default (graph 0) -> Stream #0:1 (h264_v4l2m2m)
[2024-04-27 23:11:21] DEBUG: [FFMPEG] Press [q] to stop, [?] for help
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0x55560ac1d1c0]  <<< v4l2_encode_init: fmt=0/-1
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0x55560ac1d1c0] Could not find a valid device
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0x55560ac1d1c0] can't configure encoder
[2024-04-27 23:11:21] DEBUG: [FFMPEG] Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [aac @ 0x55560ac1c380] Qavg: nan
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [aac @ 0x55560ac1c380] 1 frames left in the queue on closing
[2024-04-27 23:11:21] DEBUG: [FFMPEG] Conversion failed!

Where the following lines seems to be the suspect:

[[2024-04-27 23:11:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0x55560ac1d1c0] Could not find a valid device
[2024-04-27 23:11:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0x55560ac1d1c0] can't configure encoder

Found the following after some searching: https://forums.raspberrypi.com/viewtopic.php?t=364180
Seems like the h264_v4l2m2m codec is not supported for Raspberry Pi 5, so I tried modifying the following line in karaoke.py:

default_vcodec = "h264_v4l2m2m" if self.platform == "raspberry_pi" else "libx264"

To read:

default_vcodec = "libx264" 

And that worked :)

@ChadwickTheCrab
Copy link

ChadwickTheCrab commented May 8, 2024

I've been trying to play with your software inside a docker container I made. I can't get anything to play (CDG or Youtube) through any browser. It displays the up next notification but no audio plays. The only error it seems to throw is that it's just killing the ffmpeg process. The same happens for YT videos, they download but don't play. I also tried modifying that default_vcodec line in the post above mine but that didn't work either.

2024-05-08 12:49:26 [2024-05-08 16:49:26] INFO: [08/May/2024:16:49:26] ENGINE Bus STARTED
2024-05-08 12:49:26 [2024-05-08 16:49:26] INFO: Starting PiKaraoke!
2024-05-08 12:49:26 [2024-05-08 16:49:26] INFO: Connect the player host to: http://172.17.0.2:5555/splash
2024-05-08 12:49:35 [2024-05-08 16:49:35] INFO: Song ending: None
2024-05-08 12:49:35 [2024-05-08 16:49:35] DEBUG: Killing ffmpeg process
2024-05-08 12:49:35 [2024-05-08 16:49:35] DEBUG: ffmpeg process killed
2024-05-08 12:49:41 [2024-05-08 16:49:41] INFO: 'Anon-Qhnl' is adding song to queue: /root/pikaraoke-songs/311 - Amber [HM Karaoke].mp3
2024-05-08 12:49:44 [2024-05-08 16:49:44] INFO: Playing file: /root/pikaraoke-songs/311 - Amber [HM Karaoke].mp3 transposed 0 semitones
2024-05-08 12:49:44 [2024-05-08 16:49:44] INFO: Playing CDG/MP3 file: /root/pikaraoke-songs/311 - Amber [HM Karaoke].mp3
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: COMMAND: ffmpeg -i /root/pikaraoke-songs/311 - Amber [HM Karaoke].mp3 -copyts -i /root/pikaraoke-songs/311 - Amber [HM Karaoke].cdg -filter_complex [1:v]fps=fps=25[s0] -map 0:a -map [s0] -f mp4 -b:v 5M -acodec aac -listen 1 -movflags frag_keyframe+default_base_moof -pix_fmt yuv420p -vcodec libx264 http://0.0.0.0:5556/1715186984
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: Killing ffmpeg process
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] built with gcc 13.2.1 (Alpine 13.2.1_git20231014) 20231014
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] configuration: --prefix=/usr --disable-librtmp --disable-lzma --disable-static --disable-stripping --enable-avfilter --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libdrm --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libmp3lame --enable-libopenmpt --enable-libopus --enable-libplacebo --enable-libpulse --enable-librav1e --enable-librist --enable-libsoxr --enable-libsrt --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-lto=auto --enable-lv2 --enable-openssl --enable-pic --enable-postproc --enable-pthreads --enable-shared --enable-vaapi --enable-vdpau --enable-version3 --enable-vulkan --optflags=-O3 --enable-libjxl --enable-libsvtav1 --enable-libvpl
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libavutil 58. 29.100 / 58. 29.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libavcodec 60. 31.102 / 60. 31.102
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libavformat 60. 16.100 / 60. 16.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libavdevice 60. 3.100 / 60. 3.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libavfilter 9. 12.100 / 9. 12.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libswscale 7. 5.100 / 7. 5.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libswresample 5. 0.100 / 5. 0.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] libpostproc 57. 3.100 / 57. 3.100
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Input #0, mp3, from '/root/pikaraoke-songs/311 - Amber [HM Karaoke].mp3':
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Metadata:
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] title : Amber [HM Karaoke]
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] artist : 311
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] comment : http://www.otsaudio.com/
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Duration: 00:03:26.21, start: 0.023021, bitrate: 320 kb/s
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 320 kb/s
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: Stream ready!
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Metadata:
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] encoder : LAME3.99r
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Input #1, cdg, from '/root/pikaraoke-songs/311 - Amber [HM Karaoke].cdg':
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Duration: 00:03:12.04, start: 0.000000, bitrate: 57 kb/s
2024-05-08 12:49:44 [2024-05-08 16:49:44] DEBUG: [FFMPEG] Stream #1:0: Video: cdgraphics, pal8, 300x216, 300 fps, 300 tbr, 300 tbn
2024-05-08 12:49:46 [2024-05-08 16:49:46] INFO: Song starting: 311 - Amber [HM Karaoke]
2024-05-08 12:49:46 [2024-05-08 16:49:46] DEBUG: Stream is playing
2024-05-08 12:49:55 [2024-05-08 16:49:55] INFO: Song ending: 311 - Amber [HM Karaoke]
2024-05-08 12:49:55 [2024-05-08 16:49:55] DEBUG: Killing ffmpeg process
2024-05-08 12:49:55 [2024-05-08 16:49:55] DEBUG: ffmpeg process killed
2024-05-08 12:50:06 [2024-05-08 16:50:06] INFO: Song ending: None
2024-05-08 12:50:06 [2024-05-08 16:50:06] DEBUG: Killing ffmpeg process
2024-05-08 12:50:06 [2024-05-08 16:50:06] DEBUG: ffmpeg process killed

@vicwomg
Copy link
Owner Author

vicwomg commented May 8, 2024

I've been trying to play with your software inside a docker container I made. I can't get anything to play (CDG or Youtube) through any browser. It displays the up next notification but no audio plays. The only error it seems to throw is that it's just killing the ffmpeg process. The same happens for YT videos, they download but don't play. I also tried modifying that default_vcodec line in the post above mine but that didn't work either.

This doesn't sound related to the issue as described in this ticket. You may want to see this ticket on docker. There is some stuff that needs to happen to enable the multiple ports on which pikaraoke operates
#293

@LouOtway
Copy link

LouOtway commented May 11, 2024

I'm running bullseye, with a fresh install, and I get the same problem on RP3.

What do I need to do to get things working on RP3/Bullseye?

Previously this setup was working, but something must have changed.

@vicwomg vicwomg changed the title [BUG] CDG files fail to play in latest bookworm pi release [BUG] CDG files fail to play to completion in latest bookworm pi release Jul 15, 2024
@vicwomg
Copy link
Owner Author

vicwomg commented Jul 17, 2024

I have a branch with extra logging, seeing some h264_v4l2m2m errors every time the file terminates early, which are:

[h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145its/s speed=7.18x    bitrate=N/A speed=   0x    
[h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable.08 bitrate= 192.8kbits/s speed=5.63x    
[2024-07-16 17:52:20] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[2024-07-16 17:52:21] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable
[2024-07-16 17:52:24] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable.08 bitrate= 192.8kbits/s speed=3.74x    
[2024-07-16 17:52:27] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
[2024-07-16 17:52:28] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] Failed to get buffer for src frame: Resource temporarily unavailable
[2024-07-16 17:52:31] DEBUG: [FFMPEG] [h264_v4l2m2m @ 0xafba30] V4L2 capture poll unexpected timeout: events=0x145
Error submitting video frame to the encoder=  869 fps= 29 q=-0.0 size=    2002kB time=00:01:25.08 bitrate= 192.8kbits/s speed= 2.8x    
[2024-07-16 17:52:32] DEBUG: [FFMPEG] [aac @ 0xafaab0] Qavg: 614.068
[2024-07-16 17:52:32] DEBUG: [FFMPEG] [aac @ 0xafaab0] 2 frames left in the queue on closing
[2024-07-16 17:52:32] DEBUG: [FFMPEG] Conversion failed!

@vicwomg
Copy link
Owner Author

vicwomg commented Jul 19, 2024

This appears to be some regressions to h264_v4l2m2m encoding, but only for cdg files. It appears as though these conversions are exhausting the GPU memory. However, non-CDG transcoding is ok.

Luckily, it seems like falling back to non-hardware accelerated h264 encoding is fine for CDG, it's not very demanding on the CPU. I will do some testing on pi3 add this fix if it can keep up.

@vicwomg
Copy link
Owner Author

vicwomg commented Jul 19, 2024

Fixed in #351

@vicwomg vicwomg closed this as completed Jul 19, 2024
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

4 participants