Gstreamer multifilesrc - jpegs to HLS stream

143 Views Asked by At

Im using gstreamer to encode jpegs list into hls stream. I want to create HLS stream on 10 frames per second, and hls target-duration of 10 sec.

Im using this gst pipe :

gst-launch-1.0 -e multifilesrc location="0_%04d.jpg" caps='image/jpeg, framerate=10/1' ! nvjpegdec ! nvvidconv  ! queue ! nvv4l2h264enc iframeinterval=20 idrinterval=20 ! mpegtsmux ! hlssink  max-files=0 target-duration=10 playlist-location=cam00_.m3u8 location=cam00_%02d.ts

But it generate only one ts for all frames, and the output fps is 30 instead of 10. And for that reason not all players know to play the output

Any idea ?

1

There are 1 best solutions below

0
On

Could be something wrong the the nvidia plugins or the GStreamer runtime version, that is does not respect all sync point and framerate fields correctly.

I adapted the pipeline for PC:

gst-launch-1.0 -e multifilesrc location="jpg/%05d.jpg" caps='image/jpeg, framerate=10/1' ! jpegdec ! videoconvert ! queue ! vah264enc ! mpegtsmux ! hlssink  max-files=0 target-duration=10 playlist-location=cam00_.m3u8 location=cam00_%02d.ts

For 1000 frames I end up with:

-rw-r--r--. 1 fzwoch fzwoch 234060 Nov 23 18:03 cam00_00.ts
-rw-r--r--. 1 fzwoch fzwoch 236504 Nov 23 18:03 cam00_01.ts
-rw-r--r--. 1 fzwoch fzwoch 233496 Nov 23 18:03 cam00_02.ts
-rw-r--r--. 1 fzwoch fzwoch 236504 Nov 23 18:03 cam00_03.ts
-rw-r--r--. 1 fzwoch fzwoch 233308 Nov 23 18:03 cam00_04.ts
-rw-r--r--. 1 fzwoch fzwoch 236504 Nov 23 18:03 cam00_05.ts
-rw-r--r--. 1 fzwoch fzwoch 231616 Nov 23 18:03 cam00_06.ts
-rw-r--r--. 1 fzwoch fzwoch 237068 Nov 23 18:03 cam00_07.ts
-rw-r--r--. 1 fzwoch fzwoch 232932 Nov 23 18:03 cam00_08.ts
-rw-r--r--. 1 fzwoch fzwoch 236504 Nov 23 18:03 cam00_09.ts
-rw-r--r--. 1 fzwoch fzwoch    225 Nov 23 18:03 cam00_.m3u8

Which seems to result in correct 10 fps streams with 10 seconds.

$ ffprobe cam00_00.ts 
ffprobe version 6.0.1 Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 13 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --enable-chromaprint --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libjxl --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-libplacebo --enable-librsvg --enable-librav1e --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libshaderc --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libvpl --enable-runtime-cpudetect
  libavutil      58.  2.100 / 58.  2.100
  libavcodec     60.  3.100 / 60.  3.100
  libavformat    60.  3.100 / 60.  3.100
  libavdevice    60.  1.100 / 60.  1.100
  libavfilter     9.  3.100 /  9.  3.100
  libswscale      7.  1.100 /  7.  1.100
  libswresample   4. 10.100 /  4. 10.100
  libpostproc    57.  1.100 / 57.  1.100
Input #0, mpegts, from 'cam00_00.ts':
  Duration: 00:00:10.00, start: 3600.000000, bitrate: 187 kb/s
  Program 1 
  Stream #0:0[0x41]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(progressive), 320x240 [SAR 1:1 DAR 4:3], 10 fps, 10 tbr, 90k tbn

Run with GStreamer 1.22.7