简体   繁体   中英

It is possible using ffmpeg to burn in srt and speed up without audio adjustment in one go?

I have the following functions in my config file (fish shell, but the command would be easily adaptable) to one burn in provided srt subtitles above the file and another to speed up the file video and audio without adjusting the pitch.

function ffmpeg-burnin-srt
    ffmpeg -i $argv[1] -vf subtitles=$argv[2] -preset ultrafast $($now)-output.mkv
end

function speedupvid
      ffmpeg -i $argv[1] -filter_complex "[0:v]setpts=1/$argv[2]*PTS[v];[0:a]rubberband=tempo=$argv[2][a]" -map "[v]" -map "[a]" -preset ultrafast $($now)-output.mkv
end

I would like to and have tried combining the two but that is not allowed as it is a mixture of filters when complex is being used.

I believe I could run the two functions as one, but that would involve encoding twice.

Is it possible to do both steps in one pass and if not what would be the best solution?

Separate streams

You may add the second input source for subtitles and map subtitle stream as usual:

ffmpeg -i $argv[1] \
       -i $argv[3] \
       -filter_complex \
          "[0:v]setpts=1/$argv[2]*PTS[v];\
           [0:a]rubberband=tempo=$argv[2][a]" \
       -map "[v]" \
       -map "[a]" \
       -map 1 \
       -preset ultrafast \
       $($now)-output.mkv

Hardsubs

For hardsubs you should append overlay filter to the filter_complex (note changes in mapping):

inp=$argv[1]
spd=$argv[2]
sub=$argv[3]

ffmpeg -i $inp \
       -filter_complex \
          "subtitles=$sub[s]; \ 
           [0:v]setpts=1/$spd*PTS[v];\
           [v][s]overlay[outv]; \
           [0:a]rubberband=tempo=$spd[a]" \
       -map "[outv]" \
       -map "[a]" \
       -preset ultrafast \
       $($now)-output.mkv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM