I had already set environment variable for the ffmpeg in my windows,want to embed the srt file into my mp4 file with ffmpeg:
ffmpeg -i f:\sample\dance.mp4 -vf subtitles='f:\sample\dance.srt' f:\sample\out.mp4
It encounter a strange error:
Press [q] to stop, [?] for help
[subtitles @ 0000000002c2fd00] Unable to parse option value "sampledance.srt" as
image size
Last message repeated 1 times
[subtitles @ 0000000002c2fd00] Error setting option original_size to value sampl
edance.srt.
[Parsed_subtitles_0 @ 00000000005410c0] Error applying options to the filter.
[AVFilterGraph @ 0000000002940440] Error initializing filter 'subtitles' with ar
gs 'f:\sample\dance.srt'
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
I copy the files dance.mp4
and dance.srt
into f:\ffmpeg\bin
,then do the following:
cd \d f:\ffmpeg\bin
ffmpeg -i dance.mp4 -vf subtitles=dance.srt out.mp4
It works fine, how can make ffmpeg parse the option value f:\sample\dance.srt
properly,make the command execute normally in my windows?
ffmpeg -i f:\sample\dance.mp4 -vf subtitles='f:\sample\dance.srt' f:\sample\out.mp4
@kesh,it is no use to write as below:
ffmpeg -i f:\sample\dance.mp4 -vf "subtitles='f:\sample\dance.srt'" f:\sample\out.mp4
CodePudding user response:
The parsing rules for FFmpeg filter graph are different from the rules used for other arguments.
Since 'e\sample\dance.srt'
is a value of a filter graph argument, we have to add an escape character before every special character:
ffmpeg -i e:\sample\dance.mp4 -vf subtitles='e\:\\sample\\dance.srt' e:\sample\out.mp4
The subject is described in Notes on filtergraph escaping (among other places).