Recherche avancée

Médias (0)

Mot : - Tags -/protocoles

Aucun média correspondant à vos critères n’est disponible sur le site.

Autres articles (21)

  • Librairies et binaires spécifiques au traitement vidéo et sonore

    31 janvier 2010, par

    Les logiciels et librairies suivantes sont utilisées par SPIPmotion d’une manière ou d’une autre.
    Binaires obligatoires FFMpeg : encodeur principal, permet de transcoder presque tous les types de fichiers vidéo et sonores dans les formats lisibles sur Internet. CF ce tutoriel pour son installation ; Oggz-tools : outils d’inspection de fichiers ogg ; Mediainfo : récupération d’informations depuis la plupart des formats vidéos et sonores ;
    Binaires complémentaires et facultatifs flvtool2 : (...)

  • Les statuts des instances de mutualisation

    13 mars 2010, par

    Pour des raisons de compatibilité générale du plugin de gestion de mutualisations avec les fonctions originales de SPIP, les statuts des instances sont les mêmes que pour tout autre objets (articles...), seuls leurs noms dans l’interface change quelque peu.
    Les différents statuts possibles sont : prepa (demandé) qui correspond à une instance demandée par un utilisateur. Si le site a déjà été créé par le passé, il est passé en mode désactivé. publie (validé) qui correspond à une instance validée par un (...)

  • Problèmes fréquents

    10 mars 2010, par

    PHP et safe_mode activé
    Une des principales sources de problèmes relève de la configuration de PHP et notamment de l’activation du safe_mode
    La solution consiterait à soit désactiver le safe_mode soit placer le script dans un répertoire accessible par apache pour le site

Sur d’autres sites (4032)

  • Using FFMPEG Android Library to convert PCM to m4a [duplicate]

    11 avril 2016, par Cvongrim

    This question already has an answer here :

    I am using https://github.com/WritingMinds/ffmpeg-android-java.

    I have a PCM file that I created using AudioRecord.

    I am now trying to convert the PCM file to an m4a file.

    Running the following command converts it but it speeds up the audio making the voices on the recording sound like the chipmunks.

    Finished command : ffmpeg -f s16be -i /storage/emulated/0/GMT/recordTestNew.pcm -strict -2 -y -c:a aac -b:a 176k /storage/emulated/0/GMT/recordTestFFMPEG.m4a

    Which gives

    SUCCESS with output : WARNING: linker: /data/user/0/com.globalmedicaltranscriptionapp/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
                                                                               ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
                                                                                 built on Oct  7 2014 15:08:46 with gcc 4.8 (GCC)
                                                                                 configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                                 libavutil      54.  7.100 / 54.  7.100
                                                                                 libavcodec     56.  1.100 / 56.  1.100
                                                                                 libavformat    56.  4.101 / 56.  4.101
                                                                                 libavdevice    56.  0.100 / 56.  0.100
                                                                                 libavfilter     5.  1.100 /  5.  1.100
                                                                                 libswscale      3.  0.100 /  3.  0.100
                                                                                 libswresample   1.  1.100 /  1.  1.100
                                                                                 libpostproc    53.  0.100 / 53.  0.100
                                                                               [s16be @ 0xf72ba000] Estimating duration from bitrate, this may be inaccurate
                                                                               Guessed Channel Layout for  Input Stream #0.0 : mono
                                                                               Input #0, s16be, from '/storage/emulated/0/GMT/recordTestNew.pcm':
                                                                                 Duration: 00:00:02.70, bitrate: 705 kb/s
                                                                                   Stream #0:0: Audio: pcm_s16be, 44100 Hz, 1 channels, s16, 705 kb/s
                                                                               Output #0, ipod, to '/storage/emulated/0/GMT/recordTestFFMPEG.m4a':
                                                                                 Metadata:
                                                                                   encoder         : Lavf56.4.101
                                                                                   Stream #0:0: Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s
                                                                                   Metadata:
                                                                                     encoder         : Lavc56.1.100 aac
                                                                               Stream mapping:
                                                                                 Stream #0:0 -> #0:0 (pcm_s16be (native) -> aac (native))
                                                                               Press [q] to stop, [?] for help
                                                                               size=      30kB time=00:00:01.90 bitrate= 130.0kbits/s    
                                                                               size=      44kB time=00:00:02.71 bitrate= 131.8kbits/s    
                                                                               video:0kB audio:43kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.801121%

    The audio clip should actually be about 11 seconds long. The frequency should be 11025, The encoding is using Android’s AudioFormat.ENCODING_PCM_16BIT, the channels are using AndioFormat.CHANNEL_IN_DEFAULT.

    This is my first time working with audio so it’s been a struggle. The reason why I am using AudioRecord is because I need the audio files to be in a form that allows me to split them and potentially add new audio clips in the middle.

    It seems like an issue due to the frequency not being passed to the output. I tried updating the above command to

    Finished command : ffmpeg -f s16be -ar 11025 -i /storage/emulated/0/GMT/recordTestNew.pcm -strict -2 -y -c:a aac /storage/emulated/0/GMT/recordTestFFMPEG.m4a

    Which gives

    FAILED with output : WARNING: linker: /data/user/0/com.globalmedicaltranscriptionapp/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
                                                                               ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
                                                                                 built on Oct  7 2014 15:08:46 with gcc 4.8 (GCC)
                                                                                 configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                                 libavutil      54.  7.100 / 54.  7.100
                                                                                 libavcodec     56.  1.100 / 56.  1.100
                                                                                 libavformat    56.  4.101 / 56.  4.101
                                                                                 libavdevice    56.  0.100 / 56.  0.100
                                                                                 libavfilter     5.  1.100 /  5.  1.100
                                                                                 libswscale      3.  0.100 /  3.  0.100
                                                                                 libswresample   1.  1.100 /  1.  1.100
                                                                                 libpostproc    53.  0.100 / 53.  0.100
                                                                               [s16be @ 0xf707a000] Estimating duration from bitrate, this may be inaccurate
                                                                               Guessed Channel Layout for  Input Stream #0.0 : mono
                                                                               Input #0, s16be, from '/storage/emulated/0/GMT/recordTestNew.pcm':
                                                                                 Duration: 00:00:10.81, bitrate: 176 kb/s
                                                                                   Stream #0:0: Audio: pcm_s16be, 11025 Hz, 1 channels, s16, 176 kb/s
                                                                               [aac @ 0xf7043c00] Too many bits per frame requested
                                                                               Output #0, ipod, to '/storage/emulated/0/GMT/recordTestFFMPEG.m4a':
                                                                                   Stream #0:0: Audio: aac, 0 channels, 128 kb/s
                                                                                   Metadata:
                                                                                     encoder         : Lavc56.1.100 aac
                                                                               Stream mapping:
                                                                                 Stream #0:0 -> #0:0 (pcm_s16be (native) -> aac (native))
                                                                               Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

    04-11 14:22:23.029 11026-11026/com.globalmedicaltranscriptionapp D/AudioPlayer : Finished command : ffmpeg -f s16be -ar 11025 -i /storage/emulated/0/GMT/recordTestNew.pcm -strict -2 -y -c:a aac /storage/emulated/0/GMT/recordTestFFMPEG.m4a

    Doing that makes the input seem to have the correct duration and bit rate but then I get the following error.

    Stream #0:0 -> #0:0 (pcm_s16be (native) -> aac (native))
    Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

    I have tried a million other configurations but still can’t get it to work.

    What am I doing wrong ?

  • Merging two audio files in Android using FFMPEG

    3 août 2016, par Jeremy

    I’m working on an application that takes two audio files, and merges them into the respected channels. The way they are being equalized are not as good as I had hoped, So I want to adjust the volume of each file during the mixing phase. I’ve seen a couple of examples online, like this, this, and [this][3].. but none of them are working for me. Can someone direct me in the right direction with this ? Much appreciation !

    I am using this library to execute : https://github.com/WritingMinds/ffmpeg-android-java

    Here is my code (EDIT)

    String files = "-i " + mVoiceFile.getAbsolutePath() + " -i " + mBeatFile.getAbsolutePath();
    String filter = "-filter_complex [0:a]volume=0.99[a1];[1:a]volume=0.3[a2][a1][a2]amerge=inputs=2,volume=1.3,pan=stereo|c0code>

    enter code here

    and here are my errors from running.

    04-06 12:17:34.079 30975-30975/me.rapchat.rapchat E/Studio Process: WARNING: linker: /data/user/0/me.rapchat.rapchat/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
    04-06 12:17:34.306 30975-30975/me.rapchat.rapchat E/Studio Process: ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
    04-06 12:17:34.306 30975-30975/me.rapchat.rapchat E/Studio Process:   built on Oct  7 2014 15:08:46 with gcc 4.8 (GCC)
    04-06 12:17:34.306 30975-30975/me.rapchat.rapchat E/Studio Process:   configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
    04-06 12:17:34.307 30975-30975/me.rapchat.rapchat E/Studio Process:   libavutil      54.  7.100 / 54.  7.100
    04-06 12:17:34.307 30975-30975/me.rapchat.rapchat E/Studio Process:   libavcodec     56.  1.100 / 56.  1.100
    04-06 12:17:34.307 30975-30975/me.rapchat.rapchat E/Studio Process:   libavformat    56.  4.101 / 56.  4.101
    04-06 12:17:34.307 30975-30975/me.rapchat.rapchat E/Studio Process:   libavdevice    56.  0.100 / 56.  0.100
    04-06 12:17:34.308 30975-30975/me.rapchat.rapchat E/Studio Process:   libavfilter     5.  1.100 /  5.  1.100
    04-06 12:17:34.308 30975-30975/me.rapchat.rapchat E/Studio Process:   libswscale      3.  0.100 /  3.  0.100
    04-06 12:17:34.308 30975-30975/me.rapchat.rapchat E/Studio Process:   libswresample   1.  1.100 /  1.  1.100
    04-06 12:17:34.308 30975-30975/me.rapchat.rapchat E/Studio Process:   libpostproc    53.  0.100 / 53.  0.100
    04-06 12:17:34.372 30975-30975/me.rapchat.rapchat E/Studio Process: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/recording.m4a':
    04-06 12:17:34.373 30975-30975/me.rapchat.rapchat E/Studio Process:   Metadata:
    04-06 12:17:34.373 30975-30975/me.rapchat.rapchat E/Studio Process:     major_brand     : mp42
    04-06 12:17:34.373 30975-30975/me.rapchat.rapchat E/Studio Process:     minor_version   : 0
    04-06 12:17:34.374 30975-30975/me.rapchat.rapchat E/Studio Process:     compatible_brands: isommp42
    04-06 12:17:34.374 30975-30975/me.rapchat.rapchat E/Studio Process:     creation_time   : 2016-04-06 19:17:33
    04-06 12:17:34.374 30975-30975/me.rapchat.rapchat E/Studio Process:   Duration: 00:00:01.56, start: 0.000000, bitrate: 144 kb/s
    04-06 12:17:34.375 30975-30975/me.rapchat.rapchat E/Studio Process:     Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s (default)
    04-06 12:17:34.375 30975-30975/me.rapchat.rapchat E/Studio Process:     Metadata:
    04-06 12:17:34.375 30975-30975/me.rapchat.rapchat E/Studio Process:       creation_time   : 2016-04-06 19:17:33
    04-06 12:17:34.375 30975-30975/me.rapchat.rapchat E/Studio Process:       handler_name    : SoundHandle
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process: Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/beats/d3c37d60-ed50-4c00-b454-4e399a7858ff.m4a':
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:   Metadata:
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     major_brand     : mp42
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     minor_version   : 0
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     compatible_brands: mp42isom
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     creation_time   : 1993-11-24 14:46:42
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     encoder         : Max 0.9.1
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     iTunSMPB        : 00000000 00000840 000003c0 000000000035dc00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:     date            : 2015
    04-06 12:17:34.401 30975-30975/me.rapchat.rapchat E/Studio Process:   Duration: 00:01:20.04, start: 0.047891, bitrate: 129 kb/s
    04-06 12:17:34.402 30975-30975/me.rapchat.rapchat E/Studio Process:     Stream #1:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
    04-06 12:17:34.402 30975-30975/me.rapchat.rapchat E/Studio Process:     Metadata:
    04-06 12:17:34.402 30975-30975/me.rapchat.rapchat E/Studio Process:       creation_time   : 1993-11-24 14:46:42
    04-06 12:17:34.404 30975-30975/me.rapchat.rapchat E/Studio Process: [NULL @ 0xb5e4fc00] Unable to find a suitable output format for '[a1][a2]amerge,pan=stereo|c0me.rapchat.rapchat E/Studio Process: [a1][a2]amerge,pan=stereo|c0me.rapchat.rapchat E/Studio Status Failed: WARNING: linker: /data/user/0/me.rapchat.rapchat/files/ffmpeg has text relocations. This is wasting memory and prevents security hardening. Please fix.
                                                                             ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developers
                                                                               built on Oct  7 2014 15:08:46 with gcc 4.8 (GCC)
                                                                               configuration: --target-os=linux --cross-prefix=/home/sb/Source-Code/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/sb/Source-Code/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon --extra-cflags='-I/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all -mfpu=neon' --extra-ldflags='-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
                                                                               libavutil      54.  7.100 / 54.  7.100
                                                                               libavcodec     56.  1.100 / 56.  1.100
                                                                               libavformat    56.  4.101 / 56.  4.101
                                                                               libavdevice    56.  0.100 / 56.  0.100
                                                                               libavfilter     5.  1.100 /  5.  1.100
                                                                               libswscale      3.  0.100 /  3.  0.100
                                                                               libswresample   1.  1.100 /  1.  1.100
                                                                               libpostproc    53.  0.100 / 53.  0.100
                                                                             Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/recording.m4a':
                                                                               Metadata:
                                                                                 major_brand     : mp42
                                                                                 minor_version   : 0
                                                                                 compatible_brands: isommp42
                                                                                 creation_time   : 2016-04-06 19:17:33
                                                                               Duration: 00:00:01.56, start: 0.000000, bitrate: 144 kb/s
                                                                                 Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 128 kb/s (default)
                                                                                 Metadata:
                                                                                   creation_time   : 2016-04-06 19:17:33
                                                                                   handler_name    : SoundHandle
                                                                             Input #1, mov,mp4,m4a,3gp,3g2,mj2, from '/data/user/0/me.rapchat.rapchat/cache/beats/d3c37d60-ed50-4c00-b454-4e399a7858ff.m4a':
                                                                               Metadata:
                                                                                 major_brand     : mp42
                                                                                 minor_version   : 0
                                                                                 compatible_brands: mp42isom
                                                                                 creation_time   : 1993-11-24 14:46:42
                                                                                 encoder         : Max 0.9.1
                                                                                 iTunSMPB        : 00000000 00000840 000003c0 000000000035dc00 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
                                                                                 date            : 2015
                                                                               Duration: 00:01:20.04, start: 0.047891, bitrate: 129 kb/s
                                                                                 Stream #1:0(eng): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)
                                                                                 Metadata:
                                                                                   creation_time   : 1993-11-24 14:46:42
                                                                             [NULL @ 0xb5e4fc00] Unable to find a suitable output format for '[a1][a2]amerge,pan=stereo|c0code>
  • H264 Encoding - Could not play video using VLC Player

    31 mars 2016, par bot1131357

    I am have trouble encoding an H264 video correctly using FFmpeg libav. I could not play the encoded video in VLC media player, and although I could play the video on MPC-HC the time shows 00:00/00:00. Clearly I’m missing something.

    The Media info from MPC-HC shows this :

    General
    Format : AVC
    Format/Info : Advanced Video Codec
    File size : 110 KiB
    Duration : 2s 400ms
    Overall bit rate : 375 Kbps
    Writing library : x264 core 148 r2665 a01e339
    Encoding settings : cabac=0 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=7 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=12 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=12 / rc=abr / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

    Video
    Format : AVC
    Format/Info : Advanced Video Codec
    Format profile : Baseline@L2.1
    Format settings, CABAC : No
    Format settings, ReFrames : 3 frames
    Format settings, GOP : M=1, N=12
    Duration : 2s 400ms
    Bit rate : 2 000 Kbps
    Width : 320 pixels
    Height : 240 pixels
    Display aspect ratio : 4:3
    Frame rate mode : Variable
    Frame rate : 20.833 fps
    Color space : YUV
    Chroma subsampling : 4:2:0
    Bit depth : 8 bits
    Scan type : Progressive
    Bits/(Pixel*Frame) : 1.250
    Stream size : 586 KiB
    Writing library : x264 core 148 r2665 a01e339
    Encoding settings : cabac=0 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=7 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=0 / weightp=0 / keyint=12 / keyint_min=1 / scenecut=40 / intra_refresh=0 / rc_lookahead=12 / rc=abr / mbtree=1 / bitrate=2000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00

    I noticed something odd in the above info :
    - The frame rate is 20.833 fps, instead of the specified 10 fps.
    - Duration of 2s 400ms did not seem right either, since the video played for more than 4s.

    Also, (AVFrame* picture)->pict_type is always set to AV_PICTURE_TYPE_NONE. I don’t think this is normal.

    The library that I’m using is ffmpeg-20160219-git-98a0053-win32-dev. I would really really appreciate if you could help me out of this confusion.

    /*
    * Video encoding example
    */
    char filename[] = "test.mp4";
    int main(int argc, char** argv)
    {
       AVCodec *codec = NULL;
       AVCodecContext *codecCtx= NULL;
       AVFormatContext *pFormatCtx = NULL;
       AVStream * pVideoStream = NULL;
       AVFrame *picture = NULL;

       int i, x, y,            //
           ret,                // Return value
           got_packet_ptr;     // Data encoded into packet

       printf("Video encoding\n");

       // Register all formats and codecs
       av_register_all();

       // allocate context
       pFormatCtx = avformat_alloc_context();
       memcpy(pFormatCtx->filename,filename,
           min(strlen(filename), sizeof(pFormatCtx->filename)));

       // guess format
       pFormatCtx->oformat = av_guess_format("h264", NULL, NULL);
       if (NULL==pFormatCtx->oformat)
       {
           cerr << "Could not guess output format" << endl;
           return -1;
       }  

       // Find the codec.
       codec = avcodec_find_encoder(pFormatCtx->oformat->video_codec);
       if (codec == NULL) {
           fprintf(stderr, "Codec not found\n");
           return -1;
       }

       // Set context
       int framerate = 10;
       codecCtx = avcodec_alloc_context3(codec);
       avcodec_get_context_defaults3(codecCtx, codec);
       codecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
       codecCtx->profile = FF_PROFILE_H264_BASELINE;
       // Resolution must be a multiple of two.
       codecCtx->width  = 320;
       codecCtx->height = 240;

       codecCtx->bit_rate = 2000000;
       codecCtx->time_base.den = framerate;
       codecCtx->time_base.num = 1;
       codecCtx->gop_size = 12; // emit one intra frame every twelve frames at most

       // Open the codec.  
       if (avcodec_open2(codecCtx, codec, NULL) < 0)
       {
           printf("Cannot open video codec\n");
           return -1;
       }

       // Add stream to pFormatCtx
       pVideoStream = avformat_new_stream(pFormatCtx, codec);
       if (!pVideoStream)
       {
           printf("Cannot add new video stream\n");
           return -1;
       }
       pVideoStream->codec = codecCtx;
       pVideoStream->time_base.den = framerate;
       pVideoStream->time_base.num = 1;

       if (avio_open2(&pFormatCtx->pb, filename, AVIO_FLAG_WRITE, NULL, NULL) < 0)
       {
           printf("Cannot open file\n");
           return -1;
       }

       // Write file header.
       avformat_write_header(pFormatCtx, NULL);

       // Create frame
       picture= av_frame_alloc();
       picture->format = codecCtx->pix_fmt;
       picture->width  = codecCtx->width;
       picture->height = codecCtx->height;

       int bufferImgSize = av_image_get_buffer_size(codecCtx->pix_fmt, codecCtx->width,
                       codecCtx->height,1);    
       av_image_alloc(picture->data, picture->linesize, codecCtx->width, codecCtx->height,                 codecCtx->pix_fmt, 32);

       AVPacket avpkt;

       /* encode 1 second of video */
       for(i=0;i<50;i++)
       {
           /* prepare a dummy image */
           /* Y */
           for(y=0;yheight;y++)
           {
               for(x=0;xwidth;x++)
               {
                   picture->data[0][y * picture->linesize[0] + x] = x + y + i * 3;
               }
           }
           /* Cb and Cr */
           for(y=0;yheight/2;y++)
           {
               for(x=0;xwidth/2;x++)
               {
                   picture->data[1][y * picture->linesize[1] + x] = 128 + y + i * 2;
                   picture->data[2][y * picture->linesize[2] + x] = 64 + x + i * 5;
               }
           }

           // Get timestamp
           picture->pts = (float) i * (1000.0/(float)(codecCtx->time_base.den)) * 90;

           // Encode frame to packet
           av_init_packet(&avpkt);
           got_packet_ptr = 0;
           int error = avcodec_encode_video2(codecCtx, &avpkt, picture, &got_packet_ptr);
           if (!error && got_packet_ptr > 0)
           {
               // Write packet with frame.
               ret = (av_interleaved_write_frame(pFormatCtx, &avpkt) == 0);        
           }  
           av_packet_unref(&avpkt);
       }

       // Flush remaining encoded data
       while(1)
       {
           av_init_packet(&avpkt);
           got_packet_ptr = 0;
           // Encode frame to packet.
           int error = avcodec_encode_video2(codecCtx, &avpkt, NULL, &got_packet_ptr);
           if (!error && got_packet_ptr > 0)
           {
               // Write packet with frame.
               ret = (av_interleaved_write_frame(pFormatCtx, &avpkt) == 0);        
           }
           else
           {
               break;
           }
           av_packet_unref(&avpkt);
       }
       av_write_trailer(pFormatCtx);

       av_packet_unref(&avpkt);
       av_frame_free(&picture);

       avcodec_close(codecCtx);
       av_free(codecCtx);

       cin.get();
    }