472,377 Members | 1,661 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,377 software developers and data experts.

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 3250
On Jun 15, 7:53*pm, John Salerno <johnj...@gmailNOSPAM.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...@gmailNOSPAM.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...@gmailNOSPAM.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.netcom.comwrote in message
news:1b******************************@earthlink.co m...
On Sun, 15 Jun 2008 22:53:19 -0400, John Salerno
<jo******@gmailNOSPAM.comdeclaimed the following in comp.lang.python:
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.netcom.comwrote in message
news:1b******************************@earthlink.co m...
>On Sun, 15 Jun 2008 22:53:19 -0400, John Salerno
<jo******@gmailNOSPAM.comdeclaimed the following in comp.lang.python:
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...@gmailNOSPAM.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
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",...
3
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,...
4
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...
1
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...
1
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...
2
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...
1
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...
2
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...
1
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
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.