The support for video files is planned in the future versions of Red. But actually Red and RedCV cannot read and process video files. Sometimes I need to quickly read some video files and I appreciate using ffmpeg tools such as ffplay. This code is just a simple way to read videos with ffplay from Red. The code was developped under macOS but can be adapted to Windows OS.
Enjoy :)
A sample
The code
Red [
Title: "macOS FFMPEG Player"
Author: "Francois Jouen"
File: %rffplay.red
Needs: 'View
]
fileName: ""
prog: ""
isFile: false
command: {List of commands
q, ESC: Quit.
f: Toggle full screen.
p, SPC: Pause.
m: Toggle mute.
9, 0: Decrease and increase volume respectively.
/, *: Decrease and increase volume respectively.
a: Cycle audio channel in the current program.
v: Cycle video channel.
t: Cycle subtitle channel in the current program.
c: Cycle program.
w: Cycle video filters or show modes.
s: Step to the next frame.
left/right: Seek backward/forward 10 seconds.
down/up: Seek backward/forward 1 minute.
page down/page up :Seek to the previous/next chapter. or if there are no chapters Seek backward/forward 10 minutes.
right mouse click: Seek to percentage in file corresponding to fraction of width.
left mouse double-click: Toggle full screen.
}
loadFile: does [
isFile: false
tmp: request-file
if not none? tmp [
fileName: to string! to-file tmp
win/text: fileName
isFile: true
]
]
playFile: does [
if isFile [
prog: copy "ffplay '"
append append prog FileName "'"
either cb/data [call/console prog] [call prog]
]
]
view win: layout [
title "macOS ffplay"
origin 10x10 space 10x10
button "Load" [loadFile]
button "Play" [playFile]
cb: check "Show Console"
button "Quit" [prog: "killall ffplay" call prog Quit]
return
info: area 500x280
do [info/text: command]
]
Aucun commentaire:
Enregistrer un commentaire