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.

10
  • 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 3, 2019 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. Oct 3, 2019 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 3, 2019 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 3, 2019 at 13:18
  • 1
    People usually read description after starting the video, at that point that epileptic person is having a seizure. (cool idea though)
    – gronostaj
    Oct 3, 2019 at 13:37

1 Answer 1

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.

2
  • 1
    "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 3, 2019 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). Oct 3, 2019 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .