Recherche avancée

Médias (1)

Mot : - Tags -/bug

Autres articles (23)

  • Qu’est ce qu’un éditorial

    21 juin 2013, par

    Ecrivez votre de point de vue dans un article. Celui-ci sera rangé dans une rubrique prévue à cet effet.
    Un éditorial est un article de type texte uniquement. Il a pour objectif de ranger les points de vue dans une rubrique dédiée. Un seul éditorial est placé à la une en page d’accueil. Pour consulter les précédents, consultez la rubrique dédiée.
    Vous pouvez personnaliser le formulaire de création d’un éditorial.
    Formulaire de création d’un éditorial Dans le cas d’un document de type éditorial, les (...)

  • Contribute to translation

    13 avril 2011

    You can help us to improve the language used in the software interface to make MediaSPIP more accessible and user-friendly. You can also translate the interface into any language that allows it to spread to new linguistic communities.
    To do this, we use the translation interface of SPIP where the all the language modules of MediaSPIP are available. Just subscribe to the mailing list and request further informantion on translation.
    MediaSPIP is currently available in French and English (...)

  • HTML5 audio and video support

    13 avril 2011, par

    MediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
    The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
    For older browsers the Flowplayer flash fallback is used.
    MediaSPIP allows for media playback on major mobile platforms with the above (...)

Sur d’autres sites (5444)

  • FFMPEG Converted Video Not Working In HTML5

    27 novembre 2015, par Suprabhat Biswal

    Converted Avi to Mp4 using FFMPEG, Converted video not working in html
    5

    I have a section in my web page where user can upload any types of videos of any format , currently only restricted to .mp4 and .avi. After successfull upload i have displayed the same video to the user. I have bind the path in HTML5 video so that the user can view the content he/she has uploded. Video with extension .mp4 no doubt are working properly as HTML5 support them. Tricky part is it don’t support Avi files. Now here what the problem has arised. In order to display avi videos i have used FFMPEG to convert videos with extension .avi to .mp4. With lots of googling and reading forum, i have succesfully converted avi videos to mp4 . Here’s what i have used :-

    1. ffmpeg -i input.avi -acodec libfaac -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4

    2. ffmpeg -i input.avi -c:v libx264 -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 output.mp4

    Above two are working perfectly, they have succesfully converted the video. But when i run them on browser in HTML5 and in new tab (Flash Player Plugin Installed), HTML5 doesn’t play it and flash player return an error message "Video can’t be played because the file is corrupt". But when i played them on KMplayer and in Window media player they are running perfectly.

    I have been to various threads in stackoverflow related to convert avi to mp4 and here i found following in one of the forum. where one of user has accepted this a correct answer but it ain’t worked out for me.

    1. ffmpeg -y -i sample.avi -b:v 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 sample.mp4

    Above argument returned me following error "File for preset ’slow’ not found".

    Following my futher searches i came across this thread ffmpeg convert mov file to mp4 for HTML5 video tag IE9. Here following argument worked perfectly and it able to convert video in such way that it is playble on browser.

    1. ffmpeg -y -i input.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k -pix_fmt yuv420p output.mp4.

    Problem i faced here was video is converted to 420p reso which quality is noty upto mark. Smaller resolution videos are been enlarged and seems pixelated

    Thus, i had to finally put up a question. I will be very obliged if someone can give a solution for above problem. I need to convert an avi video to mp4 supported by HTML5 video tag. It should able to play it on browser and during conversion of video it should maintain original audio and video quality plus resolution.

    Thanks

    My C# Code :

           public void Create(string input, string output, string parametri, string ThumbnailPhysicalPath, int ConvertType)
           {
               ffmpeg = new Process();

               if (ConvertType == Convert.ToInt32(ConversionType.Thumbnail))
                   ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -vframes 1 \"" + output + "\"";
               else if (ConvertType == Convert.ToInt32(ConversionType.AviToMp4))
                   ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -c:v libx264 -b:a 128k -vcodec mpeg4 -b:v 1200k -flags +aic+mv4 \"" + output + "\"";
                   //ffmpeg.StartInfo.Arguments = " -i \"" + input + "\" -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_aacenc -b:a 128k -pix_fmt yuv420p \"" + output + "\"";
               ffmpeg.StartInfo.FileName = ThumbnailPhysicalPath + @"ffmpeg.exe";
               ffmpeg.StartInfo.UseShellExecute = false;
               ffmpeg.StartInfo.RedirectStandardOutput = true;
               ffmpeg.StartInfo.RedirectStandardError = true;
               ffmpeg.StartInfo.CreateNoWindow = true;
               try
               {
                   ffmpeg.Start();
                   ffmpeg.WaitForExit();
                   string error = ffmpeg.StandardError.ReadToEnd();
               }
               catch (Exception Ex)
               {
                   Common.WriteLog("Exception occurred during conversion. Error Message :- " + Ex.Message + "\n Input Parameter :- " + input+ "\n Output Paramenter :- "+ output);
               }
               finally
               {
                   ffmpeg.Close();
                   if (ConvertType == Convert.ToInt32(ConversionType.AviToMp4))
                       UpdateConvertedVideoDetails(input,output);
               }
           }

    Command Prompt FFMPEG Output :-

    Sample 3 Result :-

    D:\Client\WebSite\Converter_Tools>ffmpeg -y -i sample.avi -b:v 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 sample.mp4
    ffmpeg version N-70239-g111d79a Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 4.9.2 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
    ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
    b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
    enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab
    le-zlib
     libavutil      54. 19.100 / 54. 19.100
     libavcodec     56. 26.100 / 56. 26.100
     libavformat    56. 23.105 / 56. 23.105
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 11.101 /  5. 11.101
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    [avi @ 037c8480] non-interleaved AVI
    Guessed Channel Layout for  Input Stream #0.1 : mono
    Input #0, avi, from 'sample.avi':
     Duration: 00:00:34.00, start: 0.000000, bitrate: 1433 kb/s
       Stream #0:0: Video: cinepak (cvid / 0x64697663), rgb24, 320x240, 15 fps, 15 tbr, 15 tbn, 15 tbc
       Stream #0:1: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 22050 Hz, 1 channels, u8, 176 kb/s
    File for preset 'slow' not found

    Sample 4 Result :-

    D:\Client\WebSite\Converter_Tools>ffmpeg -y -i input.avi -vcodec libx264 -vprofile high -preset slow -b:v 500k -maxrate 500k -bufsize 1000k -vf scale=-1:480 -threads 0 -acodec libvo_
    aacenc -b:a 128k -pix_fmt yuv420p output.mp4
    ffmpeg version N-70239-g111d79a Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 4.9.2 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libblu
    ray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
    b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --
    enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enab
    le-zlib
     libavutil      54. 19.100 / 54. 19.100
     libavcodec     56. 26.100 / 56. 26.100
     libavformat    56. 23.105 / 56. 23.105
     libavdevice    56.  4.100 / 56.  4.100
     libavfilter     5. 11.101 /  5. 11.101
     libswscale      3.  1.101 /  3.  1.101
     libswresample   1.  1.100 /  1.  1.100
     libpostproc    53.  3.100 / 53.  3.100
    Input #0, avi, from 'input.avi':
     Duration: 00:00:03.93, start: 0.000000, bitrate: 3255 kb/s
       Stream #0:0: Video: msrle ([1][0][0][0] / 0x0001), pal8, 300x250, 3301 kb/s, 15 fps, 15 tbr, 15 tbn, 15 tbc
    [libx264 @ 002ec860] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
    [libx264 @ 002ec860] profile High, level 2.2
    [libx264 @ 002ec860] 264 - core 144 r2525 40bb568 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=5 deblock=1:0:0 analyse=0x3:0x113 me=umh subm
    e=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 i
    nterlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=15 scenecut=40 intra_refresh=0 rc_lookahead=50 rc
    =cbr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to 'output.mp4':
     Metadata:
       encoder         : Lavf56.23.105
       Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 576x480, q=-1--1, 500 kb/s, 15 fps, 15360 tbn, 15 tbc
       Metadata:
         encoder         : Lavc56.26.100 libx264
    Stream mapping:
     Stream #0:0 -> #0:0 (msrle (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    frame=   59 fps= 30 q=-1.0 Lsize=     229kB time=00:00:03.80 bitrate= 493.5kbits/s
    video:227kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.637976%
    [libx264 @ 002ec860] frame I:3     Avg QP:26.53  size: 10657
    [libx264 @ 002ec860] frame P:25    Avg QP:30.49  size:  5608
    [libx264 @ 002ec860] frame B:31    Avg QP:32.26  size:  1935
    [libx264 @ 002ec860] consecutive B-frames: 22.0% 16.9% 20.3% 40.7%
    [libx264 @ 002ec860] mb I  I16..4: 16.7% 69.0% 14.4%
    [libx264 @ 002ec860] mb P  I16..4: 11.1% 29.9%  3.8%  P16..4: 21.3%  6.8%  2.6%  0.0%  0.0%    skip:24.6%
    [libx264 @ 002ec860] mb B  I16..4:  1.7%  3.0%  0.3%  B16..8: 29.7%  5.6%  0.8%  direct: 2.1%  skip:56.8%  L0:50.5% L1:45.6% BI: 3.9%
    [libx264 @ 002ec860] 8x8 transform intra:66.5% inter:79.4%
    [libx264 @ 002ec860] direct mvs  spatial:93.5% temporal:6.5%
    [libx264 @ 002ec860] coded y,uvDC,uvAC intra: 40.3% 48.8% 25.7% inter: 12.4% 8.4% 1.4%
    [libx264 @ 002ec860] i16 v,h,dc,p: 19% 59%  6% 17%
    [libx264 @ 002ec860] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 25% 16%  7%  8%  6% 11%  7% 10%
    [libx264 @ 002ec860] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 21%  9%  7%  9%  8% 10%  7% 10%
    [libx264 @ 002ec860] i8c dc,h,v,p: 41% 33% 13% 13%
    [libx264 @ 002ec860] Weighted P-Frames: Y:0.0% UV:0.0%
    [libx264 @ 002ec860] ref P L0: 67.6%  8.1%  9.6%  5.4%  6.6%  2.8%
    [libx264 @ 002ec860] ref B L0: 84.6% 10.5%  3.9%  1.0%
    [libx264 @ 002ec860] ref B L1: 95.9%  4.1%
    [libx264 @ 002ec860] kb/s:472.20
  • Convert video by ffmpeg not working in chrome

    18 novembre 2015, par Ducthien

    I used command :

     $ ffmpeg -y -i "E:\SharingVideo\src\main\webapp\resources\video\input\input.mp4" -an -c:a libfdk_aac -ac 2 -ab 128k -c:v libx264 -x264opts 'keyint=24:min-keyint=24:no-scenecut' -b:v 1500k -maxrate 1500k -bufsize 1000k -vf "scale=-1:720" "E:\SharingVideo\src\main\webapp\resources\video\input\input_an.mp4"

    to get only video with format h264 (without sound). Cmd result :

    ffmpeg version N-76224-ga7c5005 Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 5.2.0 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
     libavutil      55.  4.100 / 55.  4.100
     libavcodec     57.  9.100 / 57.  9.100
     libavformat    57. 10.101 / 57. 10.101
     libavdevice    57.  0.100 / 57.  0.100
     libavfilter     6. 12.100 /  6. 12.100
     libswscale      4.  0.100 /  4.  0.100
     libswresample   2.  0.100 /  2.  0.100
     libpostproc    54.  0.100 / 54.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'E:\SharingVideo\src\main\webapp\resources\video\input\input.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       creation_time   : 1970-01-01 00:00:00
       encoder         : Lavf52.94.0
     Duration: 00:02:29.95, start: 0.000000, bitrate: 1787 kb/s
       Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1629 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 151 kb/s (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : SoundHandler
    [libx264 @ 000000821f5fbe40] using SAR=1/1
    [libx264 @ 000000821f5fbe40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
    [libx264 @ 000000821f5fbe40] profile High, level 3.1
    [libx264 @ 000000821f5fbe40] 264 - core 148 r2638 7599210 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=24 keyint_min=13 scenecut=0 intra_refresh=0 rc_lookahead=24 rc=cbr mbtree=1 bitrate=1500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=1500 vbv_bufsize=1000 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00
    Output #0, mp4, to 'E:\SharingVideo\src\main\webapp\resources\video\input\input_an.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.10.101
       Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 1500 kb/s, 29.97 fps, 30k tbn, 29.97 tbc (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : VideoHandler
         encoder         : Lavc57.9.100 libx264
    Stream mapping:
     Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
    Press [q] to stop, [?] for help
    frame= 4494 fps= 38 q=-1.0 Lsize=   25050kB time=00:02:29.88 bitrate=1369.1kbits/s
    video:25003kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.188374%
    [libx264 @ 000000821f5fbe40] frame I:188   Avg QP:17.73  size: 40170
    [libx264 @ 000000821f5fbe40] frame P:2060  Avg QP:23.64  size:  7302
    [libx264 @ 000000821f5fbe40] frame B:2246  Avg QP:24.03  size:  1339
    [libx264 @ 000000821f5fbe40] consecutive B-frames: 29.6%  8.4%  8.9% 53.1%
    [libx264 @ 000000821f5fbe40] mb I  I16..4: 27.8% 64.1%  8.1%
    [libx264 @ 000000821f5fbe40] mb P  I16..4:  5.4% 12.4%  0.3%  P16..4: 26.4%  4.3%  2.0%  0.0%  0.0%    skip:49.3%
    [libx264 @ 000000821f5fbe40] mb B  I16..4:  0.2%  0.4%  0.0%  B16..8: 17.5%  0.7%  0.1%  direct: 0.9%  skip:80.2%  L0:41.5% L1:55.9% BI: 2.7%
    [libx264 @ 000000821f5fbe40] 8x8 transform intra:66.9% inter:89.7%
    [libx264 @ 000000821f5fbe40] coded y,uvDC,uvAC intra: 39.1% 57.7% 20.9% inter: 4.7% 10.1% 0.3%
    [libx264 @ 000000821f5fbe40] i16 v,h,dc,p: 43% 29%  8% 20%
    [libx264 @ 000000821f5fbe40] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 27% 23% 21%  4%  5%  5%  5%  5%  5%
    [libx264 @ 000000821f5fbe40] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 26%  9%  4%  8%  7%  7%  5%  4%
    [libx264 @ 000000821f5fbe40] i8c dc,h,v,p: 49% 24% 20%  7%
    [libx264 @ 000000821f5fbe40] Weighted P-Frames: Y:9.1% UV:8.9%
    [libx264 @ 000000821f5fbe40] ref P L0: 74.5% 11.1% 11.0%  3.3%  0.1%
    [libx264 @ 000000821f5fbe40] ref B L0: 91.0%  7.9%  1.1%
    [libx264 @ 000000821f5fbe40] ref B L1: 96.4%  3.6%
    [libx264 @ 000000821f5fbe40] kb/s:1365.92

    then i get audio from mp4 file :

    ffmpeg -i "E:\SharingVideo\src\main\webapp\resources\video\input\input.mp4" -vn -acodec copy "E:\SharingVideo\src\main\webapp\resources\video\input\audio.mp4"

    cmd result :

    $ ffmpeg -i "E:\SharingVideo\src\main\webapp\resources\video\input\input.mp4" -vn -acodec copy "E:\SharingVideo\src\mai
    n\webapp\resources\video\input\audio.mp4"
    ffmpeg version N-76224-ga7c5005 Copyright (c) 2000-2015 the FFmpeg developers
     built with gcc 5.2.0 (GCC)
     configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-lzma --enable-decklink --enable-zlib
     libavutil      55.  4.100 / 55.  4.100
     libavcodec     57.  9.100 / 57.  9.100
     libavformat    57. 10.101 / 57. 10.101
     libavdevice    57.  0.100 / 57.  0.100
     libavfilter     6. 12.100 /  6. 12.100
     libswscale      4.  0.100 /  4.  0.100
     libswresample   2.  0.100 /  2.  0.100
     libpostproc    54.  0.100 / 54.  0.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'E:\SharingVideo\src\main\webapp\resources\video\input\input.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       creation_time   : 1970-01-01 00:00:00
       encoder         : Lavf52.94.0
     Duration: 00:02:29.95, start: 0.000000, bitrate: 1787 kb/s
       Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1629 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : VideoHandler
       Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 151 kb/s (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : SoundHandler
    [mp4 @ 0000000b967e30a0] Codec for stream 0 does not use global headers but container format requires global headers
    Output #0, mp4, to 'E:\SharingVideo\src\main\webapp\resources\video\input\audio.mp4':
     Metadata:
       major_brand     : isom
       minor_version   : 512
       compatible_brands: isomiso2avc1mp41
       encoder         : Lavf57.10.101
       Stream #0:0(und): Audio: aac ([64][0][0][0] / 0x0040), 44100 Hz, stereo, 151 kb/s (default)
       Metadata:
         creation_time   : 1970-01-01 00:00:00
         handler_name    : SoundHandler
    Stream mapping:
     Stream #0:1 -> #0:0 (copy)
    Press [q] to stop, [?] for help
    size=    2806kB time=00:02:29.86 bitrate= 153.4kbits/s
    video:0kB audio:2780kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.933710%

    after that. I create .mpd file by MP4box :

    MP4Box -dash 10000 -profile onDemand -rap -out "E:\SharingVideo\src\main\webapp\resources\video\input\input_dash.mpd" "E:\SharingVideo\src\main\webapp\resources\video\input\input_an.mp4"#video:id=video_2Mb "E:\SharingVideo\src\main\webapp\resources\video\input\audio.mp4"#audio:id=audio

    the video play fine in firefox and IE but in chrome it doesn’t working :

    VIDEOJS: ERROR: (CODE:3 MEDIA_ERR_DECODE) The video playback was aborted due to a corruption problem or because the video used features your browser did not support.
    Video Element Error: MEDIA_ERR_DECODE
    VIDEOJS: ERROR: (CODE:4 MEDIA_ERR_SRC_NOT_SUPPORTED) The video could not be loaded, either because the server or network failed or because the format is not supported.
    Video Element Error: MEDIA_ERR_SRC_NOT_SUPPORTED

    I don’t know why it doesn’t work in chrome, please help me.What did I wrong something to display video in chrome ?

  • Issue in recording video

    16 novembre 2015, par human123

    I am trying to record video in 480*480 resolution like in vine using javacv. As a starting point I used the sample provided in https://github.com/bytedeco/javacv/blob/master/samples/RecordActivity.java Video is getting recorded (but not in the desired resolution) and saved.

    But the issue is that 480*480 resolution is not supported natively in android. So some pre processing needs to be done to get the video in desired resolution.

    So once I was able to record video using code sample provided by javacv, next challenge was on how to pre process the video. On research it was found that efficient cropping is possible when final image width required is same as recorded image width. Such a solution was provided in the SO question,Recording video on Android using JavaCV (Updated 2014 02 17). I changed onPreviewFrame method as suggested in that answer.

       @Override
       public void onPreviewFrame(byte[] data, Camera camera) {
           if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
               startTime = System.currentTimeMillis();
               return;
           }
           if (RECORD_LENGTH > 0) {
               int i = imagesIndex++ % images.length;
               yuvImage = images[i];
               timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
           }
           /* get video data */
           imageWidth = 640;
           imageHeight = 480    
           int finalImageHeight = 360;
           if (yuvImage != null && recording) {
               ByteBuffer bb = (ByteBuffer)yuvImage.image[0].position(0); // resets the buffer
               final int startY = imageWidth*(imageHeight-finalImageHeight)/2;
               final int lenY = imageWidth*finalImageHeight;
               bb.put(data, startY, lenY);
               final int startVU = imageWidth*imageHeight + imageWidth*(imageHeight-finalImageHeight)/4;
               final int lenVU = imageWidth* finalImageHeight/2;
               bb.put(data, startVU, lenVU);
               try {
                   long t = 1000 * (System.currentTimeMillis() - startTime);
                   if (t > recorder.getTimestamp()) {
                       recorder.setTimestamp(t);
                   }
                   recorder.record(yuvImage);
               } catch (FFmpegFrameRecorder.Exception e) {
                   Log.e(LOG_TAG, "problem with recorder():", e);
               }
           }


       }
    }

    Please also note that this solution was provided for an older version of javacv. The resulting video had a yellowish overlay covering 2/3rd part. Also there was empty section on left side as the video was not cropped correctly.

    So my question is what is the most appropriate solution for cropping videos using latest version of javacv ?

    Code after making change as suggested by Alex Cohn

       @Override
       public void onPreviewFrame(byte[] data, Camera camera) {
           if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
               startTime = System.currentTimeMillis();
               return;
           }
           if (RECORD_LENGTH > 0) {
               int i = imagesIndex++ % images.length;
               yuvImage = images[i];
               timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
           }
           /* get video data */
           imageWidth = 640;
           imageHeight = 480;      
           destWidth = 480;

           if (yuvImage != null && recording) {
               ByteBuffer bb = (ByteBuffer)yuvImage.image[0].position(0); // resets the buffer
               int start = 2*((imageWidth-destWidth)/4); // this must be even
               for (int row=0; row2; row++) {
                   bb.put(data, start, destWidth);
                   start += imageWidth;
               }
               try {
                   long t = 1000 * (System.currentTimeMillis() - startTime);
                   if (t > recorder.getTimestamp()) {
                       recorder.setTimestamp(t);
                   }
                   recorder.record(yuvImage);
               } catch (FFmpegFrameRecorder.Exception e) {
                   Log.e(LOG_TAG, "problem with recorder():", e);
               }
           }


       }

    Screen shot from video generated with this code (destWidth 480) is

    video resolution 480*480

    Next I tried capturing a video with destWidth speciified as 639. The result is

    639*480

    When destWidth is 639 video is repeating contents twice. When it is 480, contents are repeated 5 times and the green overlay and distortion is more.

    Also When the destWidth = imageWidth, video is captured properly. ie, for 640*480 there is no repetition of video contents and no green overlay.

    Converting frame to IplImage

    When this question was asked first, I missed to mention that the record method in FFmpegFrameRecorder is now accepting object of type Frame whereas earlier it was IplImage object. So I tried to apply Alex Cohn’s solution by converting Frame to IplImage.

    //---------------------------------------
    // initialize ffmpeg_recorder
    //---------------------------------------
    private void initRecorder() {

       Log.w(LOG_TAG,"init recorder");

       imageWidth = 640;
       imageHeight = 480;

       if (RECORD_LENGTH > 0) {
           imagesIndex = 0;
           images = new Frame[RECORD_LENGTH * frameRate];
           timestamps = new long[images.length];
           for (int i = 0; i < images.length; i++) {
               images[i] = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2);
               timestamps[i] = -1;
           }
       } else if (yuvImage == null) {
           yuvImage = new Frame(imageWidth, imageHeight, Frame.DEPTH_UBYTE, 2);
           Log.i(LOG_TAG, "create yuvImage");
           OpenCVFrameConverter.ToIplImage converter = new OpenCVFrameConverter.ToIplImage();
           yuvIplimage = converter.convert(yuvImage);

       }

       Log.i(LOG_TAG, "ffmpeg_url: " + ffmpeg_link);
       recorder = new FFmpegFrameRecorder(ffmpeg_link, imageWidth, imageHeight, 1);
       recorder.setFormat("flv");
       recorder.setSampleRate(sampleAudioRateInHz);
       // Set in the surface changed method
       recorder.setFrameRate(frameRate);

       Log.i(LOG_TAG, "recorder initialize success");

       audioRecordRunnable = new AudioRecordRunnable();
       audioThread = new Thread(audioRecordRunnable);
       runAudioThread = true;
    }



    @Override
       public void onPreviewFrame(byte[] data, Camera camera) {
           if (audioRecord == null || audioRecord.getRecordingState() != AudioRecord.RECORDSTATE_RECORDING) {
               startTime = System.currentTimeMillis();
               return;
           }
           if (RECORD_LENGTH > 0) {
               int i = imagesIndex++ % images.length;
               yuvImage = images[i];
               timestamps[i] = 1000 * (System.currentTimeMillis() - startTime);
           }
           /* get video data */
           int destWidth = 640;

           if (yuvIplimage != null && recording) {
               ByteBuffer bb = yuvIplimage.getByteBuffer(); // resets the buffer
               int start = 2*((imageWidth-destWidth)/4); // this must be even
               for (int row=0; row2; row++) {
                   bb.put(data, start, destWidth);
                   start += imageWidth;
               }
               try {
                   long t = 1000 * (System.currentTimeMillis() - startTime);
                   if (t > recorder.getTimestamp()) {
                       recorder.setTimestamp(t);
                   }
                   recorder.record(yuvImage);
               } catch (FFmpegFrameRecorder.Exception e) {
                   Log.e(LOG_TAG, "problem with recorder():", e);
               }
           }


       }

    But the videos generated with this method contained only green frames.