[FFmpeg-user] Tokenised http subtitle source

adam smith adamsmith79 at icloud.com
Wed Apr 14 16:15:48 EEST 2021


Hi group, hope you are all good.

I am trying to embed subtitles onto an mp4 and everything is working very nicely thank you; except that the source location for the subtitle file is going to change.
It was previously an open http url and the command looked like this…
ffmpeg -y -ss 00:00.00 -to 07:55.97 -i /disposable/localised_20210414-1-1gyzvxm/some_video_file.mp4 -i https://some_domain.com/subtitles/18217/bf4130a3-64f8-40cb-aae8-720da75797a7.srt -filter_complex "[0:0]fifo[vout];[0:1]afifo[01_afifo]" -map "[vout]" -map "[01_afifo]" -map 1 -pix_fmt yuv420p -c:v libx264 -s 1920x1080 -profile:v high -level:v 4.1  -refs:v 2 -keyint_min 50 -b:v 15000k -r 25 -ac 2 -bsf:a aac_adtstoasc -c:a libfdk_aac -ar 48000 -b:a 192k -c:s mov_text -flags +global_header -f tee "[f=mp4:movflags=+faststart]/disposable/transcode_20210414-1-1ald4l9/bf4130a3-64f8-40cb-aae8-720da75797a7.mp4

Like I say, everything was groovy and the subtitles were embedded without first having to specify to download the subtitle file prior to passing it to FFmpeg.

But the subtitle file location is changing and is going to require authentication to access.
So the subtitle url will look something like this…with *really* long token.

https://some_domain.com/subtitles/18217/bf4130a3-64f8-40cb-aae8-720da75797a7.srt?AWSAccessKeyId=A*****************Z&Expires=1619000593&Signature=c******************D&response-content-disposition=attachment%3B%20filename%3Dbf4130a3-64f8-40cb-aae8-720da75797a7.srt&x-amz-security-token=I**********************************************************************************crazy_long*******

If I pass this through to ffmpeg I get an authentication error..
(It is difficult for me to run this manually as the command line is too long due to the token, but it runs in my script so I grabbed the reported failure message)

[https @ 0x7f40de879b40] HTTP error 403 Forbiddenhttps://some_domain.com/subtitles/18217/bf4130a3-64f8-40cb-aae8-720da75797a7.srt?AWSAccessKeyId=A*****************Z: Server returned 403 Forbidden (access denied)

It looks like it is cutting off the URL after the aws access key.

Does anybody know if FFmpeg will work with this type of token or should I just make a HTTP.get call in my script to localise the SRT file?

I found this https://www.jokecamp.com/blog/passing-http-headers-to-ffmpeg/ <https://www.jokecamp.com/blog/passing-http-headers-to-ffmpeg/> but its pretty old and looks like I would have to parse the URL and split it up to grab all the right sections, which is probably more effort than just HTTP.get(domain, rest_of_the_url) and localising.

Thanks for your suggestions

Adam



More information about the ffmpeg-user mailing list