1

I'm curious to know if I can program the videos that can be played on computer in general and on Youtube as a special case.

I had this crazy idea and I was able to create a very simple toss the coin game (without programming) on youtube: https://youtu.be/fkYYF5w5vpE

I think programming a video would create more complex games and has some other nice applications like choosing whether or not to watch the movie uncut, turn on and off 3D feature, creating videos for visually impaired people, ..etc.

On Youtube, I think it would be dangerous as in the past, hackers wrote programming lines (viruses) in a jpg or gif file extensions and uploaded it to the servers of the websites. So, If videos can be programmed on computers. Is it possible to upload them safely?

Edit:

I would like to write some codes inside a video so that it randomly chooses between two frames (Head or Tail). When someone plays the video, the head will appear. When he pauses and plays again, the Tail appears. Just like the linked video but the one that I would like to make should somehow contain programming code inside it.

user2824371
  • 269
  • 2
  • 9
  • 25
  • What do you mean by programming a video? The video link you provided does not shed any light on your question. Are you talking about using a programming language to generate a video automatically, or edit videos for you? Please edit your post to include more clarification. Thank you. – kemotep Oct 03 '19 at 12:22
  • @kemotep I edited my question wirting an example. I'm talking about a very simple video that contains of two frames only (head and tail) just for clarification. I'm asking about the genera idea of writing codes inside a video. – user2824371 Oct 03 '19 at 12:55
  • You cannot really use a video to execute code or embed code inside a video. Youtube most certainly would not allow that. If they did you can imagine that malicious actors would put all kinds of malware and nasty code to brick people's computer, steal information, and otherwise cause problems. Video files are code that video players execute but the code is for the frames and sound information. Non-frame or sound information would likely not be handled by a video player well. – kemotep Oct 03 '19 at 13:17
  • You can write a program to randomly show one picture or another picture and have it loop for a time period and record this to save into a video format, edit it and upload it to Youtube. Even the video editing process could be programmed using something like `ffmpeg` and YouTube has an api for uploading but that is not what you are asking. – kemotep Oct 03 '19 at 13:18
  • You may want to put an epilepsy warning on that video. – gronostaj Oct 03 '19 at 13:27
  • @kemotep Thank you for your comments. I think the short answer is: no, videos can't be programmed :) I would consider this the best answer if you wrote it in an answer. – user2824371 Oct 03 '19 at 13:31
  • @gronostaj Thanks for drawing my attention to that point. I'll write that in the description of the video as I currently can't edit the video. – user2824371 Oct 03 '19 at 13:32
  • People usually read description _after_ starting the video, at that point that epileptic person is having a seizure. (cool idea though) – gronostaj Oct 03 '19 at 13:37
  • It's also not the first game video on YouTube, I vaguely remember that some company made a simplistic adventure game on YT using clickable areas that linked to other videos. – gronostaj Oct 03 '19 at 13:39
  • @gronostaj Okay, I edited the description again :D Now, it's not the first game lol :D :D I'll also think of something to make the warning more obvious for people. I don't wanna hurt anyone. I'll ask and do what I can. – user2824371 Oct 03 '19 at 13:47

1 Answers1

4

You cannot use a video to execute code or embed code inside a video without exploiting some property of the video file format or video player software itself. Video files are code that video players execute but the code is handling the frames and sound information. Non-frame or sound information would likely not be handled by a video player well.

Here is another relevant Stack Exchange post you should check out if you want to learn more.

YouTube most certainly would not allow that. If they did, you can imagine that malicious actors would put all kinds of malware to brick people's computers, steal information, and otherwise cause problems.

However...

You can write a program to randomly show one picture or another picture and have it loop for a time period and record this to save into a video format, edit it and upload it to YouTube. Even the video editing process could be programmed using something like ffmpeg and YouTube has an API for uploading but that is not the question at hand.

User gronostaj points out that people have come up with ideas for "interactive" videos on YouTube before. Here is an article I found about interactive YouTube videos to see more ideas on how this works.

kemotep
  • 156
  • 1
  • 1
  • 7
  • "Video files are code that video players execute" - not really, unless you assume that code and data are the same thing, but that would make plain text files code. Video files are data. Video players process it and send to output (a display). – gronostaj Oct 03 '19 at 14:49
  • @gronostaj The general distinction is largely meaningless, as any file format you care to name can be trivially explained to be a declarative domain specific programming language, and the same logic you're using could be applied in reverse to say that everything is data (after all, CPU's process machine code (correction, 'machine data') and send the output to the various other components in the system). – Austin Hemmelgarn Oct 03 '19 at 19:22