You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

How to create a compatible mp4 with ffmpeg ? Created Sep 3, 2009

This thread is solved

Views: 19220     Replies: 22     Last reply Nov 21, 2011  
You must login first before you can use this feature

davidstoll

Posts: 8

Registered:
Jul 26, 2009

How to create a compatible mp4 with ffmpeg ?

Posted: Sep 3, 2009

I'm capturing a stream with ffmpeg to mp4 and the resulting mp4 does not seem to be compatible with flowplayer. I was wondering what it would take to create an mp4 with ffmpeg to be able to psudostream?

I can stream flv's without any problem.

Here is my ffmpeg capture command.
ffmpegx -i /dev/video0 -vcodec copy -acodec copy -t 30 test.mp4

The resulting file has these attributes...

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
Duration: 01:00:23.01, start: 0.000000, bitrate: 6639 kb/s
Stream #0.0(und): Video: h264, yuv420p, 1280x720, 59.94 tbr, 120k tbn, 240k tbc
Stream #0.1(eng): Audio: aac, 48000 Hz, stereo, s16

Thanks!

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» How to create a compatible mp4 with ffmpeg ?

Posted: Sep 3, 2009

Reply to: How to create a compatible mp4 with ffmpeg ?, from davidstoll
Research 'moov atom' and 'qstart'

Like most converters FFmpeg does not place the moov atom (it's metadata) from the usual end of the file to the beginning. If this is not done the entire file has to be loaded into memory before playback begins. This is the way it works with all Flash video players.

davidstoll

Posts: 8

Registered:
Jul 26, 2009

» » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 3, 2009

Reply to: » How to create a compatible mp4 with ffmpeg ?, from gmccomb
Ok, so this is similar to what I have to do to get my flv files working. I used "flvtool2 -U input.flv" to correctly inject the meta data into my flv files.

I see a c utility "qt-faststart.c" that supposedly does header re-aranging, but it has to create a new file. This causes a problem for me with my scripts (and mythtv).

flvtool2 injects it right into the same flv file. Any ideas if there is a similar utility for mp4?

Thanks for the info!

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 3, 2009

Reply to: » » How to create a compatible mp4 with ffmpeg ?, from davidstoll
The only other atom moving tool I've used is mp4box, but I don't know it creates a file in place or not on all platforms. However, from the looks of the command-line it appears it uses the same file *name* for input and output.

FWIW, flvtool2 does not insert the data into the same file. It loads the entire file into memory, and writes it back out using the same filename.

davidstoll

Posts: 8

Registered:
Jul 26, 2009

» » » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 4, 2009

Reply to: » » » How to create a compatible mp4 with ffmpeg ?, from gmccomb
Any idea how to apt-get mp4box? I'm kind of a n00b when it comes to installing from source.

Or is there a deb package that I can simply download?

Thanks

davidstoll

Posts: 8

Registered:
Jul 26, 2009

» » » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 4, 2009

Reply to: » » » How to create a compatible mp4 with ffmpeg ?, from gmccomb
Actually, I found a friend to help me install it. It looks like MP4Box does NOT create another file....which is good for me.

However, I can't tell if I have the correct commands to put the meta data in the correct spot (or remade) to work with flowplayer. Any suggestions?

Thanks again!

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 4, 2009

Reply to: » » » » How to create a compatible mp4 with ffmpeg ?, from davidstoll
If it works, it works. Whatever settings are generally applied to any Flash video player running MP4 videos will also apply to Flowplayer, as Flowplayer uses the Flash platform to actually play back the videos.

davidstoll

Posts: 8

Registered:
Jul 26, 2009

» » » » » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 4, 2009

Reply to: » » » » » How to create a compatible mp4 with ffmpeg ?, from gmccomb
MP4Box -inter 0 input.mp4
or
qt-faststart input.mp4 output.mp4

For MP4Box an -inter of 0...i.e. (Specifying a 0 interleaving time) will result in the file being stored without interleaving, with all meta-data placed at beginning of the file.

Both seem to move the moov data to the front of the file. qt-faststart makes a new file, MP4Box seems to just re-create the file.

MP4Box also tells you if the data has already been moved. i.e. if you've already process it with qt-faststart or MP4Box previously, MP4Box says it can't find moov data at the end, therefore you can assume it's already been moved.

Ok, so even with the data moved to the beginning of the file, the MP4 does not seem to startup faster or pseudostream better as opposed to leaving the data where it was originally.

So, I'm not sure I understand why flowplayer is still having problems with mp4's.

gmccomb

Posts: 746

Registered:
Apr 9, 2009

» » » » » » » How to create a compatible mp4 with ffmpeg ?

Posted: Sep 4, 2009

Reply to: » » » » » » How to create a compatible mp4 with ffmpeg ?, from davidstoll
> So, I'm not sure I understand why flowplayer is
> still having problems with mp4's

It doesn't. There are plenty of example posts by people doing MP4s, and there's a whole how-to on how here to use FFmpeg to achieve high-quality MP4s.

Start with the tutorial and work your way back.

http://www.flowplayer.org/forum/7/12671

On using no interleaving, I'm not sure of the advantages of that. Interleaving is how the audio and video data packets are interspersed in the container. It has nothing to do with metadata. All I've ever used is the default (which I think is a half-second), and that's worked for me. Just calling MP4Box with the input file should be all you really need.

razibur

Posts: 1

Registered:
Sep 25, 2009

» How to create a compatible mp4 with ffmpeg ?

Posted: Sep 25, 2009

Reply to: How to create a compatible mp4 with ffmpeg ?, from davidstoll
to mux a video stream from AVI to MP4 use the following commandline:
ffmpeg -i input.avi -vcodec copy output.mp4note that ffmpeg seems to only place mpeg-4 streams correctly in MP4 when the files use a 4cc, which ffmpeg knows to be MPEG-4
therefore if you want to mux 3ivx, ffvfw or NeroDigital streams you will have to change their 4ccs to DIVX or XVID first!

also important to note is that ffmpeg isnt able to remove AVI hacks! as i am sure most already know AVI needs some hackery to be able to handle mpeg-4 (b-frames), the most important one is packed bitstream, a private workaround introduced in divx5 and now also used in xvid.
of course noone can expect mp4 muxer developers to know private, not standardised hacks, to make old containers work, and therefore ffmpeg, like many other muxers (mp4ui, mp4creator) doesnt remove these hacks

to make it short: dont mux avi files with packed bitstream b-frames (used by default in divx5 and xvid) with ffmpeg, the produced mp4 files will not be spec compliant! use 3ivx instead to mux such files!

[URLhttp://kerjakeras.com/mengembalikan-jati-diri-bangsa/]Mengembalikan Jati Diri Bangsa[/URL]|
[URLhttp://kerjakeras.com/kenali-dan-kunjungi-objek-wisata-di-pandeglang/]Kenali Dan Kunjungi Objek Wisata Di Pandeglang[/URL]

BenjaminCarl

Posts: 1

Registered:
Feb 17, 2010

» How to create a compatible mp4 with ffmpeg ?

Posted: Feb 17, 2010

Reply to: How to create a compatible mp4 with ffmpeg ?, from davidstoll
after relocating the MOOV-Atom/Box (Metadata) from the end to the beginning of the file, the file itself is ready for pseudostreaming!

After creating/converting a MP4 / Quicktime / h264 File - you can relocate the MOOV-Atom/Box simply by using the PHP Library called "moovrelocator" (a PHP5 class to relocate the moov-atom from the end to the beginning of a MP4-file).

i use this lib and it works perfect for me (currently it does not support files larger then 2 GB!)

here is the link:https://code.google.com/p/moovrelocator/

debrah.h48

Posts: 1

Registered:
Feb 4, 2010

Hello,

Posted: Feb 22, 2010

Reply to: How to create a compatible mp4 with ffmpeg ?, from davidstoll
FFmpeg is a versatile tool to encode and convert a multitude of video and audio formats. x264 encodes high-quality video superior to other popular encoders.

Although FFmpeg and x264 are available in the Ubuntu repositories, you may need to compile from source. For example, the ffmpeg-user mailing list requires that you use the latest FFmpeg svn before asking for help. Since FFmpeg and x264 are updated frequently, you may also like to have the bleeding-edge for encoding videos. Also, FFmpeg in the Ubuntu repository may not support necessary encoders, decoders, and formats.

You can get more information about this in the following thread:http://ubuntuforums.org/showthread.php?t=786095

ufff

Posts: 19

Registered:
Oct 8, 2009

» Hello,

Posted: Feb 26, 2010

Reply to: Hello,, from debrah.h48
useful info, thanks

undercash
http://www.pokercast.tv/

Posts: 55

Registered:
Feb 26, 2009

» » Hello,

Posted: Mar 21, 2010

Reply to: » Hello,, from ufff
I have made a blog post about ffmpeg compilation from source with some others libraries on an ubuntu 8.0.4
it has no pretention to be a tutorial but it s a way for me to remenber the place to go and the steps to make a good built from svn

http://www.pokercast.tv/blog/setting-up-ffmpeg

montajesberiain

Posts: 2

Registered:
Mar 7, 2011

How to create a compatible mp4 with ffmpeg ?

Posted: Mar 8, 2011

Reply to: How to create a compatible mp4 with ffmpeg ?, from davidstoll
to MUX a video stream from AVI to MP4 using the following command:
Code:

ffmpeg-i input.avi-vcodec copy output.mp4

Note that ffmpeg seems to only put mpeg-4 streams in MP4 correctly when the files using a 4CC as ffmpeg know that MPEG-4
Therefore, if you want to mux 3ivx, streams ffvfw or nero digital you have to change their 4ccs to DIVX or XVID first!

also important to note is that ffmpeg isn't can delete AVI hack! I'm sure most of you already know AVI need some hackery to handle MPEG-4 (b-frames), is the most important thing a packed bitstream, a private solution introduced DivX5 and now also in xvid.
Of course no one can expect MP4 muxer developers to learn Private, non-standard hack, to make the old container work, and therefore, ffmpeg, like many other muxers (mp4ui, mp4creator) doesn't remove these hacks

to make it short: dont mux AVI files with packed bitstream b-frames (used by default in DivX5 and XviD) with ffmpeg, it will produce mp4 files are not spec compliant! use 3ivx instead mux these files!reparacion de maquinaria

stelalouis

Posts: 1

Registered:
Mar 9, 2011

» How to create a compatible mp4 with ffmpeg ?

Posted: Mar 9, 2011

Reply to: How to create a compatible mp4 with ffmpeg ?, from montajesberiain
I will really appreciate the ideas given by montajesberiain that are too helpful here and you must tr them as once

ramesh.nkr

Posts: 1

Registered:
Mar 21, 2011

Mp4 video playing error

Posted: Mar 21, 2011

Reply to: » How to create a compatible mp4 with ffmpeg ?, from stelalouis
Hello, I'm trying to play a video on FlowPlayer. I was wondering what it would take to create an mp4 with ffmpeg to be able to psudostream?

I can stream flv's without any problem.

Here is my ffmpeg capture command.

ffmpeg -i test.mp4 -metadata title="Test" -metadata artist="Test" -metadata date="2011" -acodec copy -vcodec copy test2.mp4

The resulting file has these attributes...

Output #0, mp4, to 'test2.mp4':
Metadata:
date : 1995
artist : Test
title : Test
Stream #0.0(und): Video: mpeg4, yuv420p, 426x320 [PAR 1:1 DAR 213:160], q=2-
31, 867 kb/s, 24 tbn, 24 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, 128 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
frame= 4293 fps= 0 q=-1.0 size= 21289kB time=177.89 bitrate= 980.4kbits/s
frame= 5362 fps=5047 q=-1.0 size= 25763kB time=222.40 bitrate= 949.0kbits/s
frame= 5850 fps=3707 q=-1.0 size= 29562kB time=242.74 bitrate= 997.7kbits/s
frame= 6631 fps=3596 q=-1.0 Lsize= 33711kB time=276.13 bitrate=1000.1kbits/s

video:29248kB audio:4315kB global headers:0kB muxing overhead 0.441274%

when i run the video file it starts buffering, waits until completion of the buffer and plays the video. Here video not working but audio working.

my metadata looks like this

(Array)#0
[aacaot] 2
[audiochannels] 2
[audiocodecid] "mp4a"
[audiosamplerate] 44100
[duration] 276.1317006802721
[moovposition] 34368017
[tags] (Array)#1
[©nam] "Test"
[©too] "Lavf52.48.0"
[trackinfo] (Array)#2
[0] (Object)#3
language = "und"
length = 6631
sampledescription = (Array)#4
[0] (Object)#5
sampletype = "mp4v"
timescale = 24
[1] (Object)#6
language = "und"
length = 12177408
sampledescription = (Array)#7
[0] (Object)#8
sampletype = "mp4a"
timescale = 44100

Can anyone Help. How to inject an mp4 file
Thanks in Advance.

StJamesChiropracticClinic

Posts: 1

Registered:
Nov 21, 2011

» Mp4 video playing error

Posted: Nov 21, 2011

Reply to: Mp4 video playing error, from ramesh.nkr
Happy I came across this!..Thank you all for the info..

St. James Chiropractic Clinic