EmJayEm
26th December 2004, 18:32
I'm using the GPAC tools (OSMO4, mp4box) to create a mpeg4 file.
I want to be able to jump back 3 seconds in a video by pressing a button while the video is playing. I have tried editing some of the GPAC Regression Test examples to achieve this but I am having no luck. This is what I did:
Created a 'jump' button:
Transform2D {
translation 50 -65
children [
DEF TS4 TouchSensor {}
Shape {
appearance Appearance {
material DEF M33 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 15
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Jump"]
fontStyle USE FS
}
}
]
}
]
}
Used a script node to jump back 3 seconds in the video.
DEF SC Script {
url "javascript:
function jump_time(value) {
if (value)
ctrl.mediaStartTime = ctrl.mediaStartTime -3.0;
}
"
eventIn SFBool jump_time
field SFNode ctrl USE MC
}
Then used a route to link the button to the script node:
ROUTE TS4.isActive TO SC.jump_time
Here is the complete code:
InitialObjectDescriptor {
objectDescriptorID 1
audioProfileLevelIndication 255
visualProfileLevelIndication 254
sceneProfileLevelIndication 1
graphicsProfileLevelIndication 1
ODProfileLevelIndication 1
esDescr [
ES_Descriptor {
ES_ID 1
decConfigDescr DecoderConfigDescriptor {
streamType 3
decSpecificInfo BIFSConfig {
isCommandStream true
pixelMetric true
pixelWidth 300
pixelHeight 200
}
}
}
ES_Descriptor {
ES_ID 2
decConfigDescr DecoderConfigDescriptor {
streamType 1
}
}
]
}
OrderedGroup {
children [
Background2D {
backColor 1 1 1
}
WorldInfo {
info ["This shows MediaControl" "controling video playback speed" "" "GPAC Regression Tests" "(C) 2002-2004 GPAC Team"]
title "Media Control Test"
}
DEF MC MediaControl {
url [od:8]
loop TRUE
}
Transform2D {
translation -100 -65
children [
DEF TS1 TouchSensor {}
Shape {
appearance Appearance {
material DEF M1 Material2D {
emissiveColor 1 0 0
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance DEF TXTAPP Appearance {
material Material2D {
emissiveColor 0 0 0
filled TRUE
}
}
geometry Text {
string ["Speed" "x4"]
fontStyle DEF FS FontStyle {
justify ["MIDDLE" "MIDDLE"]
size 18
}
}
}
]
}
]
}
Transform2D {
translation 100 -65
children [
DEF TS2 TouchSensor {}
Shape {
appearance Appearance {
material DEF M2 Material2D {
emissiveColor 0 0 1
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Speed" "x0.5"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 0 -65
children [
DEF TS3 TouchSensor {}
Shape {
appearance Appearance {
material DEF M3 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Mute"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 50 -65
children [
DEF TS4 TouchSensor {}
Shape {
appearance Appearance {
material DEF M33 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 15
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Jump"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 0 30
children [
Shape {
appearance Appearance {
texture MovieTexture {
url [od:8]
}
}
geometry Bitmap {}
}
]
}
DEF C1 Conditional {
buffer {
REPLACE MC.mediaSpeed BY 4
REPLACE M1.emissiveColor BY 1 0.5 0.5
}
}
DEF C2 Conditional {
buffer {
REPLACE MC.mediaSpeed BY 0.5
REPLACE M2.emissiveColor BY 0.5 0.5 1
}
}
DEF C3 Conditional {
buffer {
REPLACE MC.mute BY TRUE
REPLACE M3.emissiveColor BY 0.5 1 0.5
}
}
DEF RESET Conditional {
buffer {
REPLACE MC.mediaSpeed BY 1
REPLACE MC.mute BY FALSE
REPLACE M1.emissiveColor BY 1 0 0
REPLACE M2.emissiveColor BY 0 0 1
REPLACE M3.emissiveColor BY 0 1 0
}
}
DEF SC Script {
url "javascript:
function jump_time(value) {
if (value)
ctrl.mediaStartTime = 3.0;
}
"
eventIn SFBool jump_time
field SFNode ctrl USE MC
}
]
}
ROUTE TS1.isOver TO C1.activate
ROUTE TS1.isOver TO RESET.reverseActivate
ROUTE TS2.isOver TO C2.activate
ROUTE TS2.isOver TO RESET.reverseActivate
ROUTE TS3.isOver TO C3.activate
ROUTE TS3.isOver TO RESET.reverseActivate
ROUTE TS4.isActive TO SC.jump_time
AT 0 {
UPDATE OD [
ObjectDescriptor {
objectDescriptorID 8
esDescr [
ES_Descriptor {
ES_ID 21
OCR_ES_ID 21
muxInfo MuxInfo {
fileName "streams/video_small.media"
}
}
]
}
]
}
Does anyone know where I am going wrong with this?
Thanks,
EmJ.
PS. Bond, I like mp4menu!
I want to be able to jump back 3 seconds in a video by pressing a button while the video is playing. I have tried editing some of the GPAC Regression Test examples to achieve this but I am having no luck. This is what I did:
Created a 'jump' button:
Transform2D {
translation 50 -65
children [
DEF TS4 TouchSensor {}
Shape {
appearance Appearance {
material DEF M33 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 15
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Jump"]
fontStyle USE FS
}
}
]
}
]
}
Used a script node to jump back 3 seconds in the video.
DEF SC Script {
url "javascript:
function jump_time(value) {
if (value)
ctrl.mediaStartTime = ctrl.mediaStartTime -3.0;
}
"
eventIn SFBool jump_time
field SFNode ctrl USE MC
}
Then used a route to link the button to the script node:
ROUTE TS4.isActive TO SC.jump_time
Here is the complete code:
InitialObjectDescriptor {
objectDescriptorID 1
audioProfileLevelIndication 255
visualProfileLevelIndication 254
sceneProfileLevelIndication 1
graphicsProfileLevelIndication 1
ODProfileLevelIndication 1
esDescr [
ES_Descriptor {
ES_ID 1
decConfigDescr DecoderConfigDescriptor {
streamType 3
decSpecificInfo BIFSConfig {
isCommandStream true
pixelMetric true
pixelWidth 300
pixelHeight 200
}
}
}
ES_Descriptor {
ES_ID 2
decConfigDescr DecoderConfigDescriptor {
streamType 1
}
}
]
}
OrderedGroup {
children [
Background2D {
backColor 1 1 1
}
WorldInfo {
info ["This shows MediaControl" "controling video playback speed" "" "GPAC Regression Tests" "(C) 2002-2004 GPAC Team"]
title "Media Control Test"
}
DEF MC MediaControl {
url [od:8]
loop TRUE
}
Transform2D {
translation -100 -65
children [
DEF TS1 TouchSensor {}
Shape {
appearance Appearance {
material DEF M1 Material2D {
emissiveColor 1 0 0
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance DEF TXTAPP Appearance {
material Material2D {
emissiveColor 0 0 0
filled TRUE
}
}
geometry Text {
string ["Speed" "x4"]
fontStyle DEF FS FontStyle {
justify ["MIDDLE" "MIDDLE"]
size 18
}
}
}
]
}
]
}
Transform2D {
translation 100 -65
children [
DEF TS2 TouchSensor {}
Shape {
appearance Appearance {
material DEF M2 Material2D {
emissiveColor 0 0 1
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Speed" "x0.5"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 0 -65
children [
DEF TS3 TouchSensor {}
Shape {
appearance Appearance {
material DEF M3 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 30
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Mute"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 50 -65
children [
DEF TS4 TouchSensor {}
Shape {
appearance Appearance {
material DEF M33 Material2D {
emissiveColor 0 1 0
filled TRUE
}
}
geometry Circle {
radius 15
}
}
Transform2D {
children [
Shape {
appearance USE TXTAPP
geometry Text {
string ["Jump"]
fontStyle USE FS
}
}
]
}
]
}
Transform2D {
translation 0 30
children [
Shape {
appearance Appearance {
texture MovieTexture {
url [od:8]
}
}
geometry Bitmap {}
}
]
}
DEF C1 Conditional {
buffer {
REPLACE MC.mediaSpeed BY 4
REPLACE M1.emissiveColor BY 1 0.5 0.5
}
}
DEF C2 Conditional {
buffer {
REPLACE MC.mediaSpeed BY 0.5
REPLACE M2.emissiveColor BY 0.5 0.5 1
}
}
DEF C3 Conditional {
buffer {
REPLACE MC.mute BY TRUE
REPLACE M3.emissiveColor BY 0.5 1 0.5
}
}
DEF RESET Conditional {
buffer {
REPLACE MC.mediaSpeed BY 1
REPLACE MC.mute BY FALSE
REPLACE M1.emissiveColor BY 1 0 0
REPLACE M2.emissiveColor BY 0 0 1
REPLACE M3.emissiveColor BY 0 1 0
}
}
DEF SC Script {
url "javascript:
function jump_time(value) {
if (value)
ctrl.mediaStartTime = 3.0;
}
"
eventIn SFBool jump_time
field SFNode ctrl USE MC
}
]
}
ROUTE TS1.isOver TO C1.activate
ROUTE TS1.isOver TO RESET.reverseActivate
ROUTE TS2.isOver TO C2.activate
ROUTE TS2.isOver TO RESET.reverseActivate
ROUTE TS3.isOver TO C3.activate
ROUTE TS3.isOver TO RESET.reverseActivate
ROUTE TS4.isActive TO SC.jump_time
AT 0 {
UPDATE OD [
ObjectDescriptor {
objectDescriptorID 8
esDescr [
ES_Descriptor {
ES_ID 21
OCR_ES_ID 21
muxInfo MuxInfo {
fileName "streams/video_small.media"
}
}
]
}
]
}
Does anyone know where I am going wrong with this?
Thanks,
EmJ.
PS. Bond, I like mp4menu!