I am using FFMPEG to convert all kind of media files to mp3. Files are being Converted Perfectly.
But files give error MPEG HEADER 30 is missing at 31576bytes. In All converted files I see this. And On Some MP3 Players, It do not play.
Here is my conversion Command what i use
$bitrate = '128k';
$command = "ffmpeg -i /home/musicupl/public_html/musicuploads/SavetoAccount/abc.mp4 -ar 44100 -ac 2 -b:a ".$bitrate." -acodec libmp3lame /home/musicupl/public_html/musicuploads/SavetoAccount/Output.mp3;
Is there any more tag to add MPEG Headers during the conversion. I have researched on this and found the -acodec libmp3lame but still same issue.
Is there any other way or attribute to add in command line.
I am using both commands in my controller, but sometimes they are not working properly.
Sometimes the compressed file size is larger than size of the original file.
exec(FFmpeg -i old.mp3 -ab 64 mp3 newfile.mp3)
And
exec(ffmpeg -i old.mp3 -acodec libmp3lame -ab 48k new.mp3)
Please, help me.
Above both command is different:
Option Description
-ab bitrate : set audio bitrate (in kbit/s)
-acodec codec : force audio codec ('copy' to copy stream)
That's why In the first command set audio stream in 64 bit, and in the second command is do the stream copy to copy.
I hope this helps.
What is best way to convert mkv to mp4, with default subtitle (that mkv have), and keep same quality of video / audio ?
Currently I'm using this command
ffmpeg -y -i filename.mkv -vf subtitles='filename.mkv' -disposition:s default+forced -c:v libx264 -c:a libmp3lame -crf 27 -preset ultrafast filename.mp4
But the command still not perfect, the mkv have better quality than mp4 generated. Any advise?
Thanks
your preset is lowest possible quality, and crf could be lower, 18 is more or less lossless, this will make the transcoding slower. of course
So suggest -crf 18 and -preset slow
If you aren't bothered about which codecs you use you could just copy everything into the mp4 container, which would be megaquick
I'm using FFMPEG to upload videos to my server,
I've tested on 1MB file and another one 5MB and it is working correctly, but then I've tested on 6MB and 50MB file and it try to upload but still with "processing" status with no change.
Here is the code which I use
exec("/usr/local/bin/ffmpeg -i ../uploadedvideo/".$image_name." -ab 56 -ar 44100 -b 200 -r 15 -s 240x180 -fs 314572800 -f flv ../uploadedvideo/".$image_namew.".flv");
What could be the problem?
I am using ffmpeg to convert a 1080p video to MP4 using this command in PHP.
$command = FFMPEG.' -i ' . $src . ' -sameq -strict -2 -vcodec libx264 -ar 22050 -y ' . $dest.'.mp4 2>&1';
exec($command,$output,$status);
The problem is that the process uses a lot of memory ~1600MB, which is not allowed by my server so ffmpeg gets terminated. Can I limit the memory usage of ffmpeg to about 600-700MB?
Any help is greatly appreciated...
It's not about PHP. It's about how to limit FFMPEG memory usage.
Short answer no!
Look here: http://hwdmediashare.co.uk/forum/27-development-customisation/54700-limit-ffmpeg-memory-usage
It would be the video codec which is mainly responsible for the high memory use.
So it's the encoder whose memory use needs to be addressed, not FFmpeg directly. I'm not sure how to fix x264's memory use, but I tried the newer x265 and in my case it's only using 1.6 GB, while libx264 was failing by asking more than the 2 GB memory limit (per process, on 32-bit systems).
So, what worked for me was to use:
ffmpeg -i input -pix_fmt yuv420p -c:v hevc -x265-params crf=23 out.mp4
(Omitting parameters to take care of the audio.)
But the general approach is to try other encoders. I was going to try mpeg4 and vp9 if x265 didn't work, maybe others. If none of that works, then further options include looking at the encoders' settings (though nothing obvious and directly relevant to memory use shows up):
ffmpeg -h encoder=mpeg4
Update: actually, it turned out that YouTube doesn't accept HEVC (aka H.265) yet (and it only let me know after the upload finished). So, like I suggested above, I went for VP9, doing a pilot run with the first 50 frames this time. I used settings similar to a guide I found (the Constant quality settings, though I should have used more of their suggested parameters):
ffmpeg.exe -i <input> -pix_fmt yuv420p -c:v libvpx-vp9 -pass 1 -b:v 0 -crf 20 -f webm pass1.webm
ffmpeg.exe -i <input> -pix_fmt yuv420p -c:v libvpx-vp9 -pass 2 -b:v 0 -crf 20 -f webm pass2.webm
(Note that pass1.webm will be almost empty.)
Also note that two passes are preferred whenever possible. It's better on all fronts, including faster encoding overall.
With these settings, a 73-second clip at 4K resolution took about 16 hours to encode — that's using one core, as I forgot to specify -threads. While slow, FFmpeg's memory use only went up to about 0.6 GB. The resulting file was 300 MB, and I can't see any loss of quality compared to uncompressed frames (so -crf 20 might have been a bit too low).
The truth is video encoding a CPU and memory intensive job. If you want to do it you need to give the requisite memory for it.
Since you want to convert a 1080p .mov to a .mp4 of same quality I am assuming you jsut want to change the format of the file and not reencode.
ffmpeg -i input.mov -acodec copy -vcodec copy out.mp4
will do it in a jiffy and without any of the memory overheads
If you want your audio codec only changed don't give the acodec part.
If the input video codec does not work for you [so copy is not an option] try doing mpeg4 encoding for vcodec. Cheaper to encode there but I cannot assure you it will fit in your memory requirements always.