I'm trying to generate a HLS stream from an input of N (in this example 2) HLS streams but I cannot figure out the right settings to get the PTS values right.
My streams can be represented this way :
stream A: chunk1 - chunk2 - chunk3 - chunk4
streamB: chunk1 - chunk2 - chunk3 - chunk4
output stream: chunkA1 - chunkA2 - generated junction chunk with part of chunk A3 and part of chunk B3 - chunkB4
I use the following command to generate my junction chunks:
ffmpeg -i <chunk from streamA> -i <chunk from streamB> -vcodec libx264 -vprofile baseline -g 10 -acodec aac -ar 44100 -ac 1 -filter_complex "[0:v]trim=0.000000:0.889000,setpts=PTS-STARTPTS[v0]; [0:a]atrim=0.000000:0.889000,asetpts=PTS-STARTPTS[a0]; [1:v]trim=4.889000:5.213700; [1:a]atrim=4.889000:5.213700; [v0][v1]concat=n=2:v=1:a=0[out]; [a0][a1]concat=n=2:v=0:a=1[aout] " -map "[out]" -map "[aout]" <output chunk>
The stream is playable with HLS.js (I add discontinuity tags when I switch streams) but when I try to send it to an rtmp server using this command :
ffmpeg -re -i <HLS url> -c:v copy -c:a aac -ar 44100 -ab 128k -ac 2 -strict -2 -flags +global_header -bsf:a aac_adtstoasc -bufsize 3000k -f flv <RTMP url>
FFmpeg complains about my DTS values and the output doesn't play very well.
I'd ideally like to avoid re-encoding my input streams but I'm fine re-encoding the ouput stream (in this example I'm not doing it but I've also tried). Although, it's ok if I have to re-mux the input.
Thanks !