Crop MP3 to first 30 seconds

后端 未结 8 2094
南方客
南方客 2020-11-28 18:39

Original Question

I want to be able to generate a new (fully valid) MP3 file from an existing MP3 file to be used as a preview -- try-before-you-buy

相关标签:
8条回答
  • 2020-11-28 18:53

    I have got an error while doing the same

    Invalid audio stream. Exactly one MP3 audio stream is required.
    Could not write header for output file #0 (incorrect codec parameters     ?): Invalid argumentStream mapping:
    

    Fix for me was:

    ffmpeg -ss 00:02:43.00 -t 00:00:10 -i input.mp3 -codec:a libmp3lame out.mp3
    
    0 讨论(0)
  • 2020-11-28 19:00

    I also recommend ffmpeg, but the command line suggested by John Boker has an unintended side effect: it re-encodes the file to the default bitrate (which is 64 kb/s in the version I have here at least). This might give your customers a false impression of the quality of your sound files, and it also takes longer to do.

    Here's a command line that will slice to 30 seconds without transcoding:

    ffmpeg -t 30 -i inputfile.mp3 -acodec copy outputfile.mp3
    

    The -acodec switch tells ffmpeg to use the special "copy" codec which does not transcode. It is lightning fast.

    NOTE: the command was updated based on comment from Oben Sonne

    0 讨论(0)
  • 2020-11-28 19:05

    You might want to try Mp3Splt.

    I've used it before in a C# service that simply wrapped the mp3splt.exe win32 process. I assume something similar could be done in your Linux/PHP scenario.

    0 讨论(0)
  • 2020-11-28 19:06

    you can use mp3cut:

    cutmp3 -i foo.mp3 -O 30s.mp3 -a 0:00.0 -b 0:30.0
    

    It's in ubuntu repo, so just: sudo apt-get install cutmp3.

    0 讨论(0)
  • 2020-11-28 19:08

    try:

    ffmpeg -t 30 -i inputfile.mp3 outputfile.mp3
    
    0 讨论(0)
  • 2020-11-28 19:11

    If you wish to REMOVE the first 30 seconds (and keep the remainder) then use this:

    ffmpeg -ss 30 -i inputfile.mp3 -acodec copy outputfile.mp3
    
    0 讨论(0)
提交回复
热议问题