Converted mp4 h264 baseline format loads long time - ffmpeg

I have converted my video to mp4 x264 baseline format and it works fine with all pc/mobile phones , the problem is it takes long time to load the video while googling came to know that ffmpeg converts and sets the index file at the eof the video so it loads to the end to read and then plays the video, So any advices would be appreciatable to cut short the loading time.
Note:tryied out QT index swapper2 but dint give much difference , please advice .
this is the cmd i used to convert -
ffmpeg -i … -c:v libx264 -profile:v baseline -level 1 …
Thanks for your time .

You have several options to relocate the moov atom so the video can begin playback before it is completely downloaded by the client.
-movflags faststart
The easiest is the option -movflags faststart when re-encoding:
ffmpeg -i input -c:v libx264 -profile:v baseline -movflags faststart output.mp4
If you already encoded your .mp4 file, but simply want to move the atom:
ffmpeg -i input.mp4 -codec copy -movflags faststart output.mp4
You may need to get a more recent ffmpeg version to use this option. See the FFmpeg download page for links to ffmpeg builds for Linux, OS X, and Windows, or you can follow a step-by-step guide to compile ffmpeg.
qt-faststart
Alternatively you can use the qt-faststart tool that comes with the ffmpeg source:
cd ~/ffmpeg/tools
make qt-faststart
./qt-faststart input.mp4 output.mp4
MP4Box
Or you could use MP4Box (usually provided by the gpac package depending on your distro):
MP4Box -add input.mp4 output.mp4
Also See
FFmpeg and x264 Encoding Guide
FFmpeg and AAC Audio Encoding Guide

Related

Fastest way to add -movflags +faststart to an MP4 using FFMPEG, leaving everything else as-is

I want to add -movflags +faststart to an mp4 file. Basically that is all I want to do, nothing else should be changed. I am using ffmpeg.
What's the fastest way to do this? Do I have to re-encode the whole video? Or is there a better/easier way?
As simple as:
ffmpeg -i in.mp4 -c copy -map 0 -movflags +faststart out.mp4
Or if you can compile FFmpeg from source, make the tool qt-faststart in the tools/ directory and run it:
qt-faststart in.mp4 out.mp4
You can also use mp4box, which lets you move the MOOV atom to the start via this command:
mp4box -inter 0 in.mp4 -out out.mp4
Or if you want to fully optimize for streaming by also interleaving the audio/video data so that the file can be easily streamed in realtime:
mp4box -inter 500 in.mp4 -out out.mp4

Playing MP4 file in Powerpoint

I have a huge MP4 file (4GB) an hour long video. I want to extract port of the file. So I used the following command to extract 70 seconds(00:01:10) of video starting from 11 minutes
ffmpeg -i INPUT.mp4 -ss 00:11:00 -t 00:01:10 -c:v copy -c:a copy OUTPUT.mp4
Now I got a small file extracted from Input.MP4
The output.mp4 file size is still big(90 MB). So I used the following command
ffmpeg -i OUTPUT.mp4 -c:v libx264 -crf 30 SmallSizeVideo.avi
I got SmallSizeVideo.avi file which is approximately 6MB.
I am using Powerpoint 2010. I want to insert the video in Powerpoint and play.
Unfortunately when I embed SmallSizeVideo.avi Powerpoint is unable to play
1) Is my approach correct?
2) What is the best way to situation like me to play small portion of clips in powerpoint
Thank you
Last I heard, h.264 in avi was nonstandard. Try instead to output as mp4 and see if that plays in PowerPoint:
ffmpeg -i OUTPUT.mp4 -c:v libx264 -crf 30 SmallSizeVideo.mp4
If it works, I believe it may work in Windows 7 or later and also OS X.
I had the same issue and had to stay for PowerPoint 2010 at Windows 10. Thus, PowerPoint is unable to play MP4, cf. https://support.office.com/en-gb/article/Video-and-audio-file-formats-supported-in-PowerPoint-d8b12450-26db-4c7b-a5c1-593d3418fb59. Finally, I come up with this command:
ffmpeg.exe -i input.mp4 -c:v wmv2 -b:v 12024k -c:a wmav2 -b:a 128k output.wmv
This command based on https://stackoverflow.com/a/34851916/2258393 by Reinhard Behrens.
By means of this command, I am able to archive the same file size and approx. the same quality as with MP4.

How add scale in my ffmpeg command

i want convert video from any format to mp4. so i am using command:
ffmpeg -i ttt.mp4 -vcodec copy -acodec copy test.mp4
this is working perftectly but now i also add scale in this -s 320:240.
There also many other command for convert LIKE :
ffmpeg -i inputfile.avi -s 320x240 outputfile.avi
but after convert by this command video not play in html5 player
BUT this is not working so tell me in my command how i add scale;
So please provide me solution for this .
Thanks in advance.
You have several problems:
In your command, you have -vcodec copy you cannot scale video without reencoding.
In the command you randomly found on the Internet, they are using AVI, which is not HTML5-compatible.
What you should do is:
ffmpeg -i INPUT -s 320x240 -acodec copy OUT.mp4
Adding to Timothy_G:
Video copy will ignore the video filter chain of ffmpeg, so no scaling is available (man ffmpeg is a great source of information that you will not find on Google). Notice that once you start decoding-filtering-encoding (i.e., no copy) the process will be much slower (x100 time slower or even more). The libx264 is recommended if you want compatibility with all browsers.
$ ffmpeg -i INPUT -s 320x240 -threads 4 -c:a copy -c:v libx264 OUT.mp4
vp9 will provide nearly 50% extra bandwidth saving, but only for supported browsers (Firefox/Chrome), and the encoding will much slower compared to libx264 (that itself is much slower that v:c copy):
$ ffmpeg -i INPUT -s 320x240 -c:a copy -c:v vp9 OUT.webm
Notice that there is a set of formats (containers) accepted by browsers (most admit mp4, some also webm, ...) and for each format there is a set of audio/video codecs accepted. For example you can use mp3 or aac with an mp4 file (container), but not with webm files.
http://en.wikipedia.org/wiki/HTML5_video#Supported_video_formats

How to wrap H264 into a mp4 container?

I have a program generating a bunch of raw H264 frames and would like to place that into a mp4 container for streaming.
Anyone know how to do that?
I was thinking I'd use ffmpeg however, this needs to be used commercially and it seems like ffmpeg can only do this through it's x264 library... which uses a GPL license.
Thank you!
If you're looking for the FFMPEG command line to do that, then try the following:
ffmpeg -i "source.h264" -c:v copy -f mp4 "myOutputFile.mp4"
If you have a separate audio file you can add it too:
ffmpeg -i "source.h264" -i "myAudio" -c:v copy -c:a copy -f mp4 "myOutputFile.mp4"
If your audio needs to be encoded as well (for instance codec AAC-LC, bitrate 256kbps):
ffmpeg -i "source.h264" -i "myAudio" -c:v copy -c:a aac -b:a 256k -strict -2 -f mp4 "myOutputFile.mp4"
libmp4v2 is under the MPL and can be used as part of a larger work commercially. It is much lighter than libavformat also.

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