Recherche avancée

Médias (0)

Mot : - Tags -/clipboard

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

Autres articles (6)

  • Organiser par catégorie

    17 mai 2013, par

    Dans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
    Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
    Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...)

  • Les thèmes de MediaSpip

    4 juin 2013

    3 thèmes sont proposés à l’origine par MédiaSPIP. L’utilisateur MédiaSPIP peut rajouter des thèmes selon ses besoins.
    Thèmes MediaSPIP
    3 thèmes ont été développés au départ pour MediaSPIP : * SPIPeo : thème par défaut de MédiaSPIP. Il met en avant la présentation du site et les documents média les plus récents ( le type de tri peut être modifié - titre, popularité, date) . * Arscenic : il s’agit du thème utilisé sur le site officiel du projet, constitué notamment d’un bandeau rouge en début de page. La structure (...)

  • Selection of projects using MediaSPIP

    2 mai 2011, par

    The examples below are representative elements of MediaSPIP specific uses for specific projects.
    MediaSPIP farm @ Infini
    The non profit organizationInfini develops hospitality activities, internet access point, training, realizing innovative projects in the field of information and communication technologies and Communication, and hosting of websites. It plays a unique and prominent role in the Brest (France) area, at the national level, among the half-dozen such association. Its members (...)

Sur d’autres sites (3203)

  • What is the best way to split videos into equally sized parts using ffmpeg ? [closed]

    18 juin 2024, par GBPU

    I have tried to split an mp4 file into smaller parts of equal time length like this ffmpeg -i ../data/2024-06-02_12-34-51.mp4 -c copy -map 0 -segment_time 00:00:05 -f segment v1_%03d.mp4. However, this produced videos of highly variables size, some 25x larger than others. I assume this was due to inconsistent framerate during recording.

    


    Next, I tried a script that would split based and limit each part to a specific size :

    


    #!/bin/sh
# Short script to split videos by filesize using ffmpeg by LukeLR

if [ $# -ne 3 ]; then
    echo 'Illegal number of parameters. Needs 3 parameters:'
    echo 'Usage:'
    echo './split-video.sh FILE SIZELIMIT "FFMPEG_ARGS'
    echo 
    echo 'Parameters:'
    echo '    - FILE:        Name of the video file to split'
    echo '    - SIZELIMIT:   Maximum file size of each part (in bytes)'
    echo '    - FFMPEG_ARGS: Additional arguments to pass to each ffmpeg-call'
    echo '                   (video format and quality options etc.)'
    exit 1
fi

FILE="../data/$1"
SIZELIMIT="$2"
FFMPEG_ARGS="$3"

# Duration of the source video
DURATION=$(ffprobe -i "$FILE" -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1|cut -d. -f -2)

# Duration that has been encoded so far
CURDURATION=0

# Filename of the source video (without extension)
BASENAME="${FILE%.*}"

# Extension for the video parts
#EXTENSION="${FILE##*.}"
EXTENSION="mp4"

# Number of the current video part
i=1

# Filename of the next video part
NEXTFILENAME="$BASENAME-$i.$EXTENSION"

echo "Duration of source video: $DURATION"

# Until the duration of all partial videos has reached the duration of the source video
#while [[ $CUR_DURATION -lt $DURATION ]]; do
while [[ $(bc <<< "$CURDURATION < $DURATION") -eq 1 ]]; do
    # Encode next part
    echo ffmpeg -i "$FILE" -ss "$CURDURATION" -fs "$SIZELIMIT" $FFMPEG_ARGS "$NEXTFILENAME"
    ffmpeg -ss "$CURDURATION" -i "$FILE" -fs "$SIZELIMIT" $FFMPEG_ARGS "$NEXTFILENAME"

    # Duration of the new part
    NEWDURATION=$(ffprobe -i "$NEXTFILENAME" -show_entries format=duration -v quiet -of default=noprint_wrappers=1:nokey=1|cut -d. -f -2)

    # Total duration encoded so far
    echo $CURDURATION
    CURDURATION=$(bc <<< "$CURDURATION + $NEWDURATION")
    echo $CURDURATION

    i=$((i + 1))

    echo "Duration of $NEXTFILENAME: $NEWDURATION"
    echo "Part No. $i starts at $CURDURATION"
    echo "Current Duration: $CURDURATION"

    NEXTFILENAME="$BASENAME-$i.$EXTENSION"
done


    


    I call the script like this : bash split-video.sh 2024-06-02_12-34-51.mp4 10000000 "-c copy"
Unfortunately, this has an issue where some of the sub videos are extremely short and have wildly inconsistent numbers of frames in them (some with nearly 400, others with 1), despite being similar sizes. I am guessing this has something to do with inconsistent framerate and keyframes or something ?

    


    I am curious what the best way to split a video into equally sized parts, and ideally with similar numbers of frames, is using ffmpeg.

    


  • How can I remove every nth frame from raw video using ffmpeg ?

    15 juin 2024, par DaveB44

    Question moved to SuperUser, please reply there

    


    I have many cine films that have been digitally converted. They have been converted as a 25 fps with 2 frames in every 23 duplicated. I need to remove the duplicated frames using a bitstream filter so there is no decoding/encoding.

    


    After removing the frames I will change to the original cine frame rate of 18 fps. I will then change the frame rate to 25 fps using duplicated frames. I don't want to interpolate as I want to preserve the jerky format of the cine. Finally I will video editing software that will do the final encoding.

    


    All the additional steps will cause several stages of decoding/encoding, that I need to avoid.

    


    First I used a combination of the answers to FFmpeg remove video frames at specific intervals and FFmpeg remove every 6th frame starting from the 3rd frame, on an mp4 file to check it works. I modified it to remove every 4th and 17th frame in 25.

    


    ffmpeg -loglevel warning -i cine.mp4 -an -vf "select='if((mod(n-4,25)),(mod(n-17,25)))',setpts='N/FRAME_RATE/TB'" cine-23.mp4


    


    This works fine, but I end up with a file a quarter the size.

    


    I now used Gyan's answer in Using ffmpeg to change framerate to extract the raw bitstream.

    


    ffmpeg -loglevel warning -i cine.mp4 -c copy -f h264 cine.h264


    


    This created the h264 file as expected, surprisingly it was 16 kB smaller than the original (67 GB file size).

    


    I then modified the code to use the .h264 file.

    


    ffmpeg -loglevel warning -i cine.h264 -vf "select='if((mod(n-4,25)),(mod(n-17,25)))',setpts='N/FRAME_RATE/TB'" cine-23.h264


    


    This gave the following error, but created the cine-23.h264 file although it was the same size as cine-23.mp4 in the test above

    


    [h264 @ 00000245ec0bfb80] non-existing SPS 0 referenced in buffering period
    Last message repeated 1 times


    


    I then checked the ffmpeg bitstream filter documentation and found the bitstream filter setts. I changed my code to the following.

    


    ffmpeg -loglevel warning -i cine.h264 -bsf:v "select='if((mod(n-4,25)),(mod(n-17,25)))',setts=pts='N/FRAME_RATE/TB'" cine-23.h264


    


    Which resulted in the following error.

    


    [vost#0:0/libx264 @ 000002916cf173c0] Error parsing bitstream filter sequence 'select='if((mod(n-4,25)),(mod(n-17,25)))',setts=pts='N/FRAME_RATE/TB'': Bitstream filter not found
Error opening output file cine-23.h264.
Error opening output files: Bitstream filter not found


    


    I'm assuming the error is because setts does not support select. Is there another way to achieve what I am looking for ?

    


    I could use mpdecimate but as that has to compare each frame it is much slower than defining it only needs to delete frames 4 and 17 in every second.

    


    This is the output of ffprobe on my original file.

    


    ffprobe version 2023-11-28-git-47e214245b-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 32.100 / 58. 32.100
  libavcodec     60. 35.100 / 60. 35.100
  libavformat    60. 18.100 / 60. 18.100
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 14.100 /  9. 14.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'cine.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 19529864
    compatible_brands: mp42isom
    creation_time   : 2024-02-19T21:01:10.000000Z
  Duration: 00:01:00.00, start: 0.000000, bitrate: 9245 kb/s
  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 720x576 [SAR 35:32 DAR 175:128], 9243 kb/s, 25 fps, 25 tbr, 25 tbn (default)
    Metadata:
      creation_time   : 2024-02-19T21:01:10.000000Z
      handler_name    : Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : AVC Coding


    


  • Use SDL2 play yuv file but actually no display [closed]

    14 juin 2024, par guan xi

    I use ffmpeg to demux and decode the media file, and then use SDL2 to play the raw data, everything is ok. no error no warning, but SDL2 windows does not dispaly video content.
All i know is frame dts is ordered in SDL2 play queue and data is good.

    


    void VideoPlay::play_video() {
  while (is_running_) {
    refresh_loop_wait_event(&event_);

    switch (event_.type) {
      case SDL_KEYDOWN:
        if (event_.key.keysym.sym == SDLK_q) {
          LOG_INFO("Q quit");
          is_running_ = false;
          frame_queue_->abort();
        }
        break;
      case SDL_QUIT:
        LOG_INFO("SDL_QUIT");
        is_running_ = false;
        frame_queue_->abort();
        break;

      default:
        break;
    }
  }
}

void VideoPlay::refresh_loop_wait_event(SDL_Event *event) {
  SDL_PumpEvents();

  while (
      !SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_FIRSTEVENT, SDL_LASTEVENT)) {
    video_refresh();
    SDL_PumpEvents();
  }
}

void VideoPlay::video_refresh() {
  int ret = 0;
  frame_queue_->pop(frame_);
  if (!frame_) {
    LOG_ERROR("frame_queue_ pop failed.");
    is_running_ = false;
    frame_queue_->abort();
    return;
  }

  rect_.x = 0;
  rect_.y = 0;
  rect_.w = video_width_;
  rect_.h = video_height_;

  ret = SDL_UpdateYUVTexture(
      texture_, &rect_, frame_->data[0], frame_->linesize[0], frame_->data[1],
      frame_->linesize[1], frame_->data[2], frame_->linesize[2]);

  LOG_DEBUG("frame pts: %ld, tot size: %d, Y size: %d, U size: %d, V size: %d",
            frame_->pts, video_width_ * video_height_, frame_->linesize[0],
            frame_->linesize[1], frame_->linesize[2]);
  if (ret != 0) {
    LOG_ERROR("SDL_UpdateYUVTexture failed. %s", SDL_GetError());
    is_running_ = false;
    frame_queue_->abort();
    return;
  }
  ret = SDL_RenderClear(renderer_);
  if (ret != 0) {
    LOG_ERROR("SDL_RenderClear failed. %s", SDL_GetError());
    is_running_ = false;
    frame_queue_->abort();
    return;
  }
  ret = SDL_RenderCopy(renderer_, texture_, nullptr, &rect_);
  if (ret != 0) {
    LOG_ERROR("SDL_RenderCopy failed. %s", SDL_GetError());
    is_running_ = false;
    frame_queue_->abort();
    return;
  }
  SDL_RenderPresent(renderer_);
  SDL_Delay(10);
  av_frame_free(&frame_);
  frame_ = nullptr;
}


    


    log file out put

    


    ~/A_CODES/ffmpeg_official/cmake-build-debug ᐅ cat sdlplay.log
[info]  [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/core/sp_demux.cpp:50  init] audio idx 1 video idx 0
[info]  [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/core/sp_decode.cpp:39  init] codec: h264
[info]  [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/core/sp_decode.cpp:68  init] yuv fmt: yuv420p
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x1100
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x1100
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x300
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x300
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x301
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:100  play_video] event 0x200
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 67, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 133, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 200, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 267, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 333, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 400, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 467, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 533, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 600, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 667, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 733, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 800, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 867, tot size: 82944, Y size: 384, U size: 192, V size: 192
[debug] [2024-06-14 15:39:33] [/home/xiguan/A_CODES/ffmpeg_official/SDLPlayer/sdl/video_play.cpp:151  video_refresh] frame pts: 933, tot size: 82944, Y size: 384, U size: 192, V size: 192


    


    I try to handle SDL2 events correctly as ffplay but no use.
I also gdb to search anything error but nothing happen too.