2

I'm trying to make a simulated live HLS/DASH server using the equivalent of the following chain:

tsplay -loop multi_resolution.ts | shaka_packager | nginx

The problem is creating the file "multi_resolution.ts": It needs to contain a single program with 1 audio and 3 video PIDs, one each for 720p, 480p and 360p. Why? Because that's the way shaka_packager needs it to be.

I think I'm confused by how to map the transcoded streams to the output file. Here the non-working command I've been struggling with:

ffmpeg -i "big_buck_bunny_1080p.mov" -threads 16 \
    -c:a aac -ac 2 -b:a:0 128k \
    -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.0 -preset veryslow -tune film \
        -vsync cfr -x264-params "nal-hrd=cbr" \
        -b:v:1 5000k -minrate 2000k -maxrate 2000k -bufsize 4000k -g 30 -s 1280x720 \
    -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.0 -preset veryslow -tune film \
        -vsync cfr -x264-params "nal-hrd=cbr" \
        -b:v:2 1500k -minrate 1000k -maxrate 1000k -bufsize 2000k -g 30 -s 854x480 \
    -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.0 -preset veryslow -tune film \
        -vsync cfr -x264-params "nal-hrd=cbr" \
        -b:v:3 500k -minrate 500k -maxrate 500k -bufsize 1000k -g 30 -s 640x360 \
    -program program_num=1:title=multi_p30:st=0:st=1:st=2:st=3 \
    -f mpegts "big_buck_bunny_720_480_360.ts"

I tested each of the encodings in isolation, and they look good. I suspect the problem is with my stream management/mapping.

Help?

BobC
  • 135

1 Answers1

3

In order to insert multiple stream in an output, each input stream needs to be expressly mapped. The encoding options, by themselves, do not create a stream assignment in the output. There is the matter of automatic stream selection, which isn't applicable here, but you can read about it at https://ffmpeg.org/ffmpeg.html#Stream-selection

So,

ffmpeg -i "big_buck_bunny_1080p.mov" -threads 16 \
    -map 0:a -map 0:v -map 0:v -map 0:v \
    -c:a aac -ac 2 -b:a 128k \
    -s:v:0 1280x720 -s:v:1 854x480-s:v:2 640x360 \
    -g 30 -c:v libx264 -pix_fmt yuv420p -profile:v high -level 4.0 -preset veryslow -tune film \
    -vsync cfr -x264-params "nal-hrd=cbr" \
    -b:v:0 5000k -minrate:v:0 2000k -maxrate:v:0 2000k -bufsize:v:0 4000k \
    -b:v:1 1500k -minrate:v:1 1000k -maxrate:v:1 1000k -bufsize:v:1 2000k \
    -b:v:2 500k -minrate:v:2 500k -maxrate:v:2 500k -bufsize:v:2 1000k \
    -program program_num=1:title=multi_p30:st=0:st=1:st=2:st=3 \
    -f mpegts "big_buck_bunny_720_480_360.ts"
Gyan
  • 38,955