Recherche avancée

Médias (1)

Mot : - Tags -/ogg

Autres articles (56)

  • À propos des documents

    21 juin 2013, par

    Que faire quand un document ne passe pas en traitement, dont le rendu ne correspond pas aux attentes ?
    Document bloqué en file d’attente ?
    Voici une liste d’actions ordonnée et empirique possible pour tenter de débloquer la situation : Relancer le traitement du document qui ne passe pas Retenter l’insertion du document sur le site MédiaSPIP Dans le cas d’un média de type video ou audio, retravailler le média produit à l’aide d’un éditeur ou un transcodeur. Convertir le document dans un format (...)

  • Emballe Médias : Mettre en ligne simplement des documents

    29 octobre 2010, par

    Le plugin emballe médias a été développé principalement pour la distribution mediaSPIP mais est également utilisé dans d’autres projets proches comme géodiversité par exemple. Plugins nécessaires et compatibles
    Pour fonctionner ce plugin nécessite que d’autres plugins soient installés : CFG Saisies SPIP Bonux Diogène swfupload jqueryui
    D’autres plugins peuvent être utilisés en complément afin d’améliorer ses capacités : Ancres douces Légendes photo_infos spipmotion (...)

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

  • I need some help accurately trimming video using the FFmpeg C api

    20 mars 2015, par Justin Bradley

    I need some help accurately trimming video using the FFmpeg C api.
    What I’m seeing is when the input video stream has a time_base of 1/48000 it correctly selects the trimmed start and end times. However when the input video stream has a time_base other than 1/48000 the trim is incorrect.

    Time bases of 1/30000 and 1/24000 trim half the expected video stream length - 10s instead of 20s.
    1/25 trims almost nothing at all - the output file size is only a few kb.

    The audio stream appears to always be trimmed correctly.

    For example if I try to trim the first 20s of a video whose video stream time base is 1/30000, the output mp4’s length is 20s. It has first 10s of video and first 20s of audio.

    I think I’m incorrectly calculating the end_time but I’m not sure why it’s correct for 1/48000 time_base streams.

    record[i].start_time = av_rescale_q((int64_t)( start_time * AV_TIME_BASE ), default_timebase, in_stream->time_base);
    record[i].end_time = av_rescale_q((int64_t)( end_time   * AV_TIME_BASE ), default_timebase, in_stream->time_base);

    Here is a more complete sample of code :

    int num_of_streams = ifmt_ctx->nb_streams;
    if(num_of_streams > 0) {
       // keeps track of each stream's trimmed start and end times
       struct stream_pts record[num_of_streams];

       for (i = 0; i < num_of_streams; i++) {
           AVStream *in_stream = ifmt_ctx->streams[i];
           AVStream *out_stream = avformat_new_stream(ofmt_ctx, in_stream->codec->codec);
           if (!out_stream) {
               LOGE("=> Failed allocating output stream");
               ret = AVERROR_UNKNOWN;
               return close_connection(ret);
           }

           ret = avcodec_copy_context(out_stream->codec, in_stream->codec);
           if (ret < 0) {
               LOGE("=> Failed to copy context from input to output stream codec context");
               return close_connection(ret);
           }
           out_stream->codec->codec_tag = 0;
           if (ofmt_ctx->oformat->flags & AVFMT_GLOBALHEADER)
               out_stream->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;

           AVRational default_timebase;
           default_timebase.num = 1;
           default_timebase.den = AV_TIME_BASE;

           // determine start/end times for each stream
           record[i].index = i;
           record[i].start_time = av_rescale_q((int64_t)( start_time * AV_TIME_BASE ), default_timebase, in_stream->time_base);
           record[i].end_time = av_rescale_q((int64_t)( end_time   * AV_TIME_BASE ), default_timebase, in_stream->time_base);
       }

       av_dump_format(ofmt_ctx, 0, output_file, 1);

       if (!(ofmt->flags & AVFMT_NOFILE)) {
           ret = avio_open(&ofmt_ctx->pb, output_file, AVIO_FLAG_WRITE);
           if (ret < 0) {
               LOGE("=> Could not open output file '%s'", output_file);
               return close_connection(ret);
           }
       }

       ret = avformat_write_header(ofmt_ctx, NULL);
       if (ret < 0) {
           LOGE("=> Error occurred when opening output file");
           return close_connection(ret);
       }

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

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

           in_stream  = ifmt_ctx->streams[pkt.stream_index];
           out_stream = ofmt_ctx->streams[pkt.stream_index];

           // 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;

           // write the frames we're looking for
           if(pkt.pts >= record[pkt.stream_index].start_time && pkt.pts <= record[pkt.stream_index].end_time) {
               ret = av_interleaved_write_frame(ofmt_ctx, &pkt);
               if (ret < 0) {
                   LOGE("=> Error muxing packet");
                   break;
               }
           }

           av_free_packet(&pkt);
       }
    }
  • ffmpeg to split mp4 file into segments... after first segment, audio unsynced

    13 avril 2015, par bcsteeve

    I’ve used the ffmpeg command line shown in this question to split MKV files perfectly for a long time. Now i have some MP4 files that i’d like to split and at first it seemed to work, but every subsequent segment after the first has the audio not synced ! And by several seconds.

    I’ve tried forcing keyframes (advice I found on some other sites) and that didn’t help.

    I tried a different program entirely (Avidemux) and it was able to split the file with proper output, but it was a LOT slower, taking upwards of 3 minutes vs less than 2 seconds with ffmpeg. With Avidemux I was able to determine the exact position of the i-frame where I wanted to split, so thinking perhaps that was the syncing problem I tried that exact position (ie. 00:12:17.111 instead of 00:12:16 or whatever) but that didn’t help either.

    Is there an option I’m missing with ffmpeg to get it to properly sync audio to the video when splitting ?

  • ffmpeg runs in terminal but returns error in subprocess.run from flatpak-installed pycharm

    19 juin 2024, par name

    I want to run this command in python :

    


    ffmpeg -ss 00:00:30 -i "/home/exl/—1—ARCHIVE—1—/video/music videos/author --- a2 - name (text).webm" -vf scale=150:-2 -vframes 1 -c:v libwebp -compression_level 6 -quality 100 /home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp


    


    In terminal it works fine, but in subprocess returns error. Python code :

    


    finished_process = subprocess.run(
                    [
                        '/usr/bin/ffmpeg',
                        '-ss', f'00:00:{seconds_shift}',
                        '-i', original_path,
                        '-vf', 'scale=150:-2',
                        '-vframes', '1',
                        '-c:v', 'libwebp',
                        '-compression_level', '6',
                        '-quality', '100',
                        preview_path
                    ],
                    #stdout=subprocess.DEVNULL,
                    #stderr=subprocess.DEVNULL,
                    check=False,
                    capture_output=True
                )


    


    finished_process.stderr.decode() :

    


    ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12.1.0 (GCC)
  configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-debug --disable-doc --disable-static --enable-optimizations --enable-shared --disable-everything --enable-ffplay --enable-ffprobe --enable-gnutls --enable-libaom --enable-libdav1d --enable-libfdk-aac --enable-libmp3lame --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-openal --enable-opengl --enable-sdl2 --enable-vulkan --enable-zlib --enable-libv4l2 --enable-libxcb --enable-vdpau --enable-vaapi --enable-encoder='ac3,alac,flac,libfdk_aac,g723_1,mp2,libmp3lame,libopus,libspeex,pcm_alaw,pcm_mulaw,pcm_f32le,pcm_s16be,pcm_s24be,pcm_s16le,pcm_s24le,pcm_s32le,pcm_u8,tta,libvorbis,wavpack,' --enable-encoder='ass,ffv1,libaom_av1,libvpx_vp8,libvpx_vp9,mjpeg_vaapi,rawvideo,theora,vp8_vaapi,libopenh264' --enable-decoder='adpcm_g722,alac,flac,g723_1,g729,libfdk_aac,libopus,libspeex,mp2,mp3,m4a,pcm_alaw,pcm_mulaw,pcm_f16le,pcm_f24le,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_s16be,pcm_s16be_planar,pcm_s24be,pcm_s16le,pcm_s16le_planar,pcm_s24le,pcm_s24le_planar,pcm_s32le,pcm_s32le_planar,pcm_s64be,pcm_s64le,pcm_s8,pcm_s8_planar,pcm_u8,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,tta,vorbis,wavpack,' --enable-decoder='ass,ffv1,mjpeg,mjpegb,libaom_av1,libdav1d,libvpx_vp8,libvpx_vp9,rawvideo,theora,vp8,vp9,libopenh264' --enable-encoder='bmp,gif,jpegls,png,tiff,webp,' --enable-decoder='bmp,gif,jpegls,png,tiff,webp,' --enable-hwaccel='vp8_vaapi,mjpeg_vaapi,' --enable-parser='aac,ac3,flac,mjpeg,mpegaudio,mpeg4video,opus,vp3,vp8,vp9,vorbis,' --enable-muxer='ac3,ass,flac,g722,gif,matroska,mp3,mpegvideo,rtp,ogg,opus,pcm_s16be,pcm_s16le,wav,webm,' --enable-demuxer='aac,ac3,ass,flac,g722,gif,image_jpeg_pipe,image_png_pipe,image_webp_pipe,matroska,mjpeg,mov,mp3,mpegvideo,ogg,pcm_mulaw,pcm_alaw,pcm_s16be,pcm_s16le,rtp,wav,' --enable-filter='crop,scale,overlay,amix,amerge,aresample,format,aformat,fps,transpose,pad,' --enable-indev='v4l2,xcbgrab,' --enable-protocol='crypto,file,pipe,rtp,srtp,rtsp,tcp,udp,unix,' --arch=x86_64 --enable-libopenh264
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
Input #0, matroska,webm, from '/home/exl/—1—ARCHIVE—1—/video/music videos/author --- a2 - name (text).webm':
  Metadata:
    ENCODER         : Lavf59.16.100
  Duration: 00:03:24.98, start: -0.007000, bitrate: 915 kb/s
  Stream #0:0(eng): Video: vp9 (Profile 0), yuv420p(tv, bt709), 1920x1036, SAR 1:1 DAR 480:259, 25 fps, 25 tbr, 1k tbn (default)
    Metadata:
      DURATION        : 00:03:24.960000000
  Stream #0:1(eng): Audio: opus, 48000 Hz, stereo, s16 (default)
    Metadata:
      DURATION        : 00:03:24.981000000
[NULL @ 0x55dd82de7d00] Unable to find a suitable output format for '/home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp'
/home/exl/—1—ARCHIVE—1—/—3—previews—3—/734a8a0bac3a83e0f6c69416a26ec5cd211a6d742f3df63bb72bdbe6431b57c30677bc11551ba4aaaecac15ed2c48de51340a09020b7e9d9479e1e81ff766191.webp: Invalid argument



    


    As suggested here (FFMPEG command runs in terminal but not by subprocess) i tried using which determine path to correct version, but this command returns /usr/bin/ffmpeg both in python and in terminal.

    


    which ffmpeg (both subprocess.run(['which', 'ffmpeg'], capture_output=True).stdout and terminal) : /usr/bin/ffmpeg

    


    ffmpeg -version : 5.1.1-1ubuntu1

    


    ffmpeg version 5.1.1-1ubuntu1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12 (Ubuntu 12.2.0-1ubuntu1)
configuration: --prefix=/usr --extra-version=1ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-shared


    


    subprocess.run(['ffmpeg', '-version'], capture_output=True).stdout.decode() : 5.0.1

    


    ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
built with gcc 12.1.0 (GCC)
configuration: --prefix=/usr --libdir=/usr/lib/x86_64-linux-gnu --disable-debug --disable-doc --disable-static --enable-optimizations --enable-shared --disable-everything --enable-ffplay --enable-ffprobe --enable-gnutls --enable-libaom --enable-libdav1d --enable-libfdk-aac --enable-libmp3lame --enable-libfontconfig --enable-libfreetype --enable-libopus --enable-libpulse --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-openal --enable-opengl --enable-sdl2 --enable-vulkan --enable-zlib --enable-libv4l2 --enable-libxcb --enable-vdpau --enable-vaapi --enable-encoder='ac3,alac,flac,libfdk_aac,g723_1,mp2,libmp3lame,libopus,libspeex,pcm_alaw,pcm_mulaw,pcm_f32le,pcm_s16be,pcm_s24be,pcm_s16le,pcm_s24le,pcm_s32le,pcm_u8,tta,libvorbis,wavpack,' --enable-encoder='ass,ffv1,libaom_av1,libvpx_vp8,libvpx_vp9,mjpeg_vaapi,rawvideo,theora,vp8_vaapi,libopenh264' --enable-decoder='adpcm_g722,alac,flac,g723_1,g729,libfdk_aac,libopus,libspeex,mp2,mp3,m4a,pcm_alaw,pcm_mulaw,pcm_f16le,pcm_f24le,pcm_f32be,pcm_f32le,pcm_f64be,pcm_f64le,pcm_s16be,pcm_s16be_planar,pcm_s24be,pcm_s16le,pcm_s16le_planar,pcm_s24le,pcm_s24le_planar,pcm_s32le,pcm_s32le_planar,pcm_s64be,pcm_s64le,pcm_s8,pcm_s8_planar,pcm_u8,pcm_u24be,pcm_u24le,pcm_u32be,pcm_u32le,tta,vorbis,wavpack,' --enable-decoder='ass,ffv1,mjpeg,mjpegb,libaom_av1,libdav1d,libvpx_vp8,libvpx_vp9,rawvideo,theora,vp8,vp9,libopenh264' --enable-encoder='bmp,gif,jpegls,png,tiff,webp,' --enable-decoder='bmp,gif,jpegls,png,tiff,webp,' --enable-hwaccel='vp8_vaapi,mjpeg_vaapi,' --enable-parser='aac,ac3,flac,mjpeg,mpegaudio,mpeg4video,opus,vp3,vp8,vp9,vorbis,' --enable-muxer='ac3,ass,flac,g722,gif,matroska,mp3,mpegvideo,rtp,ogg,opus,pcm_s16be,pcm_s16le,wav,webm,' --enable-demuxer='aac,ac3,ass,flac,g722,gif,image_jpeg_pipe,image_png_pipe,image_webp_pipe,matroska,mjpeg,mov,mp3,mpegvideo,ogg,pcm_mulaw,pcm_alaw,pcm_s16be,pcm_s16le,rtp,wav,' --enable-filter='crop,scale,overlay,amix,amerge,aresample,format,aformat,fps,transpose,pad,' --enable-indev='v4l2,xcbgrab,' --enable-protocol='crypto,file,pipe,rtp,srtp,rtsp,tcp,udp,unix,' --arch=x86_64 --enable-libopenh264


    


    Thank you in advance.