ffmpeg -fflags +genpts -i infile.mp4 -f srt -i subtitles.srt \
-map 0:0 -map 0:1 -map 1:0 -c:v copy -c:a copy -c:s srt outfile.mkv
-fflags +genpts
necessary if you get Can't write packet with unknown timestamp
errors.
Transcode to lossless Flac and while applying peak normalisation to audio track
#!/bin/bash
#
# process tab delmited 'runsheet' file with format
# output name input name start time end time
#
# where start/end time are hh:mm:ss
#
tosecs() {
date '+%s' --date="$1"
}
fromsecs() {
((h=${1}/3600))
((m=(${1}%3600)/60))
((s=${1}%60))
printf "%02d:%02d:%02d\n" $h $m $s
}
IFS=$'\n'
for i in `cat runsheet`; do
oname=`echo $i | cut -f1`
iname=`echo $i | cut -f2 | tr -d "'"`
start=`echo $i | cut -f3`
end=`echo $i | cut -f4`
to=""
if [[ -n $end ]]; then
t=$(( $(tosecs "$end") - $(tosecs "$start") ))
to="-t $(fromsecs $t)"
fi
if [[ -n $start ]]; then
ss="-ss $start"
else
ss="-ss 00:00:00"
fi
cmd="ffmpeg $ss $to -i \"../$iname\" -vcodec copy -acodec flac -filter:a loudnorm $oname.mkv"
echo $cmd
eval $cmd
date
echo
done
ffmpeg -f pulse -i default -acodec libopus -b:a 96000 -vbr on -compression_level 10 -f rtp rtp://127.0.0.1:1234
Play from RTP stream:
Create SDP file using details output from ffmpeg command.
v=0
o=- 0 0 IN IP4 127.0.0.1
s=No Name
c=IN IP4 127.0.0.1
t=0 0
a=tool:libavformat 58.12.100
m=audio 1234 RTP/AVP 97
b=AS:96
a=rtpmap:97 opus/48000/2
a=fmtp:97 sprop-stereo=1
Then pass SDP file to RTP client:
ffplay -i opus.sdp -protocol_whitelist file,udp,rtp