Solved

points for Ark

Posted on 2000-03-11
11
368 Views
Last Modified: 2010-05-18
Hey Ark, do you know off the top of your head how to join two or more mpegs into a new longer one. I want to build a program to join two or more mpegs together. Actually, I don't have enough points to ask this question, so if you know the answer, tell me when would be a good time to ask it and I will try to get some more points through referals or something.
0
Comment
Question by:Ginger16
  • 5
  • 4
  • 2
11 Comments
 
LVL 27

Accepted Solution

by:
Ark earned 40 total points
Comment Utility
Hi
Sorry, I've never worked with mpegs.
If you need this 40 points to ask other experts - you can delete this question and give me points next time, when you'll have more. I'll try to learn something about mpegs. What control or Api function do you use to play mpegs?
Regards
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Hello Ark.. welcome back from International Woman's day !!! <hic>.. LOL.

Ok Ginger16.. MP3s.. <smile>.

An MPEG audio file is built up from smaller parts called frames. Generally, frames are independent items with each frame having its own header and audio information. The one frame exception to this is the MP3 Tag which (when present) occupies the last 128 bytes of the file.

To test if the TAG Frame is present, read the last 128 bytes of the file, and in the first three characters of what you read, test for "TAG".

If you remove the TAG at the end of MP3 File1, you can then merge MP3 File2 right up against it, and you will find that they play contiguously.. <smile>.

Now.. here is where a problem comes in.. What if there is dead sound at the end of File1 and/or the beginning of File2.. and you want to edit it out? Working directly with the MP3 is NOT easy to do.. as you have to read through the file frame by frame.. keep track of where you are.. and then cut on frame boundaries.. <groan>. As I do not know how technical you are, I will reserve further discussion on that topic.

Actually, there IS another way to skin this cat.. assuming you have a WAV file editor program (most sound cards ship with one). Using Winamp.. right mouse click on the WinAmp title bar.. then Options.. Preferences.. Plug-Ins and then Output. Once there change the output Plug-In to OUT_DISK and set the Directory you wish to use for WAV output. Return to the Winamp console, and now everything you play will go to your disk as a WAV file in the directory you specified. (NOTE: Make sure that when you are done creating your WAV files that you go back and change your Output plug-in back to OUT_WAVE so that you can hear your music again). Using your WAV file editor, you can pretty much do whatever you want with the file.. Merge.. Cut.. Copy.. Paste.. etc.

Now for the final step.. taking the new WAV and compressing it back once again into MP3 format. For this you need a MP3 encoder. The one I like to use is Blade Encoder and can be downloaded from this site:

http://home8.swipnet.se/~w-82625/

An excellent frontend shell for Blade Encoder that really simplifies the MP3 encoding process is Blade Helper.. I strongly recommend that as well. You can get Blade Helper at:

http://nt.eye-catcher.com/sanderson/

Welp datz it for now.. Ark?... Welcome home.. <smile>

B.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
wsh2: glad to meet you! BTW, I'm not at home, I'm working. Holydays finished and now I've to work at weekend :-). To my shame, I don't know mpeg format as good as you, so can not take part in discussion
Ginger16: If wsh2 help you, you can give this points to him
Cheers
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Oh but Ark.. I think you would look great in a new T-Shirt.. <lol>.. Ginger16.. please.. the points stay with Ark.. I am only too happy to help a working stiff out.. <smile>.

B.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
wsh2: T-Shirt? It's a joke? It's -10C degrees today. In Russia is still winter :-).
Ginger16: I've found the same question at vb-world forum, from 03.03.2000, but it's still without answer. As for wsh2's mpeg format description - it's not hard to cut last 128 bytes from file in VB code. I'll do it tomorrow (it's too late today)

Cheers
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Hi Ark..

Nope.. No Joke.. Accumulate 5000 Expert Points here.. and they will send you a Free ExpertExchange T-Shirt.. <smile>.
0
 

Author Comment

by:Ginger16
Comment Utility
Thanks Ark, I thought I did this last night.
0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
Ginger16: what mpeg format do you want to merge? MP3, mpg? If you have some not very big files, please send them to me ark@fesma.ru. I'll check format and try to merge them programmatically.
wsh2 (if you're still here): I didn't know about T-Shirt. I see, you already have one. BTW, where are you from? I thing they wouldn't send t-shirt so far in Russia.
0
 

Author Comment

by:Ginger16
Comment Utility
mpeg video files. I wanted to make a simple video editor. I have seen shareware versions where you can put files in a list, and it will make them into a longer one. It seemed liked it wouldn't be that hard, but I guess I was wrong. I thought it would work like opening a file for append. I tried using this code off the net, but it didn't work. I thought Iit just needed some tweaking, guess not. I referred a friend and got some more points and will probably post this question on the board. Here is what I thought would work, but no.
Private Sub Command1_Click()
 Call JoinFiles("D:\mpeg join\somempeg.mpeg", _
    "D:\mpeg join\someother.mpeg", _
    "D:\mpeg join\new.mpeg")
    End
End Sub




Public Sub JoinFiles(Source1, Source2, Dest)

   'Author: -Russell Davis, Garden Grove, California
    Dim Buffer() As Byte
    Open Source1 For Binary Access Read As #1
    Open Source2 For Binary Access Read As #2
    Open Dest For Binary Access Write As #3
    ReDim Buffer(1 To LOF(1))
    Get #1, , Buffer
    Put #3, , Buffer
    ReDim Buffer(1 To LOF(1))
    Get #2, , Buffer
    Put #3, , Buffer
    Close #1, #2, #3
End Sub


0
 
LVL 27

Expert Comment

by:Ark
Comment Utility
Hi
You can take a look at my own code at http://www.freevbcode.com/ShowCode.Asp?ID=910 for join any number of files into one. But for concatenate mpeg files into one you need to remove last 128 bytes from each file, following after word TAG (as wsh2 said). Now I haven't any mpeg video files at my computer. Of course, I can find them at the INet, but if you have them and they are not a big size, you can post them to me by e-mail for I can experiment with them.

Cheers
0
 
LVL 14

Expert Comment

by:wsh2
Comment Utility
Video?... Oh G.. sorry can only help you with Audio (MP3). As the MPEG file layout is copyrighted, it is not to easy to find file layout info.. but, if you are diligent.. I am certain you can find it on the net somewhere.. <smile>.

The heart of what you are looking for is the Frame Header layout. In the header, you will find flags that can then be used to calculate what the frame length is. Armed with that you can then read (copy) frame by frame.

The only annoyance in dealing with the frame header is that it is packed tight.. its fields are bit aligned.. rather than byte (character) as we are accustomed. For example, the Frame header identifier (also called synch), is demarked by the first 11 bits all being on. In byte terms, that equates to 1-3/8 bytes.. the first character all 1s (11111111) overflowing into the first 3 high order bits.

Gawd.. <yawn>.. this techie schtuff is fun, huh? Anyhow.. long story short.. what you need is the Mpeg Audio Frame Header layout, and the empiricism on how to calculate a Frame length from that. After getting that.. the rest is easy.. <huge smile>.

And Thank You for remembering our Ark.. at -10Centigrade where he lives.. he needs the points to burn for heat.. LOL.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now