LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-11-2006, 10:21 PM   #1
fubarbundy
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Rep: Reputation: 0
Unhappy Binary regexp search and replace


Here's a ridiculous question - is there any hex editor for linux that can perform a search and replace based on a regular expression?

I have an impossible-to-get-elsewhere mp3 file that has been 'corrupted' by Macromedia's streaming Flash protocol, so that every fourth frame of the mp3 has one extra byte in the middle of it, which totally wrecks the mp3.

I know what the byte is, but I need to be very specific when I strip it out so that I don't strip out identical legitimate bytes from the wrong location:

[frame header][79/80 bytes][corrupting byte][230 bytes]
[frame header][79/80 bytes][corrupting byte][230 bytes]
[frame header][79/80 bytes][corrupting byte][230 bytes] etc.

I confidently predict that the chance of an answer to this question is nil
 
Old 04-12-2006, 04:12 PM   #2
ioerror
Member
 
Registered: Sep 2005
Location: Old Blighty
Distribution: Slackware, NetBSD
Posts: 536

Rep: Reputation: 34
Well, if the corrupting byte occurs at regular, known intervals (which appears to be what you are saying), you could try dd (with skip and seek) to filter around it.
 
Old 04-15-2006, 07:36 AM   #3
fubarbundy
LQ Newbie
 
Registered: Apr 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ioerror
Well, if the corrupting byte occurs at regular, known intervals (which appears to be what you are saying), you could try dd (with skip and seek) to filter around it.
It doesn't.. I actually found the pattern was a little more complex than that - every so often a frame would have some Flash container bytes on the end, which came in one of three lengths. Depending on the length and sequence of the container bytes, as well as whether the mp3 frame had a padding byte, the Flash container byte in the middle of the frame was in a varying position.

So I ended up writing a custom Perl script that read in the mp3, parsed it a frame at a time, decoded the header and analysed the Flash junk at the end, and then spliced out the middle byte and wrote it out to a file.



If anyone comes across a Flash streamed mp3 and wants my code, let me know.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl Regexp search-n-replace jpbarto Programming 2 06-16-2005 12:45 PM
Keeping part of a regexp in search/replace MadCactus Linux - General 4 09-29-2004 06:31 AM
regexp search for [ wijnands Linux - Newbie 3 06-22-2004 02:15 AM
search and replace C code vexer Programming 3 05-18-2004 11:11 PM
problem in perl replace command with slash (/) in search/replace string ramesh_ps1 Red Hat 4 09-10-2003 01:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:08 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration