Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

points for Ark

Posted on 2000-03-11
11
Medium Priority
?
382 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 28

Accepted Solution

by:
Ark earned 160 total points
ID: 2609095
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
ID: 2609112
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 28

Expert Comment

by:Ark
ID: 2609205
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 14

Expert Comment

by:wsh2
ID: 2609231
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 28

Expert Comment

by:Ark
ID: 2609249
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
 
LVL 14

Expert Comment

by:wsh2
ID: 2609797
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
ID: 2610130
Thanks Ark, I thought I did this last night.
0
 
LVL 28

Expert Comment

by:Ark
ID: 2610373
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
ID: 2610504
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 28

Expert Comment

by:Ark
ID: 2610639
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
ID: 2610668
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

916 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