Content-type: text/html
xmpgedit is an MPEG 1 layer 1/2/3, MPEG 2, and MPEG 2.5 audio (mp3) file editor that is capable of processing both Constant Bit Rate (CBR) and Variable Bit Rate (VBR) encoded files. xmpgedit can cut an input MPEG file into one or more output files, as well as join one or more input MPEG files into a single output file. When editing VBR files that have a XING header, xmpgedit updates the output file's XING header information to reflect the new file size and average bit rate.
When editing a file, xmpgedit locates the nearest MPEG frame boundary for the desired start and end times, then copies the frames between these times to the output file. Since no file decoding / encoding occurs during editing, there is no audio quality loss when editing with xmpgedit. For each file being edited, a time index file is created that stores the file position, in bytes, for every 1 second of play time. Indexing guarantees correct and fast random access to edit time offsets for VBR-encoded files.
xmpgedit file playback allows edit-time audio playback auditioning, which insures that desired cut occurs at the correct time offset. This feature is necessary when making edits that demand sub-second accuracy (especially with VBR files). Since most MP3 players display playback run times based on a VBR file's average encoded bit rate, edits based on these players' displayed times can miss the desired start or stop time by many seconds.
xmpgedit resembles an MP3 audio player when started. A toolbar is present at the top of the interface. Below the toolbar is the file edit list. Below the edit window is a playback status area. Below the status area are found two nearly identical audio playback controls.
These playback controls are used to specify edit start and stop times for the currently selected file. The top playback control is used to specify the edit start time, the bottom specify the edit end time. The play button works as expected; playback occurs when clicked in, and stopped when clicked out. The record button can be pressed at any time, either during playback, or after an edit time selection has been changed. By doing so, the time during playback when the record button is pressed, or the specified edit time is recorded in the edit list. The play previous button plays back from 5 seconds before the currently selected edit time, stopping after 5 seconds of material has been played. The default playback control buttons are the play button, the record button, and the play previous button. The pause button, stop button and volume control can be enabled through the File->Options menu.
Edit times are specified using either the scroll bar below the play buttons, or the time spinner buttons to the right of the play buttons. An edit time can also be typed directly into the numeric fields immediately to the left of each spinner button set. These three fields set the edit minute, second and millisecond values respectively.
When using audio playback to test an edit time, that edit time can be adjusted using either the spinner buttons, or the scroll bar. When the time is changed, playback immediately stops. Playback will now start from the newly specified edit time. Using this combination of playback, and edit time modification, searching for the desired edit point is quickly accomplished. Once the desired edit point is found, pressing the record button stores the edit time in the edit list for the highlighted entry. Both a start and end edit time must be selected for each file loaded into the editor.
The tool bar File and Edit menus are also available as popup menus. When the mouse cursor is over a blank area in the playback control area, clicking the right mouse button (a right click) will popup the File menu. A right click anywhere in the edit list area will popup the Edit menu.
Enter the input file name test1.mp3. This can be accomplished by typing the path into the File: name edit line, or by using File->Open File..., or clicking the up arrow. Repeat until there are 4 entries in the edit window for test1.mp3. As a short cut, after the first file is loaded, just press <ENTER> in the file name edit line until 4 entries appear in the editor.
Click on the first line in the edit window.
Specify an end edit time of 6 seconds using the End Time: playback spinner or scroll bar controls. Click the record button.
Click on the second line in the edit window.
Right click in the edit window, and select Copy End Time. The start time is now set to the end time of the first line.
Again use the End Time: edit time controls to now specify an end time of 12 seconds. Now click on the third line in the edit window without first pressing the record buttons. A dialog asking to record the unsaved changes appears. Click OK.
Use Copy End Time to initialize the start edit time. Set the end edit time to 18 seconds. Press the play previous button. The previous 5 seconds of material before the specified edit time is played.
Click the fourth line in the editor. Once again, use Copy End Time to specify the start edit time. Move the end edit time slider to the far right.
Right click in a blank area in the playback controls area, and select Edit. Click OK to commit any unsaved changes. Edit progress bars display as the edits proceed. Because these edits are so short, the progress bars are only displayed briefly.
In the edit list area, right click and select Clear Editor. The editor is now initialized to an empty state.
Select from the main tool bar File->Output File.... Remember that right clicking over a blank area in the playback controls area also brings up the main menu. In the Output file name dialog, select the Join radio button, and enter the output file name test_join, then click OK.
Right click over the playback area, and select Edit. The four files listed in the editor have now been joined together into a single file, named test1_join.mp3. This file is identical to the original test1.mp3 input file.
Example selecting edit times by playback
Start xmpgedit
Load test1.mp3 into the editor.
Push the End Time play button. While the file is playing, push the record button. Notice the end time in the edit list is updated each time the record button is pressed. There is a brief period of silence between 6 and 7 seconds. Practice finding that time using the record button. Test the selected time by playing back the selected edit time using the Play Previous and Play buttons. Use the second and millisecond spinner buttons to refine the candidate end time. The first edit end time should be 6.5 seconds.
Over the edit list Right click and select Copy/Append. Then Right click and select Copy End Time. Using the technique described above, locate the edit end time. The second edit end time is 12.5 seconds.
Again, Right click->Copy/Append and Right click->Copy End Time to create the third edit entry. Locate the third edit end time using the above technique. The third edit end time is at 19 seconds. Verify this is correct by using the Play and Play Previous controls.
Once again, Right click->Copy/Append and Right click->Copy End Time to create the fourth and final edit entry. This time slide the end time scroll bar to the far right, and press the Record button.
Select File->Output file... and specify second_test as the output file name, and press <ENTER>.
Select File->Edit to perform the specified edits.
- /usr/local/etc/gtk-2.0/gtkrc
Add the following entry to these files:
The UNIX mpgedit install script attempts to update the global gtkrc file. However, this will not occur when the location of this file cannot be determined. In this case, the appropriate pixmap_path entry must be added manually.
Note: It is not necessary to add this entry to the $HOME/.xmpgedit-gtkrc file when added to the global gtkrc file.
Sound playback is implemented using two mechanisms: 1) an external command line MP3 player capable of standard input file playback, and 2) the MPGLIB decoder library that ships with the LAME project. The default playback configuration uses the MPGLIB-based decoder plugin libdecoder_mpg123.so.
Two decoder plugin implementations ship with xmpgedit: libdecoder_popen.so and libdecoder_mpg123.so. libdecoder_popen.so will execute the mp3decoder.sh script for file playback. libdecoder_mpg123.so is implemented using the MPGLIB decoder library present in LAME. This implementation also serves as a sample implementation of a single process playback plugin that could be ported to the Microsoft Windows(R) operating systems, and other operating systems that do not support the popen() system call.
xmpgedit attempts to load the playback plugin libmpgedit_decoder.so when file playback is specified. When the decoder plugin is loaded, it is used for file playback. When the decoder plugin cannot be loaded, the default action is to execute the mp3decoder.sh script.
libmpgedit_decoder.so is installed as a symbolic link pointing to one of the playback plugins, libdecoder_mpg123.so or libdecoder_popen.so. make install installs the libdecoder_mpg123.so playback plugin. libdecoder_popen.so can be installed manually when use of a command line MP3 player is desired.
To use a different command line MP3 player, configure libdecoder_popen.so as the playback plugin, then edit the mp3decoder.sh file to call the desired MP3 player. This shell script is then loaded by xmpgedit when performing file playback, and provides the flexibility to specify any MP3 player that can play files from standard input.
While it is possible with xmpgedit to join together files that consist of differing encoding versions (MPEG-1 and MPEG-2, for example) and sample rates (44.1KHz and 22.05KHz, for example), caution must be used. Although such a file is technically a legal encoding, it is doubtful that all (or any, for that matter) MP3 players will be able to correctly render such a file.
Any ID3 tags present in input files are not present in the output from an edit. Output files must be tagged to restore ID3 information.
xmpgedit implements an MPEG audio frame header parser that is tolerant of many encoder errors, corrupted data, and files with formats that are not strictly MPEG audio files. When such an encoding error is encountered, all data between the last correctly encoded frame and the next recognized frame are silently skipped. Other programs, such as mp3_check, perform a more detailed validity check and report where errors occur, and are likely to be more robust when handling corrupted data files.
Using the libdecoder_mpg123.so plugin, mpgedit properly plays all of the ISO MPEG conformance files, as well as MPEG 2/2.5 files encoded using lame. Two exceptions can be noted. Win32 does not properly handle MPEG 2/2.5 files encoded at with a sample rate of 11025Hz/mono. A work around in the libdecoder_mpg123.so decoder plugin is implemented, but the sound quality suffers. The MPEG 1 layer 1 mono test file http://mpgedit.org/mpgedit/testdata/mpeg1/layer1/fl4.mp1 does not render properly. All the data used to exercise mpgedit is located at http://mpgedit.org/mpgedit/testdata/mpegdata.html.
During development, the previous name of the program was mp3edit. The final name mpgedit was settled on after much development occurred. Because of this, many source files and function names are called mp3_. You will also see mpeg_ instead of mpg_ in some cases.
mpgedit is a completely independent implementation from the early mp3_check editing prototype. While some of the early ideas from this prototype still exist in mpgedit, everything has been re-implemented.
Finding reference material sufficiently complete to implement mpgedit was difficult. The O'Reilly & Associates book "MP3: The Definitive Guide" by Scot Hacker http://www.oreilly.com/catalog/mp3/, while accurate in its description of the MPEG audio file frame header structure, did not contain sufficient detail to fully implement the MPEG file parsing functionality. The document that proved invaluable for completing the MPEG audio frame header parsing code was written by Predrag Supurovic, http://www.dv.co.yu/mpgscript/mpeghdr.htm.
The MPGLIB decoding engine comes from the MPG123 package, written by Michael Hipp (www.mpg123.de). MPGLIB is released under the GPL. The version of MPGLIB used for building the libdecoder_mpg123.so decoder plugin comes from the 3.90 alpha 7 version of LAME http://sourceforge.net/projects/lame. Earlier versions of LAME do not include a shared library build of MPGLIB, which is needed when building the decoder plugin. The MPGLIB that comes with mpg123-0.59r can also be used when linking the libdecoder_mpg123.so plugin. However, LAME appears to have fixed some bugs that mpg123 has not.