radames commited on
Commit
2c75576
·
1 Parent(s): cee1bed

add examples

Browse files
app.py CHANGED
@@ -100,7 +100,7 @@ def get_completion(prompt, files_info, top_p, temperature):
100
  "role": "system",
101
  # "content": f"""Act as a FFMPEG expert. Create a valid FFMPEG command that will be directly pasted in the terminal. Using those files: {files_info} create the FFMPEG command to achieve this: "{prompt}". Make sure it's a valid command that will not do any error. Always name the output of the FFMPEG command "output.mp4". Always use the FFMPEG overwrite option (-y). Don't produce video longer than 1 minute. Think step by step but never give any explanation, only the shell command.""",
102
  # "content": f"""You'll need to create a valid FFMPEG command that will be directly pasted in the terminal. You have those files (images, videos, and audio) at your disposal: {files_info} and you need to compose a new video using FFMPEG and following those instructions: "{prompt}". You'll need to use as many assets as you can. Make sure it's a valid command that will not do any error. Always name the output of the FFMPEG command "output.mp4". Always use the FFMPEG overwrite option (-y). Try to avoid using -filter_complex option. Don't produce video longer than 1 minute. Think step by step but never give any explanation, only the shell command.""",
103
- "content": f"""
104
  You are a very experienced agent controlling a UNIX terminal and a contributor to the ffmpeg project. You are given:
105
  (1) a set of video, audio and/or image assets. Including their name, duration, dimensions and file size
106
  (2) the description of a new video you need to create from the list of assets
@@ -109,7 +109,11 @@ Based on the available assets and the description, your objective issue a FFMPEG
109
 
110
  This will often involve putting assets one after the other, cropping the video format, or playing music in the background. Avoid using complex FFMPEG options, and try to keep the command as simple as possible as it will be directly paster into the terminal.
111
  Always output the media a video/mp4 and output file "output.mp4". Provide only the shell command without any explanations.
112
-
 
 
 
 
113
  The current assets and objective follow. Reply with the FFMPEG command:
114
 
115
  AVAILABLE ASSETS LIST:
@@ -117,17 +121,14 @@ AVAILABLE ASSETS LIST:
117
  {files_info_string}
118
 
119
  OBJECTIVE: {prompt}
120
- YOUR FFMPEG COMMAND:""",
121
- }
 
122
  ]
123
-
124
- print(messages[0]["content"])
125
-
126
  try:
127
  completion = openai.ChatCompletion.create(
128
  model="gpt-4", messages=messages, top_p=top_p, temperature=temperature
129
  )
130
-
131
  command = completion.choices[0].message.content.replace("\n", "")
132
 
133
  # remove output.mp4 with the actual output file path
@@ -156,7 +157,7 @@ def update(files, prompt, top_p=1, temperature=1):
156
  try:
157
  command_string = get_completion(prompt, files_info, top_p, temperature)
158
  print(
159
- f"""\n\n/// START OF COMMAND ///:\n\n{command_string}\n\n/// END OF COMMAND ///\n\n"""
160
  )
161
 
162
  # split command string into list of arguments
 
100
  "role": "system",
101
  # "content": f"""Act as a FFMPEG expert. Create a valid FFMPEG command that will be directly pasted in the terminal. Using those files: {files_info} create the FFMPEG command to achieve this: "{prompt}". Make sure it's a valid command that will not do any error. Always name the output of the FFMPEG command "output.mp4". Always use the FFMPEG overwrite option (-y). Don't produce video longer than 1 minute. Think step by step but never give any explanation, only the shell command.""",
102
  # "content": f"""You'll need to create a valid FFMPEG command that will be directly pasted in the terminal. You have those files (images, videos, and audio) at your disposal: {files_info} and you need to compose a new video using FFMPEG and following those instructions: "{prompt}". You'll need to use as many assets as you can. Make sure it's a valid command that will not do any error. Always name the output of the FFMPEG command "output.mp4". Always use the FFMPEG overwrite option (-y). Try to avoid using -filter_complex option. Don't produce video longer than 1 minute. Think step by step but never give any explanation, only the shell command.""",
103
+ "content": """
104
  You are a very experienced agent controlling a UNIX terminal and a contributor to the ffmpeg project. You are given:
105
  (1) a set of video, audio and/or image assets. Including their name, duration, dimensions and file size
106
  (2) the description of a new video you need to create from the list of assets
 
109
 
110
  This will often involve putting assets one after the other, cropping the video format, or playing music in the background. Avoid using complex FFMPEG options, and try to keep the command as simple as possible as it will be directly paster into the terminal.
111
  Always output the media a video/mp4 and output file "output.mp4". Provide only the shell command without any explanations.
112
+ """,
113
+ },
114
+ {
115
+ "role": "user",
116
+ "content": f"""
117
  The current assets and objective follow. Reply with the FFMPEG command:
118
 
119
  AVAILABLE ASSETS LIST:
 
121
  {files_info_string}
122
 
123
  OBJECTIVE: {prompt}
124
+ YOUR FFMPEG COMMAND:
125
+ """,
126
+ },
127
  ]
 
 
 
128
  try:
129
  completion = openai.ChatCompletion.create(
130
  model="gpt-4", messages=messages, top_p=top_p, temperature=temperature
131
  )
 
132
  command = completion.choices[0].message.content.replace("\n", "")
133
 
134
  # remove output.mp4 with the actual output file path
 
157
  try:
158
  command_string = get_completion(prompt, files_info, top_p, temperature)
159
  print(
160
+ f"""///PROMTP {prompt} \n\n/// START OF COMMAND ///:\n\n{command_string}\n\n/// END OF COMMAND ///\n\n"""
161
  )
162
 
163
  # split command string into list of arguments
gradio_cached_examples/16/Generated Video/a259b0996e13afdcfa2660b2553dadcd6c0eb289/output_b6a9d8fa-aea0-40ed-add9-29bed2cfd04f.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60b89fb5496c24e5a92f348ba02be74d9f0da6ea79a3514dbdbc9eee77f78589
3
+ size 221002
gradio_cached_examples/16/Generated Video/b7fc74293f6bbabfe8181eb22afaa41f45881a50/output_f557ac08-09f9-44b8-a54d-7b8ddb6e97c6.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17f7a1a6979bdfde4461e1d5458c21ac78efa703b32458e1fd30ac3910aa8b25
3
+ size 920454
gradio_cached_examples/16/Generated Video/d01997bc981fb482f9bc124d06ef75027f9412a3/output_16a8c8bb-5f2e-4701-a05d-d9e9029e903b.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3998e89a513b306da023a6cbb26ea3ad3a0ee66ea2c6d464b1334c0352a44353
3
+ size 5529045
gradio_cached_examples/16/Generated Video/da515a9911f57c0a33646483eaf2c74a9119b2ca/output_0854a32d-3899-4af4-850b-eeaad080d8f9.mp4 ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e6b94c5b85fd97462718a0f9cc7bf7d86e39197ddb43ac3a69e09eb74d517a4
3
+ size 68713
gradio_cached_examples/16/log.csv ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ Generated Video,component 1,flag,username,timestamp
2
+ /Users/radames/Development/hf-spaces/video-composer-gpt4/gradio_cached_examples/16/Generated Video/a259b0996e13afdcfa2660b2553dadcd6c0eb289/output_b6a9d8fa-aea0-40ed-add9-29bed2cfd04f.mp4,"{'value': '### Generated Command\n```bash\n ffmpeg\n -y\n -loop 1\n -i cat1.jpeg\n -loop 1\n -i cat2.jpeg\n -loop 1\n -i cat3.jpeg\n -loop 1\n -i cat4.jpeg\n -loop 1\n -i cat5.jpeg\n -loop 1\n -i cat6.jpeg\n -loop 1\n -i cat7.jpeg\n -loop 1\n -i cat8.jpeg\n -i heat-wave.mp3\n -filter_complex [0:v][1:v][2:v][3:v][4:v][5:v][6:v][7:v]concat=n=8:v=1:a=0,format=yuv420p[v]\n -map [v]\n -map 8:a\n -t 8\n -vcodec libx264\n -acodec aac\n -y output.mp4\n```', '__type__': 'update'}",,,2023-08-30 10:50:11.114051
3
+ /Users/radames/Development/hf-spaces/video-composer-gpt4/gradio_cached_examples/16/Generated Video/da515a9911f57c0a33646483eaf2c74a9119b2ca/output_0854a32d-3899-4af4-850b-eeaad080d8f9.mp4,"{'value': '### Generated Command\n```bash\n ffmpeg\n -i example.mp4\n -filter:v setpts=0.1*PTS\n -y output.mp4\n```', '__type__': 'update'}",,,2023-08-30 10:50:13.794110
4
+ /Users/radames/Development/hf-spaces/video-composer-gpt4/gradio_cached_examples/16/Generated Video/d01997bc981fb482f9bc124d06ef75027f9412a3/output_16a8c8bb-5f2e-4701-a05d-d9e9029e903b.mp4,"{'value': '### Generated Command\n```bash\n ffmpeg\n -i heat-wave.mp3\n -loop 1\n -i square-image.png\n -filter_complex [0:a]showwaves=s=720x720:mode=line:colors=white,format=yuv420p[v]\n -map [v]\n -map 0:a\n -shortest\n -y\n -y output.mp4\n```', '__type__': 'update'}",,,2023-08-30 10:50:24.151256
5
+ /Users/radames/Development/hf-spaces/video-composer-gpt4/gradio_cached_examples/16/Generated Video/b7fc74293f6bbabfe8181eb22afaa41f45881a50/output_f557ac08-09f9-44b8-a54d-7b8ddb6e97c6.mp4,"{'value': '### Generated Command\n```bash\n ffmpeg\n -i waterfall.mp4\n -i waterfall-overlay.png\n -filter_complex [0:v][1:v] overlay=0:0\n -y output.mp4\n```', '__type__': 'update'}",,,2023-08-30 10:50:28.299753