Ashx has asked for the wisdom of the Perl Monks concerning the following question:

Hey all ! I'm Ash and this is my first post here



The short question :
I am trying to install SDL::SMPEG or more precisely (Perl-)SDL with SDL::SMPEG in it, both from cpan and from the repository of my distribution (Arch Linux)

SDL seems to be configured to not install SMPEG by default

For example in the test run of the cpan install, it says :
"smpeg support not compiled"
Looking in the sources of the test script, it is right there :
if ( SDL::Config->has('smpeg') ) { ... } else { plan( skip_all => ( SDL::Config->has('smpeg') ? '' : ' smpeg suppo +rt not compiled' ) );

And indeed, it fails in finding files when i add "use SDL::SMPEG" in my script

So i'm looking into how i can change the config to explicitly DO install it



The long question :
I am building a Perl SDL application, which is supposed to run under X11 (on Linux)

In this application i want to show a video (available in a file) on the screen, with controls such as play, stop, seek to time etc. called from the script

I'm willing to consider all possible ways of making it, not only SDL::SMPEG, so if you can suggest something else go for it

Best Wishes - Ash

Replies are listed 'Best First'.
Re: Installing SDL::SMPEG
by cavac (Prior) on Mar 09, 2023 at 15:47 UTC

    Unfortunately, most Linux distributions strip SDL to the minimum point where "we installed SDL" is just about still true. SDL itself isn't that hard to compile, you could just install your own version into /user/local or something similar.

    The other option (the one i recommend because it is more flexible in the long run) is to use a minimal webserver and display the video in a video element. On the bonus side, the playback device doesn't need any special software installed, just a browser.

    With a bit more work (converting the video into a M3U8 stream) and using something like the hls.js javascript library, the client doesn't need to load the WHOLE video, but loads it in 5/10/whatever second increments in the background while you play. And it's easy to manipulate the M3U8 file on the fly, so you can stream multiple videos, livestream etc. (Even give your significant other the ability to insert ads/reminders to feed the trash and take out the dog).

    At the moment, i don't have a very nice example of this, only the stuff i did some time ago that's integrated into my own web framework.

    Not sure if this still works, but here's a snipped from the one-off converter i used to convert my youtube export videos to M3U8 files:

    ... my $dirpath = '/media/blogvideos/youtube/ffmpegconverted/' . $line- +>{video_id}; $line->{video_path} =~ s/^\.\///g; my $command = 'ffmpeg -i "/media/blogvideos/youtube/' . $line->{vi +deo_path} . '" -hls_list_size 0 "' . $dirpath . '/takeout.m3u8"'; my $mvcommand = 'mv ' . $dirpath . '/takeout.m3u8 ' . $dirpath . ' +/index.m3u8'; print "ID: ", $line->{video_id}, "\n"; print "DIR: ", $dirpath, "\n"; print "CMD: ", $command, "\n"; print "MV: ", $mvcommand, "\n"; mkdir $dirpath; `$command`; `$mvcommand`; print "\n\n"; ...

    The index (text) file will look something like this:

    #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:5.840000, /XXXPATHXXX/takeout0.ts #EXTINF:1.400000, /XXXPATHXXX/takeout1.ts #EXTINF:3.600000, /XXXPATHXXX/takeout2.ts #EXTINF:9.400000, /XXXPATHXXX/takeout3.ts #EXTINF:3.960000, /XXXPATHXXX/takeout4.ts ...

    The XXXPATHXXX path is just a convenient placeholder for my scripts, because file access maps different that URLs, and the corresponding scripts replace as required. This is the index file that gets regularly reloaded by the player, and makes it decide with video segment to play next. The player pretends that the whole list is one single big video, but on the backend you can mix&match as you please.

    #EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:10 #EXT-X-MEDIA-SEQUENCE:0 #EXTINF:5.840000, /XXXPATHXXX/takeout0.ts #EXTINF:1.400000, /XXXPATHXXX/takeout1.ts #EXTINF:10.00000, /wife/reminders/feedthedog.ts #EXTINF:9.400000, /XXXPATHXXX/takeout3.ts #EXTINF:60.00000, /wife/reminders/take_out_the_trash_NOW.ts #EXTINF:3.960000, /XXXPATHXXX/takeout4.ts ...

    Hope that helps.

    PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Re: Installing SDL::SMPEG
by Anonymous Monk on Mar 09, 2023 at 10:51 UTC
      Thanks

      I set off to the other ideas, namely LibVLC. Unfortunately the Perl bindings for that are broken (looks like there were API changes and something got lost - Types provided to the functions are not getting through, even the tutorial provided by the project itself is broken), so i am building this one in C

      Best Wishes - Ash