Error initializing filter 'subtitles' with args
Here's my python code:
import ffmpeg
input_dir = "C:/Users/27433/Desktop/1/"
video_file = '1_1_1.mp4'
subtl_file = '1_1_1.srt'
(
ffmpeg
.input(input_dir + video_file)
.filter('subtitles', input_dir + subtl_file)
.output(input_dir + 'output.mp4')
.run()
)
I'm sure all the files are in the right place: video in "C:\Users\27433\Desktop\1\1_1_1.mp4", subtitle in "C:\Users\27433\Desktop\1\1_1_1.srt" And the srt file's encoding is UTF-8, But the ffmpeg reported error:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/27433/Desktop/1/1_1_1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.71.100
description : Packed by Bilibili XCoder v2.0.2
Duration: 00:00:27.73, start: 0.000000, bitrate: 231 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 45 kb/s, 30 fps, 30 tbr, 16k tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 176 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
[Parsed_subtitles_0 @ 0000025a67d4d200] libass API version: 0x1502002
[Parsed_subtitles_0 @ 0000025a67d4d200] libass source: commit: 0.15.2-69-gf664ced049394e2a5d4300ba526e206df73ec729
[Parsed_subtitles_0 @ 0000025a67d4d200] Shaper: FriBidi 1.0.11 (SIMPLE) HarfBuzz-ng 4.2.0 (COMPLEX)
[Parsed_subtitles_0 @ 0000025a67d4d200] Unable to open C\:/Users/27433/Desktop/1/1_1_1.srt
[AVFilterGraph @ 0000025a67d6f280] Error initializing filter 'subtitles' with args 'C\\\:/Users/27433/Desktop/1/1_1_1.srt'
Error initializing complex filters.
Invalid argument
Traceback (most recent call last):
File "C:\Users\27433\Desktop\Ermu1.5\test.py", line 11, in <module>
.run()
File "C:\Users\27433\Desktop\Ermu1.5\venv\lib\site-packages\ffmpeg\_run.py", line 325, in run
raise Error('ffmpeg', out, err)
ffmpeg._run.Error: ffmpeg error (see stderr output for detail)
Then I tried to replace the ""to "\"or"/",but the error are still there, And I also tried to use ``` file_path=r"C:\Users\27433\Desktop\1\1_1_1.mp4" subtitle_path=r"C:\Users\27433\Desktop\1\1_1_1.srt" output_path=r"C:\Users\27433\Desktop\1\output.mp4" os.system("ffmpeg.EXE -i {} -vf subtitles={} {}".format(file_path, subtitle_path, output_path))
(The ffmpeg.exe are in the same folder as the .py file)
But it also raise error:
[subtitles @ 0000027c04691ac0] Unable to parse option value "Users27433Desktop11_1_1.srt" as image size Last message repeated 1 times [subtitles @ 0000027c04691ac0] Error setting option original_size to value Users27433Desktop11_1_1.srt. [Parsed_subtitles_0 @ 0000027c04600600] Error applying options to the filter. [AVFilterGraph @ 0000027c091ac300] Error initializing filter 'subtitles' with args 'C:Users27433Desktop11_1_1.srt' Error reinitializing filters! Failed to inject frame into filter network: Invalid argument Error while processing the decoded data for stream #0:0 [aac @ 0000027c041d0bc0] Qavg: 11856.707 [aac @ 0000027c041d0bc0] 2 frames left in the queue on closing Conversion failed!
or replace the "\" to"\\"or"/"
[subtitles @ 0000018074536a80] Unable to parse option value "Users27433Desktop11_1_1.srt" as image size Last message repeated 1 times [subtitles @ 0000018074536a80] Error setting option original_size to value Users27433Desktop11_1_1.srt. [Parsed_subtitles_0 @ 0000018071885ec0] Error applying options to the filter. [AVFilterGraph @ 0000018076c88900] Error initializing filter 'subtitles' with args 'C:\Users\27433\Desktop\1\1_1_1.srt' Error reinitializing filters!
[subtitles @ 000002d7e9858ac0] Unable to parse option value "/Users/27433/Desktop/1/1_1_1.srt" as image size Last message repeated 1 times [subtitles @ 000002d7e9858ac0] Error setting option original_size to value /Users/27433/Desktop/1/1_1_1.srt. [Parsed_subtitles_0 @ 000002d7e9c96bc0] Error applying options to the filter. [AVFilterGraph @ 000002d7ef088a00] Error initializing filter 'subtitles' with args 'C:/Users/27433/Desktop/1/1_1_1.srt'
Why could all these happen?how should I fix it?
I'll be very grateful if anybody could help me.