Recherche avancée

Médias (1)

Mot : - Tags -/lev manovitch

Autres articles (53)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Supporting all media types

    13 avril 2011, par

    Unlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)

  • List of compatible distributions

    26 avril 2011, par

    The table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
    If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...)

Sur d’autres sites (7116)

  • php ming flash swf slideshow to mp4/avi

    19 août 2013, par Stefan

    After hours of searching and trying i finally got a nice script together that generates a good looking Flash .swf file with a nice transaction in between de images.
    It works great if you access the swf file directly in a browser, depending on the amount of images the flash created takes anywhere between 10 and 60 seconds.
    But when uploading to Youtube the movie created flashed by in one second.
    Because swf isnt really a accepted fileformat for Youtube we decided to convert the flash file to mp4 or avi using ffmpeg.
    Unfortunally that didnt work, it had the same effect as the youtube movie.
    We had a old version of ffmpeg and updated that to a recent version and tried to convert again with the same result.
    The main thing i see is that ffmpeg cant see the swf file duration and bitrate, they are both 'N/A' while were do set them in the php script.
    I thought it looked like the Metadata doesnt get written and i cant find anything on that regarding Ming.
    But i downloaded a phpclass that extracts the metadata from the swf and that tells me the framerate etc is getting set.

    Now i have to admit i havent really tested with the new version because the commandline options are a little different but ill work on that after i post this.
    In the previous version we tried setting the framerate of the source swf file, but that didnt work either.

    Anyone here that can has a idea ? it would be greatly appriciated.

    PHP Ming Script :

         $fps = 30;
            foreach($objects as $objectId => $images){
                   // START FLASH MOVIE
                   $m = new SWFMovie();
                   $m->setDimension($width, $height);
                   $m->setBackground(0, 0, 0);
                   $m->setRate($fps);
                   $m->setFrames(count($images)*202); //count(images)* 2 breaks *($fps*$breakTime)+22(fadeOut))

                   $i = 0;
                   foreach($images as $image){

                       // REMOVE THE BACKGROUND IMAGE
                       if($behind){
                           $m->remove($behind);
                       }
                       // # REMOVE

                       // LOAD NEW IMAGE
                       $img = new SWFBitmap(fopen($image,"rb"));
                       $pic = $m->add($img);
                       $pic->setdepth(3);
                       // # LOAD

                       // BREAK TIME
                       for($j=1;$j<=($fps*$breakTime);$j++){
                           $m->nextFrame();
                       }
                       $m->remove($pic);
                       // # BREAK

                       // LOAD THE NEXT IMAGE AS BACKGROUND, IF LAST IMAGE, LOAD FIRST
                       $nextBackgrondImage =($images[$i+1]) ? $images[$i+1] : $images[0] ;
                       $img = new SWFBitmap(fopen($nextBackgrondImage,"rb"));
                       $behind = $m->add($img);
                       $behind->setdepth(2);
                       // # LOAD

                       // AND FADE OUT AGAIN
                       $img = fadeOut($image, $width, $height);
                       $pic = $m->add($img);
                       $pic->setdepth(3);
                       // # FADE OUT

                       // BREAK TIME
                       for($j=1;$j<=($fps*$breakTime);$j++){
                           $m->nextFrame();
                       }
                       $m->remove($pic);
                       # BREAK
                       $i++;
                   }      
                   $m->save('./flash/'.$nvmId.'_'.$objectId.'.swf');  
               unset($m);
               }
    }

    FFMPEG version :

    root@server:~# ffmpeg -version
    \FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
     built on Aug 15 2013 20:43:21 with gcc 4.4.5
     configuration: --enable-libmp3lame --enable-libtheora --enable-libx264
     --enable-libgsm --enable-postproc --enable-libxvid --enable-libfaac --enable-pthreads
     --enable-libvorbis --enable-gpl --enable-x11grab --enable-nonfree
     libavutil     50.36. 0 / 50.36. 0
     libavcore      0.16. 1 /  0.16. 1
     libavcodec    52.108. 0 / 52.108. 0
     libavformat   52.93. 0 / 52.93. 0
     libavdevice   52. 2. 3 / 52. 2. 3
     libavfilter    1.74. 0 /  1.74. 0
     libswscale     0.12. 0 /  0.12. 0
     libpostproc   51. 2. 0 / 51. 2. 0
    FFmpeg SVN-r26402
    libavutil     50.36. 0 / 50.36. 0
    libavcore      0.16. 1 /  0.16. 1
    libavcodec    52.108. 0 / 52.108. 0
    libavformat   52.93. 0 / 52.93. 0
    libavdevice   52. 2. 3 / 52. 2. 3
    libavfilter    1.74. 0 /  1.74. 0
    libswscale     0.12. 0 /  0.12. 0
    libpostproc   51. 2. 0 / 51. 2. 0

    FFMPEG command

    root@server:~# ffmpeg -r 30 -i /pathTo/flash/73003_8962011.swf -r 30 -ar 22050 -b 2048k /pathTo/flash/output.avi
    FFmpeg version SVN-r26402, Copyright (c) 2000-2011 the FFmpeg developers
     built on Aug 15 2013 20:43:21 with gcc 4.4.5
     configuration: --enable-libmp3lame --enable-libtheora --enable-libx264 --enable-libgsm --enable-postproc --enable-libxvid
     --enable-libfaac --enable-pthreads --enable-libvorbis --enable-gpl --enable-x11grab --enable-nonfree
     libavutil     50.36. 0 / 50.36. 0
     libavcore      0.16. 1 /  0.16. 1
     libavcodec    52.108. 0 / 52.108. 0
     libavformat   52.93. 0 / 52.93. 0
     libavdevice   52. 2. 3 / 52. 2. 3
     libavfilter    1.74. 0 /  1.74. 0
     libswscale     0.12. 0 /  0.12. 0
     libpostproc   51. 2. 0 / 51. 2. 0
    [swf @ 0x1ca1510] Estimating duration from bitrate, this may be inaccurate
    Input #0, swf, from '/pathTo/flash/73003_8962011.swf':
     Duration: N/A, bitrate: N/A
       Stream #0.0: Video: mjpeg, yuvj420p, 360x480, 30 fps, 30 tbr, 30 tbn, 30 tbc
    File '/pathTo/output.avi' already exists. Overwrite ? [y/N] y
    [buffer @ 0x1cb42d0] w:360 h:480 pixfmt:yuvj420p
    [ffsink @ 0x1cb4570] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
    [scale @ 0x1cb4870] w:360 h:480 fmt:yuvj420p -> w:360 h:480 fmt:yuv420p flags:0xa0000004
    Output #0, avi, to '/pathTo/flash/output.avi':
     Metadata:
       ISFT            : Lavf52.93.0
       Stream #0.0: Video: mpeg4, yuv420p, 360x480, q=2-31, 2048 kb/s, 30 tbn, 30 tbc
    Stream mapping:
     Stream #0.0 -> #0.0
    Press [q] to stop encoding
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    Input Stream #0.0 frame size changed to 640x480, yuvj420p
    frame=   39 fps=  0 q=17.5 Lsize=     524kB time=1.30 bitrate=3304.9kbits/s
    video:518kB audio:0kB global headers:0kB muxing overhead 1.250735%

    Metadata :

    DEBUG: Data values initialized
    DEBUG: Opened ./flash/98701_8965910.swf
    DEBUG: Read MAGIC signature: FWS
    DEBUG: Read VERSION: 9
    DEBUG: Partial SIZE read: 225
    DEBUG: Partial SIZE read: 28928
    DEBUG: Partial SIZE read: 1441792
    DEBUG: Partial SIZE read: 0
    DEBUG: Total SIZE: 1470945
    DEBUG: RECT field size: 15 bits
    DEBUG: RECT binary value: 000000000000000 (0)
    DEBUG: RECT binary value: 011001000000000 (640)
    DEBUG: RECT binary value: 000000000000000 (0)
    DEBUG: RECT binary value: 010010110000000 (480)
    DEBUG: Frame rate: 30.0
    DEBUG: Frames: 2222
    DEBUG: Finished processing ./flash/98701_8965910.swf
    FILE: ./flash/98701_8965910.swf
    MAGIC: FWS
    VERSION: 9
    SIZE: 1470945 bytes
    WIDHT: 640
    HEIGHT: 480
    FPS: 30.0 Frames/s
    FRAMES: 2222 FRAME
  • Converting Real Media with ffmpeg

    7 août 2013, par Eric Arenson

    I have a number of old crusty Real Media files I need to convert and was hoping to write a script to batch process them. I'm able to do a Real Media -> AVI conversion with FFMpegX, but when I try to replicate the conversion with ffmpeg, it always errors out with something like :

    [avi @ 0x10084fa00] Too large number of skipped frames 117425 > 60000

    It may have something to do with the funky format of these Real Media files :

    Duration: 01:28:23.42, start: 0.000000, bitrate: 448 kb/s
       Stream #0:0: Data: none, 32 kb/s
       Stream #0:1: Data: none, 192 kb/s
       Stream #0:2: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:3: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:4: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 8 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:5: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 5 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:6: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 27 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:7: Audio: cook (cook / 0x6B6F6F63), 22050 Hz, mono, fltp, 32 kb/s
       Stream #0:8: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 192 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
       Stream #0:9: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 136 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
       Stream #0:10: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:11: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:12: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:13: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:14: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:15: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 5 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc

    Does anyone have any tips on either how to find out what FFMpegX is doing to make the conversion work, or a better way to go about using ffmpeg to do this ?

    EDIT

    Including the ffmpeg command (thank you to @Mondain for teaching me about the stream mapping !) and output :

    Command :

    ffmpeg -i cc121307pm.rm -map 0:8 -map 0:7 -c:v libx264 -c:a libfaac -b:a 32k test.avi

    Output :

    ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
     built on Aug  7 2013 12:29:30 with gcc 4.2.1 (GCC) (Apple Inc. build 5664)
     configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=/usr/bin/gcc-4.2 --host-cflags='-Os -w -pipe -march=core2 -msse4.1 -mmacosx-version-min=10.6' --host-ldflags=-L/usr/local/lib --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
     libavutil      52. 18.100 / 52. 18.100
     libavcodec     54. 92.100 / 54. 92.100
     libavformat    54. 63.104 / 54. 63.104
     libavdevice    54.  3.103 / 54.  3.103
     libavfilter     3. 42.103 /  3. 42.103
     libswscale      2.  2.100 /  2.  2.100
     libswresample   0. 17.102 /  0. 17.102
     libpostproc    52.  2.100 / 52.  2.100
    [rm @ 0x10180f200] Unsupported stream type 00000265
    [rm @ 0x10180f200] Unsupported stream type 00000652
    [rm @ 0x10180f200] max_analyze_duration 5000000 reached at 5004000 microseconds
    Input #0, rm, from 'input.rm':
     Metadata:
       File ID         : 41deac0f-94fb-3595-325c-c717943bc532
       Content Rating  : (PICS-1.1 "http://www.classify.org/safesurf" labels comment "RealProducer Plus 8.5.0.200 Windows" ratings (SS~~000 1))
       Modification Date: 12/13/2007 16:26:16
       Generated By    : RealProducer Plus 8.5.0.200 Windows
       Keywords        :
       Abstract        :
       Target Audiences: 28K Modem (20 Kbps);56K Modem (34 Kbps);256K DSL/Cable Modem (225 Kbps);
       Video Quality   : Normal Motion Video
       Audio Format    : Voice Only
       Creation Date   : 12/13/2007 14:57:49
       ASMRuleBook     : #($Bandwidth < 15000),Stream2Bandwidth = 6500, Stream3Bandwidth = 5499;#($Bandwidth >= 15000) && ($Bandwidth < 20000),Stream2Ba
       title           :
       author          :
       copyright       : ?2007
       comment         :
     Duration: 01:28:23.42, start: 0.000000, bitrate: 448 kb/s
       Stream #0:0: Data: none, 32 kb/s
       Stream #0:1: Data: none, 192 kb/s
       Stream #0:2: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:3: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:4: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 8 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:5: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 5 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:6: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 27 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:7: Audio: cook (cook / 0x6B6F6F63), 22050 Hz, mono, fltp, 32 kb/s
       Stream #0:8: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 192 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
       Stream #0:9: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 136 kb/s, 30 fps, 30 tbr, 1k tbn, 1k tbc
       Stream #0:10: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:11: Audio: sipr (sipr / 0x72706973), 8000 Hz, mono, flt, 6 kb/s
       Stream #0:12: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:13: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:14: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 13 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
       Stream #0:15: Video: rv20 (RV20 / 0x30325652), yuv420p, 320x240, 5 kb/s, 15 fps, 15 tbr, 1k tbn, 1k tbc
    [libx264 @ 0x101889c00] using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.1 Cache64
    [libx264 @ 0x101889c00] profile High, level 1.3
    Output #0, avi, to 'test.avi':
     Metadata:
       File ID         : 41deac0f-94fb-3595-325c-c717943bc532
       Content Rating  : (PICS-1.1 "http://www.classify.org/safesurf" labels comment "RealProducer Plus 8.5.0.200 Windows" ratings (SS~~000 1))
       Modification Date: 12/13/2007 16:26:16
       Generated By    : RealProducer Plus 8.5.0.200 Windows
       Keywords        :
       Abstract        :
       Target Audiences: 28K Modem (20 Kbps);56K Modem (34 Kbps);256K DSL/Cable Modem (225 Kbps);
       Video Quality   : Normal Motion Video
       Audio Format    : Voice Only
       Creation Date   : 12/13/2007 14:57:49
       ASMRuleBook     : #($Bandwidth < 15000),Stream2Bandwidth = 6500, Stream3Bandwidth = 5499;#($Bandwidth >= 15000) && ($Bandwidth < 20000),Stream2Ba
       INAM            :
       author          :
       ICOP            : ?2007
       ICMT            :
       ISFT            : Lavf54.63.104
       Stream #0:0: Video: h264 (H264 / 0x34363248), yuv420p, 320x240, q=-1--1, 30 tbn, 30 tbc
       Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 22050 Hz, mono, s16, 32 kb/s
    Stream mapping:
     Stream #0:8 -> #0:0 (rv20 -> libx264)
     Stream #0:7 -> #0:1 (cook -> libfaac)
    Press [q] to stop, [?] for help
    [rm @ 0x10180f200] DATA tag in middle of chunk, file may be broken.
    Truncating packet of size 775215378 to 283607526
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 686581284 to 279055389
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 845942319 to 279042877
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 519635011 to 279040757
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 302013449 to 260425302
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 671112232 to 260422550
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 670137329 to 260371048
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 674387680 to 260336787
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 698852899 to 260336757
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 881600768 to 260281240
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 623325768 to 241694111
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 273397034 to 241679920
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 245534365 to 241615319
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 264614026 to 220525004
    [rm @ 0x10180f200] Impossibly sized packet
    [rm @ 0x10180f200] DATA tag in middle of chunk, file may be broken.
    Truncating packet of size 637535515 to 219973842
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 432193588 to 219973831
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 286760544 to 219962162
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 1070610764 to 219737624
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 259875548 to 219371853
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 362059391 to 219371844
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 885179606 to 219371833
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 587434829 to 206214002
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 816942211 to 165623435
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 471624979 to 113266905
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 674059889 to 113266894
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 459361272 to 113253548
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 637535515 to 91792709
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 432193588 to 91792698
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 286760544 to 91781029
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 157876310 to 91505934
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 469953408 to 91505925
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 260215377 to 91486921
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 877425642 to 91335612
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 259887697 to 91322050
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 885071836 to 91245341
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 264614182 to 90930431
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 811350015 to 90930422
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 128974975 to 90713958
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 801151589 to 89195724
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 654645420 to 85989435
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 184860915 to 85989426
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 1072093904 to 85980304
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 907644163 to 85521587
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 187973624 to 52762203
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 315276941 to 52762157
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 947559309 to 23894660
    [rm @ 0x10180f200] Impossibly sized packet
    Truncating packet of size 183681448 to 2582872
    [rm @ 0x10180f200] Impossibly sized packet
    input.rm: Input/output error
    frame=    0 fps=0.0 q=0.0 Lsize=      10kB time=00:00:00.00 bitrate=N/A    
    video:0kB audio:0kB subtitle:0 global headers:0kB muxing overhead inf%
    Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
  • How to concat mp4 files using libffmpeg in c program ?

    1er août 2013, par chichien

    I know ffmpeg command line is easy, but how to programmatically implement? I'm not good at this,here is some code from internet, it is used to convert .mp4 to .ts,and i made some changes,but the audio stream problem persists:

    #include
    #include
    #include
    #include

    #include "libavformat/avformat.h"
    #include "libavcodec/avcodec.h"
    #include "libavutil/avutil.h"
    #include "libavutil/rational.h"
    #include "libavdevice/avdevice.h"
    #include "libavutil/mathematics.h"
    #include "libswscale/swscale.h"

    static AVStream* add_output_stream(AVFormatContext* output_format_context, AVStream* input_stream)
    {

       AVCodecContext* input_codec_context = NULL;
       AVCodecContext* output_codec_context = NULL;

       AVStream* output_stream = NULL;
       output_stream = av_new_stream(output_format_context, 0);
       if (!output_stream)
       {
           printf("Call av_new_stream function failed\n");
           return NULL;
       }

       input_codec_context = input_stream->codec;
       output_codec_context = output_stream->codec;

       output_codec_context->codec_id = input_codec_context->codec_id;
       output_codec_context->codec_type = input_codec_context->codec_type;
       output_codec_context->codec_tag = input_codec_context->codec_tag;
       output_codec_context->bit_rate = input_codec_context->bit_rate;
       output_codec_context->extradata = input_codec_context->extradata;
       output_codec_context->extradata_size = input_codec_context->extradata_size;

       if (av_q2d(input_codec_context->time_base) * input_codec_context->ticks_per_frame > av_q2d(input_stream->time_base) && av_q2d(input_stream->time_base) < 1.0 / 1000)
       {
           output_codec_context->time_base = input_codec_context->time_base;
           output_codec_context->time_base.num *= input_codec_context->ticks_per_frame;
       }
       else
       {
           output_codec_context->time_base = input_stream->time_base;
       }
       switch (input_codec_context->codec_type)
       {
       case AVMEDIA_TYPE_AUDIO:
           output_codec_context->channel_layout = input_codec_context->channel_layout;
           output_codec_context->sample_rate = input_codec_context->sample_rate;
           output_codec_context->channels = input_codec_context->channels;
           output_codec_context->frame_size = input_codec_context->frame_size;
           if ((input_codec_context->block_align == 1 && input_codec_context->codec_id == CODEC_ID_MP3) || input_codec_context->codec_id == CODEC_ID_AC3)
           {
               output_codec_context->block_align = 0;
           }
           else
           {
               output_codec_context->block_align = input_codec_context->block_align;
           }
           break;
       case AVMEDIA_TYPE_VIDEO:
           output_codec_context->pix_fmt = input_codec_context->pix_fmt;
           output_codec_context->width = input_codec_context->width;
           output_codec_context->height = input_codec_context->height;
           output_codec_context->has_b_frames = input_codec_context->has_b_frames;
           if (output_format_context->oformat->flags & AVFMT_GLOBALHEADER)
           {
               output_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;
           }
           break;
       default:
           break;
       }

       return output_stream;
    }

    //[[** from ffmpeg.c
    static void write_frame(AVFormatContext *s, AVPacket *pkt, AVCodecContext *avctx, AVBitStreamFilterContext *bsfc){
       int ret;

       while(bsfc){
           AVPacket new_pkt= *pkt;
           int a= av_bitstream_filter_filter(bsfc, avctx, NULL,
                                             &new_pkt.data, &new_pkt.size,
                                             pkt->data, pkt->size,
                                             pkt->flags & AV_PKT_FLAG_KEY);
           if(a>0){
               av_free_packet(pkt);
               new_pkt.destruct= av_destruct_packet;
           } else if(a<0){
               fprintf(stderr, "%s failed for stream %d, codec %s\n",
                       bsfc->filter->name, pkt->stream_index,
                       avctx->codec ? avctx->codec->name : "copy");
               //print_error("", a);
               //if (exit_on_error)
               //    ffmpeg_exit(1);
           }
           *pkt= new_pkt;

           bsfc= bsfc->next;
       }

       ret= av_interleaved_write_frame(s, pkt);
       if(ret < 0){
           //print_error("av_interleaved_write_frame()", ret);
           fprintf(stderr, "av_interleaved_write_frame(%d)\n", ret);
           exit(1);
       }
    }
    //]]**

    int main(int argc, char* argv[])
    {

       const char* input;
       const char* output;
       const char* output_prefix = NULL;
       char* segment_duration_check = 0;
       const char* index = NULL;
       char* tmp_index = NULL;
       const char* http_prefix = NULL;
       long max_tsfiles = NULL;
       double prev_segment_time = 0;
       double segment_duration = 0;

       AVInputFormat* ifmt = NULL;
       AVOutputFormat* ofmt = NULL;
       AVFormatContext* ic = NULL;
       AVFormatContext* oc = NULL;
       AVStream* video_st = NULL;
       AVStream* audio_st = NULL;
       AVCodec* codec = NULL;
       AVDictionary* pAVDictionary = NULL;

       long frame_count = 0;

       if (argc != 3) {
           fprintf(stderr, "Usage: %s inputfile outputfile\n", argv[0]);
           exit(1);
       }

       input = argv[1];
       output = argv[2];

       av_register_all();

       char szError[256] = {0};
       int nRet = avformat_open_input(&ic, input, ifmt, &pAVDictionary);
       if (nRet != 0)
       {
           av_strerror(nRet, szError, 256);
           printf(szError);
           printf("\n");
           printf("Call avformat_open_input function failed!\n");
           return 0;
       }

       if (av_find_stream_info(ic) < 0)
       {
           printf("Call av_find_stream_info function failed!\n");
           return 0;
       }

       ofmt = av_guess_format("mpegts", NULL, NULL);
       if (!ofmt)
       {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }

       oc = avformat_alloc_context();
       if (!oc)
       {
           printf("Call av_guess_format function failed!\n");
           return 0;
       }
       oc->oformat = ofmt;

       int video_index = -1, audio_index = -1;
       for (unsigned int i = 0; i < ic->nb_streams && (video_index < 0 || audio_index < 0); i++)
       {
           switch (ic->streams[i]->codec->codec_type)
           {
           case AVMEDIA_TYPE_VIDEO:
               video_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               video_st = add_output_stream(oc, ic->streams[i]);
               break;
           case AVMEDIA_TYPE_AUDIO:
               audio_index = i;
               ic->streams[i]->discard = AVDISCARD_NONE;
               audio_st = add_output_stream(oc, ic->streams[i]);
               break;
           default:
               ic->streams[i]->discard = AVDISCARD_ALL;
               break;
           }
       }
       codec = avcodec_find_decoder(video_st->codec->codec_id);
       if (codec == NULL)
       {
           printf("Call avcodec_find_decoder function failed!\n");
           return 0;
       }

       if (avcodec_open(video_st->codec, codec) < 0)
       {
           printf("Call avcodec_open function failed !\n");
           return 0;
       }

       if (avio_open(&oc->pb, output, AVIO_FLAG_WRITE) < 0)
       {
           return 0;
       }

       if (avformat_write_header(oc, &pAVDictionary))
       {
           printf("Call avformat_write_header function failed.\n");
           return 0;
       }

       //[[++
       AVBitStreamFilterContext *bsfc = av_bitstream_filter_init("h264_mp4toannexb");
       //AVBitStreamFilterContext *absfc = av_bitstream_filter_init("aac_adtstoasc");
       if (!bsfc) {
           fprintf(stderr, "bsf init error!\n");
           return -1;
       }
       //]]++

       int decode_done = 0;
       do
       {
           double segment_time = 0;
           AVPacket packet;

           decode_done = av_read_frame(ic, &packet);
           if (decode_done < 0)
               break;

           if (av_dup_packet(&packet) < 0)
           {
               printf("Call av_dup_packet function failed\n");
               av_free_packet(&packet);
               break;
           }

           //[[**
           if (packet.stream_index == audio_index) {
               segment_time = (double)audio_st->pts.val * audio_st->time_base.num / audio_st->time_base.den;
               nRet = av_interleaved_write_frame(oc, &packet);  
           } else if (packet.stream_index == video_index) {
               if (packet.flags & AV_PKT_FLAG_KEY) {
                   segment_time = (double)video_st->pts.val * video_st->time_base.num / video_st->time_base.den;
               } else {
                   segment_time = prev_segment_time;
               }
               //nRet = av_interleaved_write_frame(oc, &packet);  
               write_frame(oc, &packet, video_st->codec, bsfc);
           }
           //]]**

           if (nRet < 0)
           {
               printf("Call av_interleaved_write_frame function failed: %d\n", nRet);
           }
           else if (nRet > 0)
           {
               printf("End of stream requested\n");
               av_free_packet(&packet);
               break;
           }
           av_free_packet(&packet);
           frame_count++;
       }while(!decode_done);

       av_write_trailer(oc);
       printf("frame_count = %d\n", frame_count);

       av_bitstream_filter_close(bsfc);  
       avcodec_close(video_st->codec);
       for(unsigned int k = 0; k < oc->nb_streams; k++)
       {
           av_freep(&oc->streams[k]->codec);
           av_freep(&oc->streams[k]);
       }
       av_free(oc);
       //getchar();
       return 0;
    }

    Compile this code, to got an executable file named muxts, and then :

    $ ./muxts vid1.mp4 vid1.ts

    No error message printed,but the audio stream was unsynchronized and noise。Check the .ts file using ffmpeg :

    $ ffmpeg -i vid1.ts
    ffmpeg version 0.8.14-tessus, Copyright (c) 2000-2013 the FFmpeg developers
     built on Jul 29 2013 17:05:18 with llvm_gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)
     configuration: --prefix=/usr/local --arch=x86_64 --as=yasm --extra-version=tessus --enable-gpl --enable-nonfree --enable-version3 --disable-ffplay --enable-libvorbis --enable-libmp3lame --enable-libx264 --enable-libxvid --enable-bzlib --enable-zlib --enable-postproc --enable-filters --enable-runtime-cpudetect --enable-debug=3 --disable-optimizations
     libavutil    51.  9. 1 / 51.  9. 1
     libavcodec   53.  8. 0 / 53.  8. 0
     libavformat  53.  5. 0 / 53.  5. 0
     libavdevice  53.  1. 1 / 53.  1. 1
     libavfilter   2. 23. 0 /  2. 23. 0
     libswscale    2.  0. 0 /  2.  0. 0
     libpostproc  51.  2. 0 / 51.  2. 0

    Seems stream 0 codec frame rate differs from container frame rate: 180000.00 (180000/1) -> 90000.00 (180000/2)
    Input #0, mpegts, from 'vid1.ts':
     Duration: 00:00:03.75, start: 0.000000, bitrate: 3656 kb/s
     Program 1
       Metadata:
         service_name    : Service01
         service_provider: FFmpeg
       Stream #0.0[0x100]: Video: h264 (Baseline), yuv420p, 640x480, 90k tbr, 90k tbn, 180k tbc
       Stream #0.1[0x101]: Audio: aac, 48000 Hz, mono, s16, 190 kb/s
    At least one output file must be specified

    What should i do ?

    If this issue fixed , how can i concat multi .ts files into single .mp4 file ?