473,785 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Combining music or video files?

Before I try this and destroy my computer :) I just wanted to see if
this would even work at all. Is it possible to read a binary file such
as an mp3 or an avi, put its contents into a new file, then read another
such file and append its contents to this same new file as well, thereby
making, for example, a single long video instead of two smaller ones?

Thanks.
Jun 27 '08 #1
6 3367
On Jun 15, 7:53*pm, John Salerno <johnj...@gmail NOSPAM.comwrote :
Before I try this and destroy my computer :) I just wanted to see if
this would even work at all. Is it possible to read a binary file such
as an mp3 or an avi, put its contents into a new file, then read another
such file and append its contents to this same new file as well, thereby
making, for example, a single long video instead of two smaller ones?

Thanks.
This works with basic mpeg videos, but pretty much nothing else.
You're going to need some video editing software.
Jun 27 '08 #2
On Sun, Jun 15, 2008 at 11:55 PM, Jason Scheirer
<ja************ @gmail.comwrote :
On Jun 15, 7:53 pm, John Salerno <johnj...@gmail NOSPAM.comwrote :
>Before I try this and destroy my computer :) I just wanted to see if
this would even work at all. Is it possible to read a binary file such
as an mp3 or an avi, put its contents into a new file, then read another
such file and append its contents to this same new file as well, thereby
making, for example, a single long video instead of two smaller ones?

Thanks.

This works with basic mpeg videos, but pretty much nothing else.
You're going to need some video editing software.
--
http://mail.python.org/mailman/listinfo/python-list
I actually don't know what would happen if you concatenated even MP3s
with the ID3 tags that are stored at the end... I know with some DivX
files at least you could approximate this by running a separate
program on them that would recreate whatever index it needed. (At
least, you could recreate the index for files that cut off early, I
guess it could figure out what to do if it found a second index
halfway through the file.)
Jun 27 '08 #3

On 16 jun 2008, at 05:55, Jason Scheirer wrote:
On Jun 15, 7:53 pm, John Salerno <johnj...@gmail NOSPAM.comwrote :
>Before I try this and destroy my computer :) I just wanted to see if
this would even work at all. Is it possible to read a binary file
such
as an mp3 or an avi, put its contents into a new file, then read
another
such file and append its contents to this same new file as well,
thereby
making, for example, a single long video instead of two smaller ones?

Thanks.

This works with basic mpeg videos, but pretty much nothing else.
You're going to need some video editing software.
you can't just edit mpeg (including mp3)...
mpeg is a stream. it sets a "key" frame for the first frame
followed by motion vectors from the changes from that frame
until the next keyframe.
If you cut in the middle of the vectors the keyframe is lost
and the vector frames don;t make any sense anymore.

avi is not a video codec, it's a container like quicktime.
so it depends...

I come from a Mac background and use quicktime a lot.
there are some basic editing features that quicktime can do.
And Apple has a nice quicktime python module in OSX.
I bet there's something for windows too...

best thing to do is convert the video o a framesequence and
the audio to an uncompressed format like wav or aiff
then combine in quicktime or <something in windows>

cheers,
Arno


Jun 27 '08 #4
"Dennis Lee Bieber" <wl*****@ix.net com.comwrote in message
news:1b******** *************** *******@earthli nk.com...
On Sun, 15 Jun 2008 22:53:19 -0400, John Salerno
<jo******@gmail NOSPAM.comdecla imed the following in comp.lang.pytho n:
Even the simplest format -WAV, which is normally uncompressed
audio samples, is wrapped in layers of informational packets.

snip other stuff!!!
Yikes! Then what I'm reading from your post (and others) is no, I can't do
it my way. ;) It *did* seem a little too easy, after all!
Jun 27 '08 #5
John Salerno wrote:
"Dennis Lee Bieber" <wl*****@ix.net com.comwrote in message
news:1b******** *************** *******@earthli nk.com...
>On Sun, 15 Jun 2008 22:53:19 -0400, John Salerno
<jo******@gmai lNOSPAM.comdecl aimed the following in comp.lang.pytho n:
Even the simplest format -WAV, which is normally uncompressed
audio samples, is wrapped in layers of informational packets.

snip other stuff!!!

Yikes! Then what I'm reading from your post (and others) is no, I can't do
it my way. ;) It *did* seem a little too easy, after all!

I can't speak for video (and I'd imagine it's a factor more difficult)
but it's really not that hard to concatenate audio in python. What you
need to do...

Import the right modules for the audio formats you want to read.
Decide on a master output format, say CD quality - PCM 16bit 44.1Khz Stereo.
Open a file for appending
Read through each of your source files loading them into memory
Get the sample rate and format
Run the sample data through a function to convert it to the master
output format*
Squirt it to disk

Finally take the resulting file, calculate a new header and munge the
two together. Voila :)
*I'm sure several modules have functions/methods for this but it
wouldn't be very hard to roll your own either.
Roger Heathcote

http://www.technicalbloke.com
Jun 27 '08 #6
On 16 Jun, 04:53, John Salerno <johnj...@gmail NOSPAM.comwrote :
Before I try this and destroy my computer :) I just wanted to see if
this would even work at all. Is it possible to read a binary file such
as an mp3 or an avi, put its contents into a new file, then read another
such file and append its contents to this same new file as well, thereby
making, for example, a single long video instead of two smaller ones?
Probably not, as people have pointed out, but I imagine you could use
GStreamer and a few processing pipelines, as I pointed out in a
comment on the following article (for another task):

http://jessenoller.com/2008/05/06/la...ion-libraries/

This is probably as close as you can get to treating the files as if
they were simple things which can be concatenated.

Paul
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
16145
by: Marian Aldenhövel | last post by:
Hi, I am trying to make pygame play music on windows. This simple program: import pygame,time pygame.init() print "Mixer settings", pygame.mixer.get_init() print "Mixer channels", pygame.mixer.get_num_channels() pygame.mixer.music.set_volume(1.0) pygame.mixer.music.load('file1.mp3)
3
2263
by: rangermccoy | last post by:
Hello there, What are the best php/c libraries for handling media including images, video, and music? I would like to manipulate media dfiles, including watermarking, thumbnailing, truncating, etc. I know there's the GD llibrary for images.
4
3885
by: Doug van Vianen | last post by:
Hi, I am using Visual Basic 6 to generate web pages that can be used by the members of our seniors' computer club to create e-cards that include their own pictures. I wish to include background music. The music plays okay until the viewer clicks to cause some JavaScript code to execute. When the JavaScript code runs it stops the music even though the coding is just used to resize pictures and divs on the page (viz, it is not supposed...
1
2544
by: Blackeyes24 | last post by:
My sister has asked me if there is a way to mute the volume on a music video she has embeded in her myspace page. She wants the video because of the people in it but not the song. Is this possible? Here is the code she is using" <div><embed allowScriptAccess="never" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" src="http://www.pcplanets.com/asx/33779.asx" showstatusbar="1" autostart="1"...
1
3313
by: majestik | last post by:
Question, can I see an event in Javascript that tells me a video starts playing using the <embed src="file.wmv>. I stream the video, but there is a wait time and wanted to pop up a message telling the user it is buffering until the video actually begins to play in the browser. Thanks for any help! JJ
2
7892
by: hzgt9b | last post by:
Using VS2003, VB.NET, BACKGROUND I have a window forms based application that will be distributed and executed directly from CD media. The app contains a TreeView control and a WebBroswer (AxSHDocVw.AxWebBrowse) control. The TreeView is populated with nodes that when clicked play an audio clip that is stored on the CD and navigate the browser control to a specified web URL (also stored on the CD). All the web URLs are html documents...
1
1948
by: JustThisOneQuestion | last post by:
Hi all. With iTunes 7 (Windows XP), if repeat is selected and a music video is next in the same playlist, the current song finishes but does not switch to the next one automatically... it just sits on 'play' with 0 seconds remaining. Manually pressing play works fine. Have tried to get around this using setTimeout, but having NO experience in JScript means getting this ready in time has been a pain in the rump. Have been trying to get it to...
2
3928
by: FlashForumKB | last post by:
Here is a chance for you to make my developers look bad. I have hired these guys to development my website which, in part, has music demos available to my users. These demos must include the entire piece with a spoiler in the background so users can not record them freely. The files must be secure! My original request was to have them build an application that merged the two files (spoiler and original music) into a single mp3 file and have...
1
2808
by: David Buckley | last post by:
Does anyone have any example code of converting any type of video to flash video at all using asp.net 2.0 c# web applications. God Bless
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10087
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7496
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5380
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.