Converting mp3 to hls

I’m trying to convert a set of mp3s that represent chapters of an audiobook into HLS as part of a real-time streaming solution. While I have the code working, the main issue is that the conversion only creates one large segment per input file even if I specify 10 second segments in hlssink. Perhaps, I have to use another element such as splitmuxsink to manually split the files? I don’t have this problem with video. Here is the Python code fragment of my pipeline:

# Create the source element
    src = Gst.ElementFactory.make('appsrc', 'source')

    # Create the rest of the audio pipeline
    decodebin = Gst.ElementFactory.make('decodebin')
    audioconvert = Gst.ElementFactory.make('audioconvert')
    avenc_aac = Gst.ElementFactory.make('avenc_aac')  
    mpegtsmux = Gst.ElementFactory.make('mpegtsmux')
    hlssink = Gst.ElementFactory.make('hlssink')

    # Create the queue element
    queue = Gst.ElementFactory.make('queue')

    # Set the target-duration property of hlssink
    hlssink.set_property('target-duration', 20)  # Set target duration to 20 seconds

    # Set the location and playlist-location properties of hlssink
    hlssink.set_property('location', f'segment{i:05d}.ts')
    hlssink.set_property('playlist-location', f'playlist{i}.m3u8')

Just wondering, have you tried with hlssink2 or hlssink3?

I tried hllsink2 but the same pipeline somehow got. stuck. Same with hlsink3.

I have a working solution using ffmpeg that does what I want to do but am still interested in finding a solution with Gstreamer since my video streaming is with Gstreamer.

This pipeline seems to be working well with hlssink2. So I will adapt it into my code. It would be nice if there is a single spot for various pipeline examples. If there is one, I would like to know about it.

gst-launch-1.0 -e filesrc location=input.mp3 ! decodebin ! audioconvert ! audioresample ! avenc_aac ! aacparse ! queue ! hlssink2 max-files=0 playlist-length=0 playlist-root=./ location=./segment%05d.ts playlist-location=./playlist.m3u8

Usually each element’s documentation provides at least one pipeline example, see this page for instance: hlssink2

Thanks for the pointers. My code is now working with hlssink2 or hlssink3. I’m new to using gstreamer but I find it very powerful but also plenty to learn.
Regards, V