Video takes long time to start

1

I use this command to convert video using ffmpeg on phpvibe:

unfortunately the videos take a long time to start on firefox so I'm looking for a command to move the video's atom to the beginning so the video will start very quickly

time ffmpeg -i de.avi -vcodec libx264 -s 640x360  -profile:v high -level 4.2 -preset ultrafast -qp 0 -y -crf 23 -vf scale=-1:360 -threads 0 -acodec aac -strict experimental  -b:a 128k -movflags +faststart vvv.mp4
ffmpeg version 2.5 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jan 29 2015 23:14:07 with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
  configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-shared --enable-libmp3lame --enable-libx264 --enable-libfaac --enable-libvpx --enable-libvorbis --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopencore-amrnb --enable-libtheora --enable-libfreetype
  libavutil      54. 15.100 / 54. 15.100
  libavcodec     56. 13.100 / 56. 13.100
  libavformat    56. 15.102 / 56. 15.102
  libavdevice    56.  3.100 / 56.  3.100
  libavfilter     5.  2.103 /  5.  2.103
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  3.100 / 53.  3.100
[mpeg4 @ 0x1edba20] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using a tool like VirtualDub or avidemux to fix it.
Input #0, avi, from 'de.avi':
  Metadata:
    encoder         : VirtualDubMod 1.5.10.2 Fr | www.trad-fr.com ||  (build 2540/release)
  Duration: 01:49:30.57, start: 0.000000, bitrate: 894 kb/s
    Stream #0:0: Video: mpeg4 (Advanced Simple Profile) (XVID / 0x44495658), yuv420p, 624x336 [SAR 1:1 DAR 13:7], 757 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.98 tbc
    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 48000 Hz, stereo, s16p, 128 kb/s
[libx264 @ 0x1efa3e0] using SAR=117/112
[libx264 @ 0x1efa3e0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x1efa3e0] profile Constrained Baseline, level 4.2
[libx264 @ 0x1efa3e0] 264 - core 144 r2 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=23 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'vvv.mp4':
  Metadata:
    encoder         : Lavf56.15.102
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 640x360 [SAR 117:112 DAR 13:7], q=-1--1, 23.98 fps, 2500k tbn, 23.98 tbc
    Metadata:
      encoder         : Lavc56.13.100 libx264
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc56.13.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg4 (native) -> h264 (libx264))
  Stream #0:1 -> #0:1 (mp3 (native) -> aac (native))
Press [q] to stop, [?] for help
[mpeg4 @ 0x25c5700] Video uses a non-standard and wasteful way to store B-frames ('packed B-frames'). Consider using a tool like VirtualDub or avidemux to fix it.
frame=   40 fps=0.0 q=20.0 size=       6kB time=00:00:02.47 bitrate=  20.8kbits/frame=  178 fps=178 q=23.0 size=     931kB time=00:00:08.23 bitrate= 925.9kbits/frame=  326 fps=217 q=24.0 size=    2199kB time=00:00:14.40 bitrate=1251.1kbits/frame=  456 fps=228 q=22.0 size=    3440kB time=00:00:19.81 bitrate=1422.0kbits/frame=  610 fps=244 q=17.0 size=    4431kB time=00:00:26.21 bitrate=1384.4kbits/frame=  747 fps=249 q=19.0 size=    5036kB time=00:00:31.93 bitrate=1291.7kbits/frame=  864 fps=247 q=22.0 size=    5484kB time=00:00:36.82 bitrate=1220.2kbits/frame=  977 fps=244 q=17.0 size=    6086kB time=01:48:49.30 bitrate=1310.5kbitsframe=156635 fps=242 q=25.0 size= 1045689kB time=01:48:53.78 bitrate=1311.1kbitsframe=156737 fps=242 q=24.0 size= 1046605kB time=01:48:58.02 bitrate=1311.4kbitsframe=156870 fps=242 q=22.0 size= 1047699kB time=01:49:03.57 bitrate=1311.6kbitsframe=157018 fps=242 q=27.0 size= 1048527kB time=01:49:09.71 bitrate=1311.4kbitsframe=157157 fps=242 q=15.0 size= 1049050kB time=01:49:15.54 bitrate=1310.9kbitsframe=157289 fps=242 q=22.0 size= 1049714kB time=01:49:21.06 bitrate=1310.6kbitsframe=157389 fps=242 q=12.0 size= 1050224kB time=01:49:25.24 bitrate=1310.5kbitsframe=157446 fps=242 q=12.0 size= 1050296kB time=01:49:27.57 bitrate=1310.1kbitsframe=157490 fps=242 q=12.0 size= 1050313kB 
time=01:49:29.42 bitrate=1309.7kbits[mp4 @ 0x1ef3de0] Starting second pass: moving the moov atom to the beginning of the file
frame=157537 fps=239 q=-1.0 Lsize= 1053540kB time=01:49:30.61 bitrate=1313.5kbits/s dup=4 drop=0
video:947550kB audio:102771kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.306465%
[libx264 @ 0x1efa3e0] frame I:631   Avg QP:18.49  size: 35280
[libx264 @ 0x1efa3e0] frame P:156906 Avg QP:21.39  size:  6042
[libx264 @ 0x1efa3e0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x1efa3e0] mb P  I16..4:  4.0%  0.0%  0.0%  P16..4: 55.8%  0.0%  0.0%  0.0%  0.0%    skip:40.2%
[libx264 @ 0x1efa3e0] coded y,uvDC,uvAC intra: 55.2% 50.9% 23.1% inter: 31.1% 18.9% 2.1%
[libx264 @ 0x1efa3e0] i16 v,h,dc,p: 40% 28% 20% 12%
[libx264 @ 0x1efa3e0] i8c dc,h,v,p: 38% 24% 29%  9%
[libx264 @ 0x1efa3e0] kb/s:1181.37

real    11m0.425s
user    19m50.981s
sys     0m57.000s

this is a video's link MP4 Any idea please

user3137017

Posted 2015-02-11T20:56:13.170

Reputation: 11

Answers

1

I'm looking for a command to move the video's atom to the beginning so the video will start very quickly

You're already doing that by setting -movflags +faststart. So you're fine. The video has an average bitrate of about 1 MBit/s, which is okay, but probably a little too much for 360p video.

For me, your video takes rougly 4–5 seconds to start, on Google Chrome. On Firefox, it takes a tad longer, but not too much. I have a 16 MBit/s (nominal) DSL connection. Nothing special.

The video shows errors in Firefox. Not sure what causes this:

I'm wondering why you call the video "AVI". It's not an AVI container, but MP4. So maybe you're converting or renaming it to AVI, which causes the problem?


Some other notes:

-qp 0 -crf 23

This doesn't make sense. Only use -crf 23, or, if you target a specific bitrate, use -b:v 1M, for example. If you have time for encoding, go with a two-pass encode. Read the H.264 encoding guide thoroughly. I have the feeling you're a bit overwhelmed with the options, since…

-s 640x360 -vf scale=-1:360

This doesn't make sense either. No need to scale twice. Just use -vf scale=-1:360, or, even better, -vf scale=-2:360, to ensure that your video width is a multiple of 2 (needed for libx264).

slhck

Posted 2015-02-11T20:56:13.170

Reputation: 182 472

Thnak you ,i did make this changes but i have always the same issue with firefox – user3137017 – 2015-02-12T23:35:23.170

I'm sorry, I can't reproduce it. Maybe you need to check the logs for more information, or post a bug report on the Firefox tracker. Especially when other browsers play the file just fine. – slhck – 2015-02-13T05:35:13.557

i'm using this {ffmpeg-cmd} -i {input} -c:v libx264 -s {ffmpeg-vsize} -crf 24 -b:v 1M -c:a aac -strict -2 -preset ultrafast -movflags +faststart {output}.mp4 and i see that videos start more quickly you can check http://dimafabor.com/video/153/dolphin-tale-2-glups-avi/

– user3137017 – 2015-02-14T12:31:11.947

Do not use -crf and -b:v at the same time. Like I said, use either -crf, or -b:v. This video takes ~15 seconds for me to load in Chrome, so actually a little longer than the previous one you showed. But it's not a huge loading time… seems fine for me for a movie of 1hr length. But can you elaborate on why they are called .avi in your application? – slhck – 2015-02-14T16:24:06.987

thanks for the title (.avi) because the php code take the name and its extension from my computer so im testing i don't change the title for now , you can see here http://dimafabor.com/mp4.png.

– user3137017 – 2015-02-14T20:59:20.210

i think that i'm not the only one https://support.mozilla.org/en-US/questions/1046263

– user3137017 – 2015-02-15T00:10:42.230