Crop mp3 file with ffmpeg which contains album cover - ffmpeg

For cropping mp3 to 30 seconds i use this and it worked well until somebody uploaded mp3 file with album cover
ffmpeg -t 30 -i in.mp3 -acodec copy out.mp3
And now i've got this:
Any suggestions?

Looks like your ffmpeg build does not have the PNG encoder.
Use
ffmpeg -t 30 -i in.mp3 -c:v copy -c:a copy out.mp3

Related

FFMPEG converting MP3 to MP4 is adding blank space, how to fix Terminal command?

I'm creating MP4 files from MP3 files + an image. Searching here at StackOverflow I found a Terminal command that gets me really close:
ffmpeg -loop 1 -r 1 -i pic.jpg -i input.mp3 -c:a copy -shortest -c:v libx264 output.mp4
Works almost perfectly so long as input.mp3 and pic.jpg are in the same folder. The problem is:
It frequently ends up with about 20-40seconds of blank space at the end of the resulting MP4. I can manually chop it off, but I'd love to find out if there's a way to alter this command so that the resulting MP4 file is exactly the length of the input MP3 file.
I don't know the ffmpeg commands well and know just enough Terminal to be dangerous. So I'm hoping it's something obvious haha.
This command should work for you:
ffmpeg -i input.mp3 -loop 1 -i pic.jpg -shortest -c:a copy -c:v mjpeg output.mp4
You do not need to set -r 1 with just one image and -loop 1.
I think -c:v mjpeg is more suitable to encode jpg than -c:v libx264.

Converting a large number of MP3 files to videos for YouTube, each using same the JPEG image

I am looking for a way to convert large number of MP3 files to videos, each using the same image. Efficient processing time is important.
I tried the following:
ffmpeg -i image.jpg -i audio.mp3 -vcodec libx264 video.mp4
VLC media player played the resulting video file with the correct sound, but a blank screen.
Microsoft Media Player played the sound and showed the intended image. I uploaded the video to YouTube and received the message:
"The video has failed to process. Please make sure you are uploading a supported file type."
How can I make this work?
Create video:
ffmpeg -framerate 6 -loop 1 -i input.jpg -c:v libx264 -vf format=yuv420p -t 00:10:00 video.mp4
The duration (-t) should be ≥ the MP3 with the longest duration.
Now stream copy the same video for each MP3:
ffmpeg -i video.mp4 -i audio.mp3 -map 0:v -map 1:a -c copy -movflags +faststart -shortest output.mp4
Some notes regarding compatibility:
MP3 in MP4 does not have universal support, but will be fine in YouTube. If your target players do not like it then add -c:a aac after -c copy to output AAC audio.
If your target player does not like it then increase the -framerate value or add the -r output option with an appropriate value, such as -r 15. Again, YouTube should be able to handle it.

Convert Multiple Audio Tracks of Multiple Files FFmpeg

I'm using a script to convert all video files in a folder. These files have multiple audio tracks and I want the converted files to have each audio track as well. I've tried both -c copy and -c:a mp3 and neither worked for me. Any ideas how I can modify this to copy all audio tracks?
#!/bin/sh
for i in *.mkv; do ffmpeg -i "$i" -c:a mp3 -vcodec libx264 -crf 18 -r 60 "${i%.mkv}.mp4"; done
You can do this by setting -c:a copy. In your example you're attempting to set the audio codec to mp3, which is actually just the container. Hope that helps!
I should amend this... My first thought will simply copy the single, highest-quality audio stream from the input file. To copy all streams we'll want to use the map option1. Your example, copying all audio streams could look like this:
#!/bin/sh
for i in *.mkv; do
ffmpeg -i "$i" -map 0 -c copy -c:v libx264 -crf 18 -r 60 "${i%.mkv}.mp4";
done

ffmpeg audio property is blank in output video

Here's what I have to do,
I want to convert two different images in different video file (ex: convert a.jpg into a.avi and b.jpg into b.avi).
I am trying to generate video (.avi) from image file. Video file is generated successfully but I can't see the audio properties when I right click on video and see details tab in property.
Then I have one video file (.avi), using ffmpeg concat function, I am concating these three video files (a.avi, middle.avi which I already have, b.avi).
After this, I am getting file output.avi but audio is not there in outout.avi file. I have middle.avi which already contains audio.
Here's my concat command,
ffmpeg -i "concat:a.avi|middle.avi|b.avi" -vcodec copy 103_n4_2.avi
I am trying to generate video (.avi) from only one image file. Video file is generated successfully but I can't see the audio properties when I right click on video and see details tab in property.
Here's my command to convert image to video:
ffmpeg -loop 1 -i bCopy.jpg -t 30 -q:v 0 -r 24 output_a.avi
PS: a.avi and b.avi (which I have generated from images does not contain audio) but only middle.avi contains the audio.
I think the audio track is completly ommitted. I was not able to test it but it seams you need to map the audio stream manually to the output and delay it by the the length of your first image.
ffmpeg -i middle.avi -itsoffset 1 -map 1:1 -i "concat:a.avi|middle.avi|b.avi" -map 0:0 -vcodec copy -acodec copy 103_n4_2.avi
Thanks for the help but I have found the solution of this perticular issue,
Here are the steps:
1. Generate blank mp3 of the first slide duration.
- ffmpeg -f lavfi -i aevalsrc=0 -t 31 -q:a 9 -acodec libmp3lame out.mp3
2. Trim audio from middle slide
- ffmpeg -i middle.avi -acodec copy middle.mp3
3. Concat this two audio
- ffmpeg -i "concat:out.mp3|middle.mp3" -acodec copy 103_n4_2.mp3
4. Now concat audio and video(that we've cgenerated by concatenation)
- ffmpeg -i 103_n4_3.avi -i 103_n4_2.mp3 -c:v copy -c:a aac -strict experimental 103_n4_5.avi

JPG join MP3 to FLV

How to convert image and music to video? I would like YouTube video. I like FFMPEG command or other Ubuntu free software. I would like: *.mp3 + *.jpg = *.flv
Here is an example using a recent ffmpeg syntax:
ffmpeg -loop 1 -i image.jpg -i music.mp3 -shortest -c:v libx264 -crf 20 -tune stillimage -c:a copy output.mkv
This example will copy the audio instead of re-encoding to preserve quality. Adjust quality if desired with the CRF option. See the FFmpeg and x264 Encoding Guide for more information.
Super User (another StackExchange site) is a better place for ffmpeg usage questions since Stack Overflow is programming specific.
Today I was in need of merging an image and an audio file into a video file. Since none of the answers that I found on SO worked for me, I'm leaving here what worked for me after trial and error:
ffmpeg -loop 1 -t 205 -i audio.mp3 -i image.jpg -crf 20 test.flv
Where 205 is the duration of the input mp3 file in seconds -> 3:25 minutes.
(Tested with FFmpeg SVN-r13582)

Resources