CodeWalrus

Development => PC, Mac & Vintage Computers => Topic started by: Ephraim Becker on November 27, 2015, 01:40:30 AM

Title: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 01:40:30 AM
Is there a way to code a mp4 video from scratch? How do I do it?
Title: Re: How to code an mp4 video
Post by: bb010g on November 27, 2015, 01:42:19 AM
"Code" a MP4? Please be more specific. Also, what resources have you already looked at?
Title: Re: How to code an mp4 video
Post by: Adriweb on November 27, 2015, 01:47:27 AM
It's the ISO 14496-1 spec.
http://xhelmboyx.tripod.com/formats/mp4-layout.txt

Good luck
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 02:28:33 AM
What programming language do I use to program an mp4 video?
Title: Re: How to code an mp4 video
Post by: bb010g on November 27, 2015, 02:31:41 AM
Quote from: Ephraim Becker on November 27, 2015, 02:28:33 AM
What programming language do I use to program an mp4 video?
What have you looked at already? We won't help you unless you prove that you've tried at least an iota already.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 02:36:07 AM
I found a tutorial over here: http://funprogramming.org/125-Simple-video-player-in-Processing.html
Title: Re: How to code an mp4 video
Post by: bb010g on November 27, 2015, 02:42:10 AM
Ok. So you want to play a MP4 video, not "code" one (whatever that means)?
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 02:45:04 AM
This tutorial is much better: http://funprogramming.org/114-How-to-create-movies-using-Processing.html
Title: Re: How to code an mp4 video
Post by: Travis on November 27, 2015, 02:49:56 AM
So you're talking about creating animations? That's one thing. Actually decoding (or encoding) a codec like MPEG is not something you want to be trying to do from scratch at this stage. (I'm not sure very many of us here even know how to do that.) Better just use a program or library for that part.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 02:51:06 AM
I actually want to program an mp4 video from scratch in C. How do I do that?
Title: Re: How to code an mp4 video
Post by: Travis on November 27, 2015, 02:57:25 AM
I really don't understand what you're saying. MP4 is not a programming language. It's just a linear, non-interactive stream of data. If you really want to learn codecs, you're best off starting really, really small. First figure out how bitmaps are stored. Then basic lossless compression (RLE, PNG/GIF, etc.). Then JPEG. Then some very early, very simple lossy codecs. MPEG4/H264 is insanely complicated (and that's not including the audio). It can take literally years to get up to speed with this stuff.
Title: Re: How to code an mp4 video
Post by: Adriweb on November 27, 2015, 02:58:26 AM
Quote from: Ephraim Becker on November 27, 2015, 02:51:06 AMprogram an mp4 video
This does not make sense. "program" or "code" are verbs that don't go with "mp4" or "video". It's like asking "Put your glasses on and listen to the nice smell".
What are you actually trying to do? The end goal.

Also what tev said.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 02:59:00 AM
I know that mp4 is not a programming language. I want to know if I can code an mp4 file in C.
Title: Re: How to code an mp4 video
Post by: Adriweb on November 27, 2015, 03:00:43 AM
(https://i.imgur.com/URe6lX5.gif)

Dude. Read what we just said.

Edit:
Actually, here you go, some C code to code an mp4:
FILE* f = fopen("THEREYOUGO.mp4", "rb");
fclose(f);
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 03:05:08 AM
Any tutorials for how to program an mp4 video in C? I can't find any in my google search or bing search.
Title: Re: How to code an mp4 video
Post by: Travis on November 27, 2015, 03:18:11 AM
You probably aren't finding tutorials because "program an MP4" is not a phrasing that makes sense to most people. What do you want the program to do, exactly? What will appear on the screen when you run it? Does it do anything in response to keyboard or mouse input, and what? What will get stored on the hard drive?

Please consider explaining what you mean, without repeating the same sentence over and over, because that will not help us understand you. If you again respond to this post with something substantially similar to "I want to program/code an MP4 file...", I'm personally going to give up and stop participating in this thread because it's clear I'm not able to help you, and I'm afraid others might do the same.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 03:22:47 AM
What I mean is instead of taking a video with a video camera, I want to code the video. I'm expecting my C program, main.c, to compile down to main.mp4 and when I click on it, it will open up in a video player (example: Windows Media Player) and play the video I coded in C. The problem is that I don't know how to do that.
Title: Re: How to code an mp4 video
Post by: Dream of Omnimaga on November 27, 2015, 03:47:39 AM
Do you mean a C program that generates each frame pixel by pixel, like people do with PHP images? (examples: Cemetech, Omnimaga and CodeWalrus post statistic graphics)
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 03:49:19 AM
Don't I need to start by making a lot of images?
Title: Re: How to code an mp4 video
Post by: Yuki on November 27, 2015, 03:52:16 AM
Okay I think I know what he wants to do. Dynamically-generated MP4 files, just like the GD library we use in PHP to dynamically generate images, but for MP4s.

Theorically, you could, you could code an animation in C and stitch all the images in a MP4. But it's pretty hard without a library.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 03:54:44 AM
Is there an official mp4 C library?
Title: Re: How to code an mp4 video
Post by: Ivoah on November 27, 2015, 04:19:36 AM
I would use Processing to make an animation and then use a screen recorder to record it.
Title: Re: How to code an mp4 video
Post by: bb010g on November 27, 2015, 04:37:09 AM
You are not asking good questions.

Stop that.

To help you, I'm going to leave these here: How To Ask Questions The Smart Way (http://catb.org/~esr/faqs/smart-questions.html), and The Help Vampire: A Spotter's Guide (http://www.skidmore.edu/~pdwyer/e/eoc/help_vampire.htm). Read them.

I've been holding off on posting these. CodeWalrus is normally a pretty friendly place. We try to help people, even if we have to go out of our ways to try and decipher their questions, code, or whatever. We don't want to make people feel unwelcome.

However, these people normally, over time, hone their problem solving-fu and figure out how to search more effectively, how to think more effectively, and how to ask questions more effectively. You have not done any of that. You, in this thread alone, have managed to provide little information and have ignored our requests for clarification. Thus, you have received little help, and this thread could very well be considered a waste of time for all involved. None of us want this.

We continually try to divine meaning from you because we want you to succeed. Your determination is admirable, but there's a reason we tell you to not start with ASM, indent your JS, and not try to reverse engineer drivers for Windows. Those things are hard, and we've seen many people try them and fail, becoming discouraged. We love programming, and we want you to love it too. This forum interaction is a give and take between everyone. If we're going to give you help so we can experience the fruits of your labor, you have to take some of our advice and put in some effort.

We are not your personal human search engine. This is covered in How To Ask Questions The Smart Way, which you should go back and read if you haven't yet. Being a search engine takes time and is boring; that's why computers do it.

Again, we want to help you. Help us help you.
Title: Re: How to code an mp4 video
Post by: Dream of Omnimaga on November 27, 2015, 04:41:28 AM
Quote from: Ephraim Becker on November 27, 2015, 03:49:19 AM
Don't I need to start by making a lot of images?

Depends. If your video is 90 minutes long, uncompressed, 24-bits colors at 1080p resolution, then I think you will need 938.5 GB of RAM. So in some cases, pre-rendering would not be recommended. :P



Quote from: bb010g on November 27, 2015, 04:37:09 AM
You are not asking good questions.

Stop that.

To help you, I'm going to leave these here: How To Ask Questions The Smart Way (http://catb.org/~esr/faqs/smart-questions.html), and The Help Vampire: A Spotter's Guide (http://www.skidmore.edu/~pdwyer/e/eoc/help_vampire.htm). Read them.

To be fair, we aspergers don't like long texts due to our relatively short attention span, so perhaps a shorter version, or directing him to the most important points, if your post is missing any, might be a better solution.
Title: Re: How to code an mp4 video
Post by: Ephraim Becker on November 27, 2015, 01:42:58 PM
Quote from: DJ Omnimaga on November 27, 2015, 04:41:28 AM
Quote from: Ephraim Becker on November 27, 2015, 03:49:19 AM
Don't I need to start by making a lot of images?

Depends. If your video is 90 minutes long, uncompressed, 24-bits colors at 1080p resolution, then I think you will need 938.5 GB of RAM. So in some cases, pre-rendering would not be recommended. :P

I only have 4 GB of RAM. I do want to make a long video. Is there anyway I can do this with 4 GB of RAM?
Title: Re: How to code an mp4 video
Post by: Snektron on November 27, 2015, 03:40:20 PM
You don't want to code an mp4 video, you want to make a program that generates an mp4 video. There are already programs for this, like blender etc, but if you really want to you can do it in C. What you would need is some way to generate frames, then put them into a mp4 file. You would probably need to learn the ffmpeg api and create the neccesary drawing functions yourself though. You need a main loop which loops though all the images (say you want to create a 60 second animation at 30 fps you loop 1800 times).

A better approach would probably to get a library like SDL output to a mp4 file...
Title: Re: How to code an mp4 video
Post by: Dream of Omnimaga on November 27, 2015, 04:57:41 PM
Quote from: Ephraim Becker on November 27, 2015, 01:42:58 PM
Quote from: DJ Omnimaga on November 27, 2015, 04:41:28 AM
Quote from: Ephraim Becker on November 27, 2015, 03:49:19 AM
Don't I need to start by making a lot of images?

Depends. If your video is 90 minutes long, uncompressed, 24-bits colors at 1080p resolution, then I think you will need 938.5 GB of RAM. So in some cases, pre-rendering would not be recommended. :P

I only have 4 GB of RAM. I do want to make a long video. Is there anyway I can do this with 4 GB of RAM?
http://downloadmoreram.com/


But more seriously, what Cumred said