join 2 mp3 file with overlay at end
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Hy,i using function joinmp3.php to join 2 mp3 songs. It works perfectly but I want song 2 to start from last 3 seconds from first song.
How i can to do it?
Thanks for help!
Sorry for my bad english,i'm from Romania!
How i can to do it?
Thanks for help!
Sorry for my bad english,i'm from Romania!
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
You'd have to figure out using the average bitrate of the first file how many bytes from the end 3 seconds is equal to (e.g. 192kbps = 192000 [kilobits-per-second] / 8 [bits-per-byte] * 3 [seconds] = 72000 bytes) and start your copy from there.
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
How to implement this in the function?
I can't figure out how,i'm use file with 192 kbps.
I do not know ID3 to well,thanks alot for help! ;)
I can't figure out how,i'm use file with 192 kbps.
I do not know ID3 to well,thanks alot for help! ;)
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
I have made some changes to demo.joinmp3.php so it should now be able to do what you want.
changes: https://github.com/JamesHeinrich/getID3 ... 26d3e1f64f
If you want to copy the last 3 seconds of the first file plus all of the second file:
The new function format accepts for the second parameters ($FilenamesIn) an array where each element can either be a plain filename, or an array where the first element is the filename, (optional) second element is the start offset in seconds, (optional) third element is the length in seconds to copy. If start offset and/or length elements are omitted they are assumed to be zero (start from beginning of file; copy entire file). Negative values are acceptable: negative start offset means start X seconds from end of file rather than beginning of file; negative length means stop X seconds from end of file.
Start Offset: (0) = start of file; (>0) = start X seconds from beginning of file; (<0) = start X seconds from end of file
Copy Length: (0) = copy to end of file; (>0) = copy X seconds from Start Offset; (<0) = copy from Start Offset up to X seconds from end of file.
changes: https://github.com/JamesHeinrich/getID3 ... 26d3e1f64f
If you want to copy the last 3 seconds of the first file plus all of the second file:
Code: Select all
$FilenameOut = 'output.mp3';
$FilenamesIn[] = array('one.mp3', -3, 0); // extract last 3 seconds of audio
$FilenamesIn[] = array('two.mp3', 0, 0); // copy everything
CombineMultipleMP3sTo($FilenameOut, $FilenamesIn);
Start Offset: (0) = start of file; (>0) = start X seconds from beginning of file; (<0) = start X seconds from end of file
Copy Length: (0) = copy to end of file; (>0) = copy X seconds from Start Offset; (<0) = copy from Start Offset up to X seconds from end of file.
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
I will try this,thank you alot, I appreciate your help! :D
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
It's very good function but I want to overlap their final 3 seconds not cut them,it's possible?
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
No. That would require decoding the audio, mixing it, and (optionally) re-encoding it to mp3.
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
Okay,thanks for help!
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
I am trying to cut single file, when i cut from beginning is working well, but when i try to cut from the end nothing happening, size of mp3 file is changing but the duration remaining same
Code: Select all
$FilenamesIn[] = array('test.mp3', 10, 0); /// working
$FilenamesIn[] = array('test.mp3', 0, -10); /// NOT working
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
Are you sure the duration is remaining the same? If the filesize is smaller, very likely the audio is in fact shorter but since the header frame is left intact a quick examination of the mp3 file will simply report the originally-encoded duration from the VBR header. Try playing the last 10 seconds and see if they're actually in the file or not.
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
Original file:
http://b13.biz/test.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 9175248
[filepath] => /home/etc/b13.biz
[filename] => test.mp3
[filenamepath] => /home/etc/b13.biz/test.mp3
[avdataoffset] => 175165
[avdataend] => 9175120
[fileformat] => mp3
[playtime_seconds] => 224.998875
[playtime_string] => 3:45
when i use $FilenamesIn[] = array('test.mp3', 0, -10);:
http://b13.biz/testCUT.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 8999955
[filepath] => /home/etc/b13.biz
[filename] => testCUT.mp3
[filenamepath] => /home/etc/b13.biz/testCUT.mp3
[avdataoffset] => 0
[avdataend] => 8999955
[fileformat] => mp3
[playtime_seconds] => 224.998875
[playtime_string] => 3:45
and when i use $FilenamesIn[] = array('test.mp3', 10, 0);:
http://b13.biz/testCUT1.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 8599955
[filepath] => /home/etc/b13.biz
[filename] => testCUT1.mp3
[filenamepath] => /home/etc/b13.biz/testCUT1.mp3
[avdataoffset] => 320
[avdataend] => 8599955
[fileformat] => mp3
[playtime_seconds] => 214.990875
[playtime_string] => 3:35
the last 10 seconds is there, i play it
http://b13.biz/test.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 9175248
[filepath] => /home/etc/b13.biz
[filename] => test.mp3
[filenamepath] => /home/etc/b13.biz/test.mp3
[avdataoffset] => 175165
[avdataend] => 9175120
[fileformat] => mp3
[playtime_seconds] => 224.998875
[playtime_string] => 3:45
when i use $FilenamesIn[] = array('test.mp3', 0, -10);:
http://b13.biz/testCUT.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 8999955
[filepath] => /home/etc/b13.biz
[filename] => testCUT.mp3
[filenamepath] => /home/etc/b13.biz/testCUT.mp3
[avdataoffset] => 0
[avdataend] => 8999955
[fileformat] => mp3
[playtime_seconds] => 224.998875
[playtime_string] => 3:45
and when i use $FilenamesIn[] = array('test.mp3', 10, 0);:
http://b13.biz/testCUT1.mp3
[GETID3_VERSION] => 1.9.12-201602240818
[filesize] => 8599955
[filepath] => /home/etc/b13.biz
[filename] => testCUT1.mp3
[filenamepath] => /home/etc/b13.biz/testCUT1.mp3
[avdataoffset] => 320
[avdataend] => 8599955
[fileformat] => mp3
[playtime_seconds] => 214.990875
[playtime_string] => 3:35
the last 10 seconds is there, i play it
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
testCUT.mp3 is 8999955 bytes from position 175165 in the original file to the end (minus ID3v1)
testCUT1.mp3 is 8599955 bytes from position 575165 in the original file to the end (minus ID3v1)
Before I go chasing any further, I see you're running a 2.5-year-old version of getID3, please update to the current version and try again. If the problem still exists I will look further.
testCUT1.mp3 is 8599955 bytes from position 575165 in the original file to the end (minus ID3v1)
Before I go chasing any further, I see you're running a 2.5-year-old version of getID3, please update to the current version and try again. If the problem still exists I will look further.
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
I maked the test again with curent version of getID3 and demo.joinmp3.php with another mp3 file with empty tags and the results are the same,i tested with PHP 5.6 and PHP 7.2
Original file:
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6752130
[filepath] => /home/etc/b13.biz
[filename] => test.mp3
[filenamepath] => /home/etc/b13.biz/test.mp3
[avdataoffset] => 0
[avdataend] => 6752130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 2
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] => MS
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 41822
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 168.80325
[bitrate] => 320000
[playtime_string] => 2:49
)
Cut fom beginning with $FilenamesIn[] = array('test.mp3', 10, 0);:
WORKING
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6352130
[filepath] => /home/etc/b13.biz
[filename] => testCUT.mp3
[filenamepath] => /home/etc/b13.biz/testCUT.mp3
[avdataoffset] => 196
[avdataend] => 6352130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[warning] => Array
(
[0] => Unknown data before synch (should be at beginning of file, synch detected at 196)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 0
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] =>
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 22828
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 158.79835
[bitrate] => 320000
[playtime_string] => 2:39
)
and cut from the end with $FilenamesIn[] = array('test.mp3', 0, -10);:
NOT WORKING
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6752130
[filepath] => /home/etc/b13.biz
[filename] => testCUT1.mp3
[filenamepath] => /home/etc/b13.biz/testCUT1.mp3
[avdataoffset] => 0
[avdataend] => 6752130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 2
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] => MS
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 41822
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 168.80325
[bitrate] => 320000
[playtime_string] => 2:49
)
nothing changes, the file remaining at same like original, cutting from the end is not working
Original file:
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6752130
[filepath] => /home/etc/b13.biz
[filename] => test.mp3
[filenamepath] => /home/etc/b13.biz/test.mp3
[avdataoffset] => 0
[avdataend] => 6752130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 2
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] => MS
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 41822
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 168.80325
[bitrate] => 320000
[playtime_string] => 2:49
)
Cut fom beginning with $FilenamesIn[] = array('test.mp3', 10, 0);:
WORKING
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6352130
[filepath] => /home/etc/b13.biz
[filename] => testCUT.mp3
[filenamepath] => /home/etc/b13.biz/testCUT.mp3
[avdataoffset] => 196
[avdataend] => 6352130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[warning] => Array
(
[0] => Unknown data before synch (should be at beginning of file, synch detected at 196)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 0
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] =>
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 22828
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 158.79835
[bitrate] => 320000
[playtime_string] => 2:39
)
and cut from the end with $FilenamesIn[] = array('test.mp3', 0, -10);:
NOT WORKING
Array
(
[GETID3_VERSION] => 1.9.15-201806201619
[filesize] => 6752130
[filepath] => /home/etc/b13.biz
[filename] => testCUT1.mp3
[filenamepath] => /home/etc/b13.biz/testCUT1.mp3
[avdataoffset] => 0
[avdataend] => 6752130
[fileformat] => mp3
[audio] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
[streams] => Array
(
[0] => Array
(
[dataformat] => mp3
[channels] => 2
[sample_rate] => 44100
[bitrate] => 320000
[channelmode] => joint stereo
[bitrate_mode] => cbr
[lossless] =>
[encoder_options] => CBR320
[compression_ratio] => 0.22675736961451
)
)
)
[encoding] => UTF-8
[mime_type] => audio/mpeg
[mpeg] => Array
(
[audio] => Array
(
[raw] => Array
(
[synch] => 4094
[version] => 3
[layer] => 1
[protection] => 0
[bitrate] => 14
[sample_rate] => 0
[padding] => 0
[private] => 0
[channelmode] => 1
[modeextension] => 2
[copyright] => 1
[original] => 1
[emphasis] => 0
)
[version] => 1
[layer] => 3
[channelmode] => joint stereo
[channels] => 2
[sample_rate] => 44100
[protection] => 1
[private] =>
[modeextension] => MS
[copyright] => 1
[original] => 1
[emphasis] => none
[crc] => 41822
[padding] =>
[bitrate] => 320000
[framelength] => 1044
[bitrate_mode] => cbr
)
)
[playtime_seconds] => 168.80325
[bitrate] => 320000
[playtime_string] => 2:49
)
nothing changes, the file remaining at same like original, cutting from the end is not working
-
- getID3() v1 developer
- Posts:1477
- Joined:Fri May 04, 2001 4:00 pm
- Are you a spambot?:no
- Location:Northern Ontario, Canada
- Contact:
Re: join 2 mp3 file with overlay at end
Should be fixed now, wrong variable was used on line 86.
https://github.com/JamesHeinrich/getID3 ... aad0838832
https://github.com/JamesHeinrich/getID3 ... aad0838832
-
- User
- Posts:9
- Joined:Sat Oct 10, 2015 8:12 pm
- Are you a spambot?:no
- Location:Germany
- Contact:
Re: join 2 mp3 file with overlay at end
Great, now works perfectly!