imageio / imageio-ffmpeg

FFMPEG wrapper for Python
BSD 2-Clause "Simplified" License
221 stars 50 forks source link

ffmpeg video filter vf with imageio-ffmpeg #103

Open sugizo opened 4 months ago

sugizo commented 4 months ago

objective use ffmpeg video filter vf with imageio-ffmpeg

code

from imageio_ffmpeg import read_frames, write_frames

output_file = 'magma.mp4'

reader = read_frames(video_file)
meta = reader.__next__()

writer = write_frames(output_file, audio_path = video_file,
                      size = meta['size'], fps = meta['fps'],
                      input_params = ['-y', ],
                      output_params = ['-r', fps_v, 
                                       '-vf', "[v0]pseudocolor = preset = magma[v1]", ] )
writer.send(None)

for frame in reader:
    writer.send(frame)

writer.close()

result

BrokenPipeError                           Traceback (most recent call last)
[/usr/local/lib/python3.10/dist-packages/imageio_ffmpeg/_io.py](https://localhost:8080/#) in write_frames(path, size, pix_fmt_in, pix_fmt_out, fps, quality, bitrate, codec, macro_block_size, ffmpeg_log_level, ffmpeg_timeout, input_params, output_params, audio_path, audio_codec)
    626             try:
--> 627                 p.stdin.write(bb)
    628             except Exception as err:

BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
1 frames
[/usr/local/lib/python3.10/dist-packages/imageio_ffmpeg/_io.py](https://localhost:8080/#) in write_frames(path, size, pix_fmt_in, pix_fmt_out, fps, quality, bitrate, codec, macro_block_size, ffmpeg_log_level, ffmpeg_timeout, input_params, output_params, audio_path, audio_codec)
    632                     "OUTPUT:\n".format(err, cmd_str)
    633                 )
--> 634                 raise IOError(msg)
    635 
    636             nframes += 1

OSError: [Errno 32] Broken pipe

FFMPEG COMMAND:
/usr/local/lib/python3.10/dist-packages/imageio_ffmpeg/binaries/ffmpeg-linux64-v4.2.2 -y -f rawvideo -vcodec rawvideo -s 640x368 -pix_fmt rgb24 -r 10.00 -y -i - -i merge_audio_ffmpeg.mp4 -vcodec libx264 -pix_fmt yuv420p -crf 25 -v warning -r 10 -vf [v0]pseudocolor = preset = magma[v1] -map 0:v:0 -map 1:a:0 magma.mp4

FFMPEG STDERR OUTPUT:

best regards

almarklein commented 4 months ago

Is there anything below FFMPEG STDERR OUTPUT:? I suspect ffmpeg does not like the arguments and gave up.

sugizo commented 4 months ago

Is there anything below FFMPEG STDERR OUTPUT:?

there's nothing below FFMPEG STDERR OUTPUT:

the parameter -vf [v0]pseudocolor = preset = magma[v1] is work fine when test with : ffmpeg on shell, vidgear, ffmpegio, typed-ffmpeg, python-ffmpeg, ffmpeg-python

best regards