ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.75k stars 5.28k forks source link

Multiple Transcode directives under one vhost #3855

Closed mjankovskis closed 3 months ago

mjankovskis commented 8 months ago

What is the business background? Please provide a description. Everyone who wants to transcode different app on different endpoint etc. Single transcode on single app is working, but multiple transcode in config on different apps doesn't work.

Is your feature request related to a problem? Please describe.

vhost __defaultVhost__ {
  #for example i have "msrc" app which should remove audio from input
  transcode msrc {
          enabled on;
          ffmpeg ./objs/ffmpeg/bin/ffmpeg;
          engine copy {
              enabled on;
              vcodec copy;
              acodec an;
              output rtmp://127.0.0.1:[port]/history/[stream][param];
          }
   }
  #for example i have "msrc/0" app which should remove audio but point to different endpoint
  transcode msrc/0 {
          enabled on;
          ffmpeg ./objs/ffmpeg/bin/ffmpeg;
          engine copy {
              enabled on;
              vcodec copy;
              acodec an;
              output rtmp://127.0.0.1:[port]/live/[stream][param];
          }
   }
  #for example i have "src" app which should remove audio but point to history endpoint
  transcode msrc/0 {
          enabled on;
          ffmpeg ./objs/ffmpeg/bin/ffmpeg;
          engine copy {
              enabled on;
              vcodec copy;
              acodec copy;
              output rtmp://127.0.0.1:[port]/history/[stream][param];
          }
   }

Describe the solution you'd like When adding single transcode to vhost __defaultVhost__ it works, but when add multiple transcode, only the first one works.

Describe alternatives you've considered Alternative is to use another server (ip:port) or domain (vhost) which handles transcoding but allowing multiple transcodes under single vhost would allow to easier maintain, as problem is that this is related to streaming devices and configurating devices is timeconsuming. as there are audio, without-audio endpoints

The transcode functionality works as is, but would be nice to pass multiple transcods by "app"

I think that this could be implemented in here, it should itereate over all "transcode" configs, instead of getting first one.

{
    SrsConfDirective* conf = get_vhost(vhost);
    if (!conf) {
        return NULL;
    }

    conf = conf->get("transcode");
    if (!conf || conf->arg0() != scope) {
        return NULL;
    }

    return conf;
}