Recherche avancée

Médias (1)

Mot : - Tags -/stallman

Autres articles (103)

  • ANNEXE : Les plugins utilisés spécifiquement pour la ferme

    5 mars 2010, par

    Le site central/maître de la ferme a besoin d’utiliser plusieurs plugins supplémentaires vis à vis des canaux pour son bon fonctionnement. le plugin Gestion de la mutualisation ; le plugin inscription3 pour gérer les inscriptions et les demandes de création d’instance de mutualisation dès l’inscription des utilisateurs ; le plugin verifier qui fournit une API de vérification des champs (utilisé par inscription3) ; le plugin champs extras v2 nécessité par inscription3 (...)

  • 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 (...)

  • Activation de l’inscription des visiteurs

    12 avril 2011, par

    Il est également possible d’activer l’inscription des visiteurs ce qui permettra à tout un chacun d’ouvrir soit même un compte sur le canal en question dans le cadre de projets ouverts par exemple.
    Pour ce faire, il suffit d’aller dans l’espace de configuration du site en choisissant le sous menus "Gestion des utilisateurs". Le premier formulaire visible correspond à cette fonctionnalité.
    Par défaut, MediaSPIP a créé lors de son initialisation un élément de menu dans le menu du haut de la page menant (...)

Sur d’autres sites (11604)

  • ffmpeg android concatenation with different codec [on hold]

    31 mars 2016, par raphwilmes

    I’m trying to concatenate 10 videos, but 5 of them have
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)

    And the rest have
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)

    And my code is :

    String commandForMerge = "";
    for(int i = 1; i<=numberQuestion;i++){
       commandForMerge += "-i "+toDir+"/image"+i+".mp4 -i "+toDir+"/"+i+".mp4 ";
    }
    String cmd = commandForMerge+"-filter_complex concat=n=10:v=1:a=1 -y "+toDir+"/input.mp4";
    execFFmpegBinaryMerge(cmd);

    Here my fonction :

    private void execFFmpegBinaryMerge(final String command) {
       try {

           ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
               @Override
               public void onFailure(String s) {
               }

               @Override
               public void onSuccess(String s) {
               }

               @Override
               public void onProgress(String s) {
                   txtProcess.setText(txtProcess.getText()+"\n "+s.toString());
               }

               @Override
               public void onStart() {
                   txtProcess.setText("mise en place...");
               }

               @Override
               public void onFinish() {

               }
           });
       } catch (FFmpegCommandAlreadyRunningException e) {
           // do nothing for now
       }
    }

    I use this library : https://github.com/WritingMinds/ffmpeg-android-java

    Edit :

    Now, I’v this : Unable to find a suitable output format for ’[1:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v1] ;’ Invalid Agurment

    My Command is : *ffmpeg -i image1.mp4 -i 1.mp4 -i image2.mp4 -i 2.mp4 -i image3.mp4 -i 3.mp4.mp4 -i image4.mp4 -i 4.mp4 -i image5.mp4 -i .mp4

    - filter-complex
    "[0:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v0] ;
    [1:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v1] ;
    [2:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v2] ;
    [3:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v3] ;
    [4:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v4] ;
    [5:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v5] ;
    [6:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v6] ;
    [7:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v7] ;
    [8:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v8] ;
    [9:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v9] ;"
    ’[v0][0:a][v1][1:a][v2][2:a][v3][3:a][v4][4:a][v5][5:a][v6][6:a][v7][7:a][v8][8:a][v9][9:a]’ concat=n=10:v=1:a=1 -y output.mp4
    *

    Now the "[0:v]scale=-1:480,pad=640:0 :(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v0] ;" pass but not the [1:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v1] ;

    output :

    WARINING:linker : /data/data/vrapp_mobile.com.duoquiz2/files/ffmpeg has text relocation. This is wasting memory and is security risk. Please fix.
    ffmpeg version n2.4.2 Copyright (c) 2000-2014 the FFmpeg developpers 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- —arm=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-libfrididi —enable-fontconfig —enable-pthreads —disable-debug —disable-ffserver —enable-version3 —enable-hardcored-tables —disable-ffplay —disable-ffprobe —enable-gpl —enable-yasm —disable-doc —disable-shared —enable-static —pjg-config=/home/sb/Source-Code/ffmpeg-android/ffmpeg-pkg-config —prefix=/home/sb/Source-Code/ffmpeg-android/build/armeabi-v7a-neon —extra-cflags=’-l/home/sb/Source-Code/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protextor-all -mfpu=neon’ —extra-ldflags=’-L/home/sb/Source-Code/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,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,mj2, from ’/storage/emulated/0/DuoQuiz/image1.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :512
    compatible_brands:isomiso2avc1mp41
    encoder :Lavf56.4.101
    Duration : 00:00:02.40, start : 0.023021 , bitrate : 334 kb/s
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata :
    handler_name : VideoHandler
    Stream #0:1(und) : Audio.mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 320 kb/s (default)
    Metadata :
    handler_name :SoundHandler
    Input #1,mov,mp4,m4a,3gp,3g2,mj2, from ’/storage/emulated/0/DuoQuiz/1.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :0
    compatible_brands:isom3gp4
    creation_time :2016-03-21 16:05:25
    Duration : 00:00:02.73, start : 0.000000, bitrate : 229 kb/s
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)
    Metadata :
    rotate :270
    creation_time :2016-03-21 16:05:25
    handler_name :VideoHandle
    Side data :
    displaymatrix : rotation of 90.00 degrees
    Stream #1:1(eng) : Audio : aac (mp4a / 0x6134706D),44100 Hz, mono, fltp, 49 kb/s (default)
    Metadata :
    creation_time :2016-03-21 16:05:25
    handler_name :SoundHandle
    Input #2,mov,mp4,m4a,3gp,mj2, from ’/storage/emulated/0/DuoQuiz/image2.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :512
    compatible_brands:isomiso2avc1mp41
    encoder :Lavf56.4.101
    Duration : 00:00:02.40, start : 0.023021 , bitrate : 334 kb/s
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata :
    handler_name : VideoHandler
    Stream #0:1(und) : Audio.mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 320 kb/s (default)
    Metadata :
    handler_name :SoundHandler
    Input #3,mov,mp4,m4a,3gp,3g2,mj2, from ’/storage/emulated/0/DuoQuiz/2.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :0
    compatible_brands:isom3gp4
    creation_time :2016-03-21 16:05:25
    Duration : 00:00:02.73, start : 0.000000, bitrate : 229 kb/s
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)
    Metadata :
    rotate :270
    creation_time :2016-03-21 16:05:25
    handler_name :VideoHandle
    Side data :
    displaymatrix : rotation of 90.00 degrees
    Stream #1:1(eng) : Audio : aac (mp4a / 0x6134706D),44100 Hz, mono, fltp, 49 kb/s (default)
    Metadata :
    creation_time :2016-03-21 16:05:25
    handler_name :SoundHandle
    Input #4,mov,mp4,m4a,3gp,mj2, from ’/storage/emulated/0/DuoQuiz/image3.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :512
    compatible_brands:isomiso2avc1mp41
    encoder :Lavf56.4.101
    Duration : 00:00:02.40, start : 0.023021 , bitrate : 334 kb/s
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata :
    handler_name : VideoHandler
    Stream #0:1(und) : Audio.mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 320 kb/s (default)
    Metadata :
    handler_name :SoundHandler
    Input #5,mov,mp4,m4a,3gp,3g2,mj2, from ’/storage/emulated/0/DuoQuiz/3.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :0
    compatible_brands:isom3gp4
    creation_time :2016-03-21
    Duration : 00:00:02.73, start : 0.000000, bitrate : 229 kb/s
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)
    Metadata :
    rotate :270
    creation_time :2016-03-2116:05:25
    handler_name :VideoHandle
    Side data :
    displaymatrix : rotation of 90.00 degrees
    Stream #1:1(eng) : Audio : aac (mp4a / 0x6134706D),44100 Hz, mono, fltp, 49 kb/s (default)
    Metadata :
    creation_time :2016-03-21 16:05:25
    handler_name :SoundHandle
    Input #6,mov,mp4,m4a,3gp,mj2, from ’/storage/emulated/0/DuoQuiz/image4.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :512
    compatible_brands:isomiso2avc1mp41
    encoder :Lavf56.4.101
    Duration : 00:00:02.40, start : 0.023021 , bitrate : 334 kb/s
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata :
    handler_name : VideoHandler
    Stream #0:1(und) : Audio.mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 320 kb/s (default)
    Metadata :
    handler_name :SoundHandler
    Input #7,mov,mp4,m4a,3gp,3g2,mj2, from ’/storage/emulated/0/DuoQuiz/4.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :0
    compatible_brands:isom3gp4
    creation_time :2016-03-21
    Duration : 00:00:02.73, start : 0.000000, bitrate : 229 kb/s
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)
    Metadata :
    rotate :270
    creation_time :2016-03-2116:05:25
    handler_name :VideoHandle
    Side data :
    displaymatrix : rotation of 90.00 degrees
    Stream #1:1(eng) : Audio : aac (mp4a / 0x6134706D),44100 Hz, mono, fltp, 49 kb/s (default)
    Metadata :
    creation_time :2016-03-21 16:05:25
    handler_name :SoundHandle
    Input #8,mov,mp4,m4a,3gp,mj2, from ’/storage/emulated/0/DuoQuiz/image5.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :512
    compatible_brands:isomiso2avc1mp41
    encoder :Lavf56.4.101
    Duration : 00:00:02.40, start : 0.023021 , bitrate : 334 kb/s
    Stream #0:0(und) : Video : h264 (High) (avc1 / 0x31637661), yuv420p, 600x976 [SAR 1:1 DAR 75:122], 17 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata :
    handler_name : VideoHandler
    Stream #0:1(und) : Audio.mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 320 kb/s (default)
    Metadata :
    handler_name :SoundHandler
    Input #9,mov,mp4,m4a,3gp,3g2,mj2, from ’/storage/emulated/0/DuoQuiz/5.mp4’ :
    Metadata :
    major_brand :isom
    minor_version :0
    compatible_brands:isom3gp4
    creation_time :2016-03-21
    Duration : 00:00:02.73, start : 0.000000, bitrate : 229 kb/s
    Stream #1:0(eng) : Video : h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 640x480x 175 kb/s, SAR 65536:65536 DAR 4:3, 7.69frp, 23.08 tbr, 90k tbn, 15tbc (default)
    Metadata :
    rotate :270
    creation_time :2016-03-2116:05:25
    handler_name :VideoHandle
    Side data :
    displaymatrix : rotation of 90.00 degrees
    Stream #1:1(eng) : Audio : aac (mp4a / 0x6134706D),44100 Hz, mono, fltp, 49 kb/s (default)
    Metadata :
    creation_time :2016-03-21 16:05:25
    handler_name :SoundHandle
    [AVFilterGraph @ 0x2b5b2e10] No such filter : ""
    Error configuring filter
    *

    On my computer, i try this command :

    -i image1.mp4 -i 1.mp4 -i image2.mp4 -i 2.mp4 -i image3.mp4 -i 3.mp4 -i image4.mp4 -i 4.mp4 -i image5.mp4 -i 5.mp4 -filter_complex "[0:v]scale=-1:480,pad=640:0:(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v0]; [1:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v1]; [2:v]scale=-1:480,pad=640:0:(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v2]; [3:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v3]; [4:v]scale=-1:480,pad=640:0:(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v4]; [5:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v5]; [6:v]scale=-1:480,pad=640:0:(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v6]; [7:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v7]; [8:v]scale=-1:480,pad=640:0:(ow-iw)/2,setsar=1,setpts=PTS-STARTPTS[v8]; [9:v]fps=25,setsar=1,setpts=PTS-STARTPTS[v9]; [v0][0:a][v1][1:a][v2][2:a][v3][3:a][v4][4:a][v5][5:a][v6][6:a][v7][7:a][v8][8:a][v9][9:a] concat=n=10:v=1:a=1" -y output.mp4

    That’s ok on my PC but not on my Android

  • ffmpeg way to encode h265 video that allows fast-forward play without jumps

    27 octobre 2022, par SysHex

    Let me start of by saying that this issue presents itself on a Android headset, while running a Unity app with unity video player component that plays a video on it at 2 times the speed. Hence, the issue might be related to these components and not the video file itself.

    


    I have a library of video files with properties as I will describe further down this post.

    


    When I play these files at 2x the speed , the become extremelly jumpy to the point they can't be watched.

    


    I've played with configurations such as : min-keyint=30:keyint=30:scenecut=0:open-gop=0:lossless=1 but I have to be honest and state that I have almost no clue as to what they do. I've read the documentation and understand gop, I-Frames , and the need to exist reference frames for fast seek, and almost for sure Fast playing of the file (?! maybe not ?) , but don't know how to fine tune this.

    


    Maybe I'm missing out something completely and/or someone as any advice as to what I could try ?

    


    The goal is to play these files at 2x its speed, or possibly faster.

    


    Now for the details on the mpeg4 files :

    


    Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L5@Main
Codec ID                                 : hev1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 15 min 0 s
Bit rate                                 : 6 578 kb/s
Width                                    : 3 840 pixels
Height                                   : 2 160 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 30.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0 (Type 0)
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.026
Stream size                              : 706 MiB (98%)
Writing library                          : x265 3.5+37-07b011400:[Windows][GCC 11.2.0][64 bit] 8bit+10bit+12bit
Encoding settings                        : cpuid=1111039 / frame-threads=3 / numa-pools=8 / wpp / no-pmode / no-pme / no-psnr / no-ssim / log-level=2 / input-csp=1 / input-res=3840x2160 / interlace=0 / total-frames=0 / level-idc=0 / high-tier=1 / uhd-bd=0 / ref=4 / no-allow-non-conformance / no-repeat-headers / annexb / no-aud / no-eob / no-eos / no-hrd / info / hash=0 / no-temporal-layers / open-gop / min-keyint=25 / keyint=250 / gop-lookahead=0 / bframes=4 / b-adapt=2 / b-pyramid / bframe-bias=0 / rc-lookahead=25 / lookahead-slices=4 / scenecut=40 / no-hist-scenecut / radl=0 / no-splice / no-intra-refresh / ctu=64 / min-cu-size=8 / rect / no-amp / max-tu-size=32 / tu-inter-depth=1 / tu-intra-depth=1 / limit-tu=0 / rdoq-level=2 / dynamic-rd=0.00 / no-ssim-rd / signhide / no-tskip / nr-intra=0 / nr-inter=0 / no-constrained-intra / strong-intra-smoothing / max-merge=3 / limit-refs=3 / limit-modes / me=3 / subme=3 / merange=57 / temporal-mvp / no-frame-dup / no-hme / weightp / no-weightb / no-analyze-src-pics / deblock=0:0 / sao / no-sao-non-deblock / rd=4 / selective-sao=4 / no-early-skip / rskip / no-fast-intra / no-tskip-fast / no-cu-lossless / no-b-intra / no-splitrd-skip / rdpenalty=0 / psy-rd=2.00 / psy-rdoq=1.00 / no-rd-refine / no-lossless / cbqpoffs=0 / crqpoffs=0 / rc=crf / crf=20.0 / qcomp=0.60 / qpstep=4 / stats-write=0 / stats-read=0 / ipratio=1.40 / pbratio=1.30 / aq-mode=2 / aq-strength=1.00 / cutree / zone-count=0 / no-strict-cbr / qg-size=32 / no-rc-grain / qpmax=69 / qpmin=0 / no-const-vbv / sar=0 / overscan=0 / videoformat=5 / range=0 / colorprim=1 / transfer=1 / colormatrix=1 / chromaloc=1 / chromaloc-top=0 / chromaloc-bottom=0 / display-window=0 / cll=0,0 / min-luma=0 / max-luma=255 / log2-max-poc-lsb=8 / vui-timing-info / vui-hrd-info / slices=1 / no-opt-qp-pps / no-opt-ref-list-length-pps / no-multi-pass-opt-rps / scenecut-bias=0.05 / hist-threshold=0.03 / no-opt-cu-delta-qp / no-aq-motion / no-hdr10 / no-hdr10-opt / no-dhdr10-opt / no-idr-recovery-sei / analysis-reuse-level=0 / analysis-save-reuse-level=0 / analysis-load-reuse-level=0 / scale-factor=0 / refine-intra=0 / refine-inter=0 / refine-mv=1 / refine-ctu-distortion=0 / no-limit-sao / ctu-info=0 / no-lowpass-dct / refine-analysis-type=0 / copy-pic=1 / max-ausize-factor=1.0 / no-dynamic-refine / no-single-sei / no-hevc-aq / no-svt / no-field / qp-adaptation-range=1.00 / scenecut-aware-qp=0conformance-window-offsets / right=0 / bottom=0 / decoder-max-rate=0 / no-vbv-live-multi-pass
Language                                 : English
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709
Codec configuration box                  : hvcC

Audio
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 15 min 0 s
Source duration                          : 15 min 0 s
Source_Duration_LastFrame                : -12 ms
Bit rate mode                            : Constant
Bit rate                                 : 128 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 13.8 MiB (2%)
Source stream size                       : 13.8 MiB (2%)
Default                                  : Yes
Alternate group                          : 1
mdhd_Duration                            : 900233



    


  • how can I copy file frame by frame to get exactly the same file ? (FFmpeg)

    14 février 2018, par user3360601

    I was using an ffmpeg example from original source remuxing.c to copy file by frames. It works, but the result file has another structure inside. enter image description here

    From the left is original file. It has "framerate" field. Moreover, the copy file has smaller size. On 18 bytes less.

    Question : how can I copy file frame by frame to get exactly the same file ? Including "framerate" field and total size ?

    Code from the source site.

       /*
    * Copyright (c) 2013 Stefano Sabatini
    *
    * Permission is hereby granted, free of charge, to any person obtaining a copy
    * of this software and associated documentation files (the "Software"), to deal
    * in the Software without restriction, including without limitation the rights
    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    * copies of the Software, and to permit persons to whom the Software is
    * furnished to do so, subject to the following conditions:
    *
    * The above copyright notice and this permission notice shall be included in
    * all copies or substantial portions of the Software.
    *
    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
    * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    * THE SOFTWARE.
    */

    /**
    * @file
    * libavformat/libavcodec demuxing and muxing API example.
    *
    * Remux streams from one container format to another.
    * @example remuxing.c
    */

    #include <libavutil></libavutil>timestamp.h>
    #include <libavformat></libavformat>avformat.h>

    static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt, const char *tag)
    {
       AVRational *time_base = &amp;fmt_ctx->streams[pkt->stream_index]->time_base;

       printf("%s: pts:%s pts_time:%s dts:%s dts_time:%s duration:%s duration_time:%s stream_index:%d\n",
              tag,
              av_ts2str(pkt->pts), av_ts2timestr(pkt->pts, time_base),
              av_ts2str(pkt->dts), av_ts2timestr(pkt->dts, time_base),
              av_ts2str(pkt->duration), av_ts2timestr(pkt->duration, time_base),
              pkt->stream_index);
    }

    int main(int argc, char **argv)
    {
       AVOutputFormat *ofmt = NULL;
       AVFormatContext *ifmt_ctx = NULL, *ofmt_ctx = NULL;
       AVPacket pkt;
       const char *in_filename, *out_filename;
       int ret, i;
       int stream_index = 0;
       int *stream_mapping = NULL;
       int stream_mapping_size = 0;

       if (argc &lt; 3) {
           printf("usage: %s input output\n"
                  "API example program to remux a media file with libavformat and libavcodec.\n"
                  "The output format is guessed according to the file extension.\n"
                  "\n", argv[0]);
           return 1;
       }

       in_filename  = argv[1];
       out_filename = argv[2];

       av_register_all();

       if ((ret = avformat_open_input(&amp;ifmt_ctx, in_filename, 0, 0)) &lt; 0) {
           fprintf(stderr, "Could not open input file '%s'", in_filename);
           goto end;
       }

       if ((ret = avformat_find_stream_info(ifmt_ctx, 0)) &lt; 0) {
           fprintf(stderr, "Failed to retrieve input stream information");
           goto end;
       }

       av_dump_format(ifmt_ctx, 0, in_filename, 0);

       avformat_alloc_output_context2(&amp;ofmt_ctx, NULL, NULL, out_filename);
       if (!ofmt_ctx) {
           fprintf(stderr, "Could not create output context\n");
           ret = AVERROR_UNKNOWN;
           goto end;
       }

       stream_mapping_size = ifmt_ctx->nb_streams;
       stream_mapping = av_mallocz_array(stream_mapping_size, sizeof(*stream_mapping));
       if (!stream_mapping) {
           ret = AVERROR(ENOMEM);
           goto end;
       }

       ofmt = ofmt_ctx->oformat;

       for (i = 0; i &lt; ifmt_ctx->nb_streams; i++) {
           AVStream *out_stream;
           AVStream *in_stream = ifmt_ctx->streams[i];
           AVCodecParameters *in_codecpar = in_stream->codecpar;

           if (in_codecpar->codec_type != AVMEDIA_TYPE_AUDIO &amp;&amp;
               in_codecpar->codec_type != AVMEDIA_TYPE_VIDEO &amp;&amp;
               in_codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE) {
               stream_mapping[i] = -1;
               continue;
           }

           stream_mapping[i] = stream_index++;

           out_stream = avformat_new_stream(ofmt_ctx, NULL);
           if (!out_stream) {
               fprintf(stderr, "Failed allocating output stream\n");
               ret = AVERROR_UNKNOWN;
               goto end;
           }

           ret = avcodec_parameters_copy(out_stream->codecpar, in_codecpar);
           if (ret &lt; 0) {
               fprintf(stderr, "Failed to copy codec parameters\n");
               goto end;
           }
           out_stream->codecpar->codec_tag = 0;
       }
       av_dump_format(ofmt_ctx, 0, out_filename, 1);

       if (!(ofmt->flags &amp; AVFMT_NOFILE)) {
           ret = avio_open(&amp;ofmt_ctx->pb, out_filename, AVIO_FLAG_WRITE);
           if (ret &lt; 0) {
               fprintf(stderr, "Could not open output file '%s'", out_filename);
               goto end;
           }
       }

       ret = avformat_write_header(ofmt_ctx, NULL);
       if (ret &lt; 0) {
           fprintf(stderr, "Error occurred when opening output file\n");
           goto end;
       }

       while (1) {
           AVStream *in_stream, *out_stream;

           ret = av_read_frame(ifmt_ctx, &amp;pkt);
           if (ret &lt; 0)
               break;

           in_stream  = ifmt_ctx->streams[pkt.stream_index];
           if (pkt.stream_index >= stream_mapping_size ||
               stream_mapping[pkt.stream_index] &lt; 0) {
               av_packet_unref(&amp;pkt);
               continue;
           }

           pkt.stream_index = stream_mapping[pkt.stream_index];
           out_stream = ofmt_ctx->streams[pkt.stream_index];
           log_packet(ifmt_ctx, &amp;pkt, "in");

           /* copy packet */
           pkt.pts = av_rescale_q_rnd(pkt.pts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
           pkt.dts = av_rescale_q_rnd(pkt.dts, in_stream->time_base, out_stream->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
           pkt.duration = av_rescale_q(pkt.duration, in_stream->time_base, out_stream->time_base);
           pkt.pos = -1;
           log_packet(ofmt_ctx, &amp;pkt, "out");

           ret = av_interleaved_write_frame(ofmt_ctx, &amp;pkt);
           if (ret &lt; 0) {
               fprintf(stderr, "Error muxing packet\n");
               break;
           }
           av_packet_unref(&amp;pkt);
       }

       av_write_trailer(ofmt_ctx);
    end:

       avformat_close_input(&amp;ifmt_ctx);

       /* close output */
       if (ofmt_ctx &amp;&amp; !(ofmt->flags &amp; AVFMT_NOFILE))
           avio_closep(&amp;ofmt_ctx->pb);
       avformat_free_context(ofmt_ctx);

       av_freep(&amp;stream_mapping);

       if (ret &lt; 0 &amp;&amp; ret != AVERROR_EOF) {
           fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
           return 1;
       }

       return 0;
    }