Recherche avancée

Médias (1)

Mot : - Tags -/swfupload

Autres articles (94)

  • Dépôt de média et thèmes par FTP

    31 mai 2013, par

    L’outil MédiaSPIP traite aussi les média transférés par la voie FTP. Si vous préférez déposer par cette voie, récupérez les identifiants d’accès vers votre site MédiaSPIP et utilisez votre client FTP favori.
    Vous trouverez dès le départ les dossiers suivants dans votre espace FTP : config/ : dossier de configuration du site IMG/ : dossier des média déjà traités et en ligne sur le site local/ : répertoire cache du site web themes/ : les thèmes ou les feuilles de style personnalisées tmp/ : dossier de travail (...)

  • Keeping control of your media in your hands

    13 avril 2011, par

    The vocabulary used on this site and around MediaSPIP in general, aims to avoid reference to Web 2.0 and the companies that profit from media-sharing.
    While using MediaSPIP, you are invited to avoid using words like "Brand", "Cloud" and "Market".
    MediaSPIP is designed to facilitate the sharing of creative media online, while allowing authors to retain complete control of their work.
    MediaSPIP aims to be accessible to as many people as possible and development is based on expanding the (...)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

Sur d’autres sites (11908)

  • A pragmatic strategy to merge multiple video files

    19 juin 2021, par saurav

    I currently am working on recording a multiparty video conference which supports up to 6 participants. I am recording the conference using a media server and storing audio/video streams individually for every participant.

    


    Next, I need to merge those individual recordings into a single video file and upload it to a cloud storage like aws s3. For this I am considering 2 options, either Gstreamer or FFMPEG. I am leaning towards FFMPEG as I have used FFMPEG previously. I currently am playing with FFMPEG things like the hstack and vstack filters etc.

    


    Here is the FFMPEG command I recently used to join 2 webm videos of 2 mins 40sec and 1min 40sec to create a mp4 video file for upload. Both the videos are 1280x720 in this case but I have included the scale part because in real life scenario different participants joining with different cameras produces video files of different resolution which is a problem for the hstack/vstack filter. Therefore, to make the video resolutions of all participant consistent, I have included the scale property.

    


    ffmpeg -i 1.webm -i 2.webm -filter_complex "[0:v]scale=1280:720,setsar=1[l];[1:v]scale=1280:720,setsar=1[r];[l][r]hstack;[0][1]amix" output-1280x720.mp4


    


    Currently I am facing 2 issues with this command.

    


      

    1. The output mp4 file is very big, in this case 140Mb (approx) for a less than 3 minutes video.

      


    2. 


    3. How do I add delay to any video before starting to merge ?
      
Currently the videos are going out of sync if all the participants don't join at the same time which is highly unlikely to happen in a real world scenario.

      


    4. 


    


    Any pointer in the right direction will be highly appreciated.

    


    Here is a log sample from FFmpeg (or see the full log link) :

    


    ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Input #0, matroska,webm, from '3.webm':
  Metadata:
    title           : FFmpeg
    ENCODER         : Lavf58.29.100
  Duration: 00:01:39.63, start: 0.000000, bitrate: 707 kb/s
    Stream #0:0: Video: vp8, yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:01:39.618000000
    Stream #0:1: Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:01:39.629000000
Input #1, matroska,webm, from '4.webm':
  Metadata:
    title           : FFmpeg
    ENCODER         : Lavf58.29.100
  Duration: 00:02:39.07, start: 0.000000, bitrate: 708 kb/s
    Stream #1:0: Video: vp8, yuv420p(tv, bt470bg/unknown/unknown, progressive), 1280x720, SAR 1:1 DAR 16:9, 1k tbr, 1k tbn, 1k tbc (default)
    Metadata:
      DURATION        : 00:02:39.050000000
    Stream #1:1: Audio: opus, 48000 Hz, stereo, fltp (default)
    Metadata:
      DURATION        : 00:02:39.068000000
Stream mapping:
  Stream #0:0 (vp8) -> scale
  Stream #0:1 (opus) -> amix:input0
  Stream #1:0 (vp8) -> scale
  Stream #1:1 (opus) -> amix:input1
  hstack -> Stream #0:0 (libx264)
  amix -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x562b4842a500] using SAR=1/1
[libx264 @ 0x562b4842a500] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x562b4842a500] profile High, level 6.1
[libx264 @ 0x562b4842a500] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=18 lookahead_threads=3 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output-new.mp4':
  Metadata:
    title           : FFmpeg
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 2560x720 [SAR 1:1 DAR 32:9], q=-1--1, 1k fps, 16k tbn, 1k tbc (default)
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      encoder         : Lavc58.54.100 aac

frame=  129 fps=0.0 q=33.0 size=       0kB time=00:00:00.23 bitrate=   1.6kbits/s dup=123 drop=0 speed=0.44x    
frame=  257 fps=228 q=33.0 size=       0kB time=00:00:00.51 bitrate=   0.8kbits/s dup=243 drop=0 speed=0.455x    
frame=  379 fps=224 q=33.0 size=     256kB time=00:00:00.73 bitrate=2855.1kbits/s dup=358 drop=0 speed=0.434x    
frame=  497 fps=222 q=33.0 size=     256kB time=00:00:00.86 bitrate=2431.5kbits/s dup=469 drop=0 speed=0.386x    
 
...
More than 1000 frames duplicated
...
  
frame=158751 fps=196 q=33.0 size=  134656kB time=00:02:39.00 bitrate=6937.4kbits/s dup=151385 drop=0 speed=0.196x    
frame=158851 fps=196 q=33.0 size=  134912kB time=00:02:39.00 bitrate=6950.6kbits/s dup=151482 drop=0 speed=0.196x    
frame=158983 fps=196 q=33.0 size=  134912kB time=00:02:39.00 bitrate=6950.6kbits/s dup=151610 drop=0 speed=0.196x    
frame=159081 fps=196 q=-1.0 Lsize=  137197kB time=00:02:39.07 bitrate=7065.2kbits/s dup=151706 drop=0 speed=0.196x    

video:132693kB audio:2494kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.486001%

[libx264 @ 0x562b4842a500] frame I:637   Avg QP:17.73  size:123895
[libx264 @ 0x562b4842a500] frame P:40088 Avg QP:19.73  size:  1134
[libx264 @ 0x562b4842a500] frame B:118356 Avg QP:27.54  size:    97
[libx264 @ 0x562b4842a500] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
[libx264 @ 0x562b4842a500] mb I  I16..4: 11.1% 67.3% 21.6%
[libx264 @ 0x562b4842a500] mb P  I16..4:  0.1%  0.1%  0.0%  P16..4:  2.6%  0.4%  0.3%  0.0%  0.0%    skip:96.5%
[libx264 @ 0x562b4842a500] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.7%  0.0%  0.0%  direct: 0.0%  skip:99.3%  L0:38.7% L1:61.3% BI: 0.0%
[libx264 @ 0x562b4842a500] 8x8 transform intra:66.8% inter:71.4%
[libx264 @ 0x562b4842a500] coded y,uvDC,uvAC intra: 81.8% 89.5% 72.3% inter: 0.2% 0.4% 0.0%
[libx264 @ 0x562b4842a500] i16 v,h,dc,p: 25% 21% 17% 37%
[libx264 @ 0x562b4842a500] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 22% 12%  4%  5%  6%  6%  6%  6%
[libx264 @ 0x562b4842a500] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 42% 24%  6%  4%  5%  5%  6%  4%  4%
[libx264 @ 0x562b4842a500] i8c dc,h,v,p: 42% 24% 26%  9%
[libx264 @ 0x562b4842a500] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x562b4842a500] ref P L0: 82.4% 11.5%  5.3%  0.8%
[libx264 @ 0x562b4842a500] ref B L0: 83.0% 16.9%  0.1%
[libx264 @ 0x562b4842a500] ref B L1: 94.9%  5.1%
[libx264 @ 0x562b4842a500] kb/s:6833.11
[aac @ 0x562b4842b540] Qavg: 239.393


    


  • Problem recording RTP from mediasoup router using ffmpeg

    22 juin 2021, par Scramjet

    I have a mediasoup server setup where I now need recording feature. To accomplish this I am doing the following -
    
On getting the event to start recording I call this function :

    


    async handleStartRecording(peer, router)
    {
        let transports = [],
            consumers = [],
            ffmpegInput = {};
        for(let entry of peer.producers.entries())
        {
            const rtpTransport = await router.createPlainTransport({
                comedia: false,
                rtcpMux: false,
                listenIp: { ip: '127.0.0.1', announcedIp: null }
            });
            transports.push(rtpTransport);

            const port = (entry[1].kind === 'audio') ? 8994 : 8996;
            const rtcpPort = port+1;

            await rtpTransport.connect({
                ip: '127.0.0.1',
                port: port,
                rtcpPort: rtcpPort,
                rtcpMux: false
            });
            peer.addTransport(rtpTransport.id, rtpTransport);

            const rtpConsumer = await rtpTransport.consume({
                producerId: entry[0],
                rtpCapabilities: router.rtpCapabilities, 
                paused: true,
            });
            consumers.push(rtpConsumer);

            const codecs = [];
            const routerCodec = router.rtpCapabilities.codecs.find(
              codec => codec.kind === entry[1].kind
            );
            codecs.push(routerCodec);
            const rtpCapabilities = {
                codecs,
                rtcpFeedback: []
            };

            ffmpegInput[entry[1].kind] = {
                port,
                rtcpPort,
                localRtcpPort: rtpTransport.rtcpTuple ? rtpTransport.rtcpTuple.localPort : undefined,
                rtpCapabilities,
                rtpParameters: rtpConsumer.rtpParameters,
                preferredPayloadType: routerCodec.payloadType
            };
        }
        
        ffmpegInput.fileName = Date.now().toString();
        peer._process = new FFmpeg(ffmpegInput, consumers);
    }


    


    and the ffmpeg class is :

    


    class FFmpeg {
    constructor(rtpParameters, consumers) {
        this._rtpParameters = rtpParameters;
        this._consumers = consumers;
        this._process = undefined;
        this._createProcess();
    }
    _createProcess() {
        this._process = child_process.spawn('ffmpeg', this._commandArgs);
        consumers.forEach((consumer) =>
        {
            consumer.resume();
        });
    }
get _commandArgs() {
        let commandArgs = [
            '-loglevel',
            'debug',
            '-protocol_whitelist',
            'file,crypto,pipe,udp,rtp',
            '-fflags',
            '+genpts',
            '-i',
            '/recording/input-h264.sdp', //path to sdp file has full path this is sample
            '-map',            // video
            '0:v:0',
            '-c:v',
            'copy',
            '-map',            //audio
            '0:a:0',
            '-strict',
            '-2',
            '-c:a',
            'copy',
            '-f',
            'webm',
            '-flags',
            '+global_header',
            '-y',
            `/files/${this._rtpParameters.fileName}.webm`
        ]);
        return commandArgs;
    }
}



    


    Sdp file :

    


    v=0
o=- 0 0 IN IP4 127.0.0.1
s=FFmpeg
c=IN IP4 127.0.0.1
t=0 0
m=video 8996 RTP/AVPF 101
a=rtcp:8997
a=rtpmap:101 VP8/90000
a=fmtp:101 level-asymmetry-allowed=1
m=audio 8994 RTP/AVPF 100
a=rtcp:8995
a=rtpmap:111 opus/48000/2
a=fmtp:111 minptime=10;useinbandfec=1


    


    Now, I am getting a codec parameter not found for stream 0 error.

    


    createProcess() [sdpString:v=0
            o=- 0 0 IN IP4 127.0.0.1
            s=FFmpeg
            c=IN IP4 127.0.0.1
            t=0 0
            m=video 8996 RTP/AVP 101
            a=rtpmap:101 VP8/90000
            a=sendonly
            m=audio 8994 RTP/AVP 100
            a=rtpmap:100 opus/48000/2
            a=sendonly
            ]
commandArgs:[ '-analyzeduration',
  '2147483647',
  '-probesize',
  '2147483647',
  '-loglevel',
  'debug',
  '-protocol_whitelist',
  'file,crypto,pipe,udp,rtp',
  '-fflags',
  '+genpts',
  '-i',
  '/recording/input-h264.sdp',
  '-map',
  '0:v:0',
  '-c:v',
  'copy',
  '-map',
  '0:a:0',
  '-strict',
  '-2',
  '-c:a',
  'copy',
  '-f',
  'webm',
  '-flags',
  '+global_header',
  '-y',
  '/files/1623939179824.webm',
  [length]: 28 ]
ffmpeg::process::data(err) [data:ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
]
ffmpeg::process::data(err) [data:  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
]
ffmpeg::process::data(err) [data:  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
]
ffmpeg::process::data(err) [data:  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
Splitting the commandline.
Reading option '-analyzeduration' ...]
ffmpeg::process::data(err) [data: matched as AVOption 'analyzeduration' with argument '2147483647'.
Reading option '-probesize' ...]
ffmpeg::process::data(err) [data: matched as AVOption 'probesize' with argument '2147483647'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-protocol_whitelist' ...]
ffmpeg::process::data(err) [data: matched as AVOption 'protocol_whitelist' with argument 'file,crypto,pipe,udp,rtp'.
Reading option '-fflags' ...]
ffmpeg::process::data(err) [data: matched as AVOption 'fflags' with argument '+genpts'.
Reading option '-i' ... matched as input url with argument '/recording/input-h264.sdp'.
Reading option '-map' ... matched as option 'map' (set input stream mapping) with argument '0:v:0'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-map' ...]
ffmpeg::process::data(err) [data: matched as option 'map' (set input stream mapping) with argument '0:a:0'.
Reading option '-strict' ...]
ffmpeg::process::data(err) [data:Routing option strict to both codec and muxer layer
 matched as AVOption 'strict' with argument '-2'.
Reading option '-c:a' ... matched as option 'c' (codec name) with argument 'copy'.
Reading option '-f' ... matched as option 'f' (force format) with argument 'webm'.
Reading option '-flags' ...]
ffmpeg::process::data(err) [data: matched as AVOption 'flags' with argument '+global_header'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '/files/1623939179824.webm' ... matched as output url.
Finished splitting the commandline.
]
ffmpeg::process::data(err) [data:Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input url /recording/input-h264.sdp.
Successfully parsed a group of options.
Opening an input file: /recording/input-h264.sdp.
]
ffmpeg::process::data(err) [data:[NULL @ 0x55b7141c1a80] Opening '/recording/input-h264.sdp' for reading
]
ffmpeg::process::data(err) [data:[sdp @ 0x55b7141c1a80] Format sdp probed with size=2048 and score=50
]
ffmpeg::process::data(err) [data:[sdp @ 0x55b7141c1a80] video codec set to: vp8
[sdp @ 0x55b7141c1a80] audio codec set to: opus
[sdp @ 0x55b7141c1a80] audio samplerate set to: 48000
[sdp @ 0x55b7141c1a80] audio channels set to: 2
]
ffmpeg::process::data(err) [data:[udp @ 0x55b7141c4d40] end receive buffer size reported is 131072
[udp @ 0x55b7141cac00] end receive buffer size reported is 131072
[sdp @ 0x55b7141c1a80] setting jitter buffer size to 500
]
ffmpeg::process::data(err) [data:[udp @ 0x55b7141c5d40] end receive buffer size reported is 131072
]
ffmpeg::process::data(err) [data:[udp @ 0x55b7141c5e00] end receive buffer size reported is 131072
[sdp @ 0x55b7141c1a80] setting jitter buffer size to 500
]
ffmpeg::process::data(err) [data:[sdp @ 0x55b7141c1a80] Before avformat_find_stream_info() pos: 262 bytes read:262 seeks:0 nb_streams:2
]
ffmpeg::process::data(err) [data:[sdp @ 0x55b7141c1a80] Could not find codec parameters for stream 0 (Video: vp8, 1 reference frame, yuv420p): unspecified size
Consider increasing the value for the 'analyzeduration' and 'probesize' options
]
ffmpeg::process::data(err) [data:[sdp @ 0x55b7141c1a80] After avformat_find_stream_info() pos: 262 bytes read:262 seeks:0 frames:0
Input #0, sdp, from '/recording/input-h264.sdp':
  Metadata:
    title           : FFmpeg
  Duration: N/A, bitrate: N/A
    Stream #0:0, 0, 1/90000: Video: vp8, 1 reference frame, yuv420p, 90k tbr, 90k tbn, 90k tbc
    Stream #0:1, 0, 1/48000: Audio: opus, 48000 Hz, stereo, fltp
Successfully opened the file.
Parsing a group of options: output url /files/1623939179824.webm.
Applying option map (set input stream mapping) with argument 0:v:0.
Applying option c:v (codec name) with argument copy.
Applying option map (set input stream mapping) with argument 0:a:0.
]
ffmpeg::process::data(err) [data:Applying option c:a (codec name) with argument copy.
Applying option f (force format) with argument webm.
Successfully parsed a group of options.
Opening an output file: /files/1623939179824.webm.
]
ffmpeg::process::data(err) [data:[file @ 0x55b714243880] Setting default whitelist 'file,crypto'
]
ffmpeg::process::data(err) [data:Successfully opened the file.
]
ffmpeg::process::data(err) [data:[webm @ 0x55b71423e100] dimensions not set
Could not write header for output file #0 (incorrect codec parameters ?): Invalid argument
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
    Last message repeated 1 times
[AVIOContext @ 0x55b714243b00] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x55b7141cacc0] Statistics: 262 bytes read, 0 seeks
]
ffmpeg::process::close


    


    I have been at it for days, I don't even know how to debug this issue. I tried using vlc's stream option with the url of server to check if the transport was working but it doesn't detect anything on localhost at that port.
    
If anyone has any ideas about the issue or ways to debug it, do tell me..

    


  • Losing audio quality when merging multiple videos with FFmpeg

    30 mai 2021, par Charly

    I am trying to merge multiple videos (a few seconds each) into one, using FFmpeg.

    


    Merging all at once

    


    I first tried merging all videos with one FFmpeg command, but it only seems to work with up to a certain amount of videos. On my Raspberry Pi 4 (2BG RAM), it worked for 16 videos and broke (ran out of memory ?) while merging 36 videos (command and ouput below)

    


    ffmpeg -i 1Rbrdn1Xp.mp4 -i G7eYqdFPb.mp4 -i -Xo-6ABm3.mp4 -i 6As9IlqbW.mp4 -i tz9tVKFA-.mp4
-i MS6DHZoJE.mp4 -i CeJYs99-G.mp4 -i Hsv5X48IC.mp4 -i Gm_DtjNU4.mp4 -i PZytbInZL.mp4
-i qsIJuvKO2.mp4 -i c5wxGk_Fx.mp4 -i j4K1qA7ih.mp4 -i AIpVWuhGV.mp4 -i yiLk0snSh.mp4
-i q1zmytaXZ.mp4 -i VRwQvLxaW.mp4 -i 0_3yLrokH.mp4 -i fW28LPQsk.mp4 -i La6WsGeE8.mp4
-i FlroQnCHq.mp4 -i c7SiL_qSU.mp4 -i aaGTUMJXD.mp4 -i hvXYBaCSM.mp4 -i CMDaFrWM4.mp4
-i _YAGDRyQN.mp4 -i RQXyshs_o.mp4 -i 96pKlIZxW.mp4 -i HVOOeCUYG.mp4 -i pJFxq7BTx.mp4
-i VxMJQqbK5.mp4 -i mkgbViPTI.mp4 -i zrjj93b5c.mp4 -i AL9oG1F36.mp4 -i IsUnC0NPb.mp4
-i Qhj2bhab9.mp4 -y -filter_complex concat=n=36:v=1:a=1 -vsync 2 kn-dQSN-v.mp4


    


    ffmpeg version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 8 (Raspbian 8.3.0-6+rpi1)
(...)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '1Rbrdn1Xp.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:00:08.08, start: 0.000000, bitrate: 602 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 533 kb/s, 57.62 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 64 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'G7eYqdFPb.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
  Duration: 00:00:21.00, start: 0.000000, bitrate: 310 kb/s
    Stream #1:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 229 kb/s, 59.09 fps, 60 tbr, 15360 tbn, 120 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 72 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
(...)
Stream mapping:
  Stream #0:0 (h264) -> concat:in0:v0
  Stream #0:1 (aac) -> concat:in0:a0
  Stream #1:0 (h264) -> concat:in1:v0
  Stream #1:1 (aac) -> concat:in1:a0
(...)
  concat:out:v0 -> Stream #0:0 (libx264)
  concat:out:a0 -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[libx264 @ 0x17cb5e0] using SAR=1/1   0kB time=-577014:32:22.77 bitrate=  -0.0kbits/s speed=N/A    
[libx264 @ 0x17cb5e0] using cpu capabilities: ARMv6 NEON
[libx264 @ 0x17cb5e0] profile High, level 3.2
[libx264 @ 0x17cb5e0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
(...)
Output #0, mp4, to 'kn-dQSN-v.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.20.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc (default)
    Metadata:
      encoder         : Lavc58.35.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 22050 Hz, mono, fltp, 69 kb/s (default)
    Metadata:
      encoder         : Lavc58.35.100 aac
frame=15952 fps= 52 q=31.0 size=   10240kB time=00:04:33.02 bitrate= 307.3kbits/s speed=0.844x
[h264 @ 0x3472d80] get_buffer() failed40kB time=00:04:33.02 bitrate= 307.3kbits/s speed=0.844x    
[h264 @ 0x3472d80] thread_get_buffer() failed
[h264 @ 0x3472d80] decode_slice_header error
[h264 @ 0x3472d80] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x34f54d0] get_buffer() failed
[h264 @ 0x34f54d0] thread_get_buffer() failed
[h264 @ 0x34f54d0] decode_slice_header error
[h264 @ 0x34f54d0] no frame!
[h264 @ 0x3472d80] get_buffer() failed
[h264 @ 0x3472d80] thread_get_buffer() failed
(...)
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3472d80] reference picture missing during reorder
[h264 @ 0x3472d80] Missing reference picture, default is 65660
[h264 @ 0x34c4540] mmco: unref short failure
[h264 @ 0x34f54d0] get_buffer() failed08kB time=00:04:45.37 bitrate= 316.0kbits/s speed=0.845x    
[h264 @ 0x34f54d0] thread_get_buffer() failed
[h264 @ 0x34f54d0] decode_slice_header error
[h264 @ 0x34f54d0] no frame!
[h264 @ 0x3472d80] decode_slice_header error
[h264 @ 0x3472d80] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x34f54d0] mmco: unref short failure
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3472d80] get_buffer() failed
[h264 @ 0x3472d80] thread_get_buffer() failed
[h264 @ 0x3472d80] decode_slice_header error
[h264 @ 0x3472d80] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3472d80] get_buffer() failed
[h264 @ 0x3472d80] thread_get_buffer() failed
[h264 @ 0x3472d80] decode_slice_header error
[h264 @ 0x3472d80] no frame!
[h264 @ 0x34f54d0] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0x34f54d0] Missing reference picture, default is 65708
    Last message repeated 1 times
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x34dccb0] reference picture missing during reorder
[h264 @ 0x34dccb0] Missing reference picture, default is 65716
[h264 @ 0x3472d80] mmco: unref short failure
[h264 @ 0x34f54d0] decode_slice_header error
[h264 @ 0x34f54d0] no frame!
Error while decoding stream #15:0: Invalid data found when processing inputbits/s speed=0.845x    
[h264 @ 0x3480010] get_buffer() failed
[h264 @ 0x3480010] thread_get_buffer() failed
[h264 @ 0x3480010] decode_slice_header error
[h264 @ 0x3480010] no frame!
[h264 @ 0x34c4540] decode_slice_header error
[h264 @ 0x34c4540] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3480010] mmco: unref short failure
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x34c4540] get_buffer() failed
[h264 @ 0x34c4540] thread_get_buffer() failed
[h264 @ 0x34c4540] decode_slice_header error
[h264 @ 0x34c4540] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x34c4540] get_buffer() failed
[h264 @ 0x34c4540] thread_get_buffer() failed
[h264 @ 0x34c4540] decode_slice_header error
[h264 @ 0x34c4540] no frame!
[h264 @ 0x34f54d0] decode_slice_header error
[h264 @ 0x34f54d0] no frame!
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3480010] reference picture missing during reorder
    Last message repeated 1 times
[h264 @ 0x3480010] Missing reference picture, default is 65772
    Last message repeated 1 times
Error while decoding stream #15:0: Invalid data found when processing input
[h264 @ 0x3472d80] reference picture missing during reorder
[h264 @ 0x3472d80] Missing reference picture, default is 65780
[h264 @ 0x34c4540] mmco: unref short failure
av_interleaved_write_frame(): Cannot allocate memory
[mp4 @ 0x295c7e0] Application provided duration: 3689347710924763697 / timestamp: 6291454 is out of range for mov/mp4 format
Segmentation fault


    


    Merging videos 2 by 2

    


    I then tried gradually merging videos into one, using multiple FFmpeg commands.

    


    # Pseudocode
final = merge(clip1, clip2)
final = merge(final, clip3)
final = merge(final, clip4)
final = merge(final, clip5)
...


    


    with each command, looking like this :

    


    ffmpeg -i 1Rbrdn1Xp.mp4 -i G7eYqdFPb.mp4 -y -filter_complex concat=n=2:v=1:a=1 -vsync 2 UMVDl9jki.mp4


    


    ffmpeg -i UMVDl9jki.mp4 -i -Xo-6ABm3.mp4 -y -filter_complex concat=n=2:v=1:a=1 -vsync 2 azE1Uombp.mp4


    


    This works but there is a loss in audio quality on the first clips, and it is slowly improving over time. I am guessing this is due to the first videos being merged more times than the last ones. You can see this effect happen in this video (weird artefacts in the voice).

    



    


    So, am I doing something wrong ?
    
Is there a way of merging a lot of videos, without running out of memory or worsening the audio quality ?