Recherche avancée

Médias (91)

Autres articles (91)

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

  • Amélioration de la version de base

    13 septembre 2013

    Jolie sélection multiple
    Le plugin Chosen permet d’améliorer l’ergonomie des champs de sélection multiple. Voir les deux images suivantes pour comparer.
    Il suffit pour cela d’activer le plugin Chosen (Configuration générale du site > Gestion des plugins), puis de configurer le plugin (Les squelettes > Chosen) en activant l’utilisation de Chosen dans le site public et en spécifiant les éléments de formulaires à améliorer, par exemple select[multiple] pour les listes à sélection multiple (...)

  • Emballe médias : à quoi cela sert ?

    4 février 2011, par

    Ce plugin vise à gérer des sites de mise en ligne de documents de tous types.
    Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;

Sur d’autres sites (13783)

  • Video fingerprinting not working for the video

    2 septembre 2024, par Veer Pratap

    I implemented video fingerprinting, and it works well when the videos are exactly the same, producing a similarity score of 1. However, I encounter an issue when comparing videos that have been merged in different orders. For instance, if I merge video1 and video2 to create a new video and then merge them in reverse order (video2 + video1), the system fails to detect any matching frames between the two resulting videos.

    


    The challenge lies in comparing frames between videos regardless of their timing or order. How can I modify the comparison process to ensure that frames are matched correctly even when the order of video segments changes ?

    


    use ffmpeg_next::{codec, format, frame, media, packet, Error};&#xA;use sha2::{Digest, Sha256};&#xA;use std::collections::HashSet;&#xA;&#xA;pub fn extract_frames(video_path: &amp;str) -> Result>, Error> {&#xA;    ffmpeg_next::init()?;&#xA;    let mut ictx = format::input(&amp;video_path)?;&#xA;    let input_stream_index = ictx&#xA;        .streams()&#xA;        .best(media::Type::Video)&#xA;        .ok_or(Error::StreamNotFound)?&#xA;        .index();&#xA;    let codec_params = ictx&#xA;        .stream(input_stream_index)&#xA;        .ok_or(Error::StreamNotFound)?&#xA;        .parameters();&#xA;    let codec = codec::Id::from(codec_params.id());&#xA;    let mut decoder = codec::Context::from_parameters(codec_params)?&#xA;        .decoder()&#xA;        .video()?;&#xA;    let mut frame = frame::Video::empty();&#xA;    let mut frames = Vec::new();&#xA;    let mut packet_count = 0;&#xA;    let mut frame_count = 0;&#xA;&#xA;    for (stream, packet) in ictx.packets() {&#xA;        packet_count &#x2B;= 1;&#xA;        if stream.index() == input_stream_index {&#xA;            decoder.send_packet(&amp;packet)?;&#xA;            while let Ok(()) = decoder.receive_frame(&amp;mut frame) {&#xA;                let frame_data = frame.data(0).to_vec();&#xA;                frames.push(frame_data);&#xA;                frame_count &#x2B;= 1;&#xA;                eprintln!("Extracted frame {}", frame_count);&#xA;            }&#xA;        }&#xA;    }&#xA;    eprintln!(&#xA;        "Processed {} packets and extracted {} frames",&#xA;        packet_count, frame_count&#xA;    );&#xA;    Ok(frames)&#xA;}&#xA;&#xA;pub fn hash_frame(frame: &amp;[u8]) -> Vec<u8> {&#xA;    let mut hasher = Sha256::new();&#xA;    hasher.update(frame);&#xA;    hasher.finalize().to_vec()&#xA;}&#xA;&#xA;/// Generates a vector of fingerprints for the given video frames.&#xA;///&#xA;/// This function takes a vector of frames (each represented as a vector of bytes)&#xA;/// and generates a fingerprint for each frame using the SHA-256 hash function.&#xA;///&#xA;/// # Arguments&#xA;///&#xA;/// * `frames` - A vector of video frames, where each frame is a `Vec<u8>` representing the frame&#x27;s raw data.&#xA;///&#xA;/// # Returns&#xA;///&#xA;/// * `Vec>` - A vector of fingerprints, where each fingerprint is a `Vec<u8>` representing the SHA-256 hash of the corresponding frame.&#xA;pub fn generate_fingerprints(frames: Vec>) -> Vec> {&#xA;    frames.into_iter().map(|frame| hash_frame(&amp;frame)).collect()&#xA;}&#xA;&#xA;/// Compares two videos by extracting frames and generating fingerprints, then computing the similarity between the two sets of fingerprints.&#xA;///&#xA;/// This function extracts frames from the two provided video files, generates fingerprints for each frame,&#xA;/// and compares the fingerprints to determine the similarity between the two videos.&#xA;///&#xA;/// # Arguments&#xA;///&#xA;/// * `video_path1` - A string slice that holds the path to the first video file.&#xA;/// * `video_path2` - A string slice that holds the path to the second video file.&#xA;///&#xA;/// # Returns&#xA;///&#xA;/// * `Result>` - The similarity score between the two videos as a floating-point value (0.0 to 1.0).&#xA;///    Returns an error if there is an issue with extracting frames or generating fingerprints.&#xA;///&#xA;/// # Errors&#xA;///&#xA;/// This function will return an error if:&#xA;/// * There is an issue with opening or reading the video files.&#xA;/// * There is an issue with extracting frames from the video files.&#xA;/// * There is an issue with generating fingerprints from the frames.&#xA;pub fn compare_videos(&#xA;    video_path1: &amp;str,&#xA;    video_path2: &amp;str,&#xA;) -> Result> {&#xA;    println!("Comparing videos: {} and {}", video_path1, video_path2);&#xA;    let frames1 = extract_frames(video_path1)?;&#xA;    let frames2 = extract_frames(video_path2)?;&#xA;&#xA;    let fingerprints1: HashSet&lt;_> = generate_fingerprints(frames1).into_iter().collect();&#xA;    let fingerprints2: HashSet&lt;_> = generate_fingerprints(frames2).into_iter().collect();&#xA;&#xA;    println!("Number of fingerprints in video 1: {}", fingerprints1.len());&#xA;    println!("Number of fingerprints in video 2: {}", fingerprints2.len());&#xA;&#xA;    if !fingerprints1.is_empty() &amp;&amp; !fingerprints2.is_empty() {&#xA;        println!(&#xA;            "Sample fingerprint from video 1: {:?}",&#xA;            fingerprints1.iter().take(1).collect::>()&#xA;        );&#xA;        println!(&#xA;            "Sample fingerprint from video 2: {:?}",&#xA;            fingerprints2.iter().take(1).collect::>()&#xA;        );&#xA;    }&#xA;&#xA;    // Calculate Jaccard similarity&#xA;    let intersection_size = fingerprints1.intersection(&amp;fingerprints2).count();&#xA;    let union_size = fingerprints1.union(&amp;fingerprints2).count();&#xA;&#xA;    println!("Intersection size: {}", intersection_size);&#xA;    println!("Union size: {}", union_size);&#xA;&#xA;    let similarity = if union_size == 0 {&#xA;        0.0&#xA;    } else {&#xA;        intersection_size as f64 / union_size as f64&#xA;    };&#xA;&#xA;    println!("Similarity score: {}", similarity);&#xA;&#xA;    Ok(similarity)&#xA;}&#xA;&#xA;</u8></u8></u8>

    &#xA;

  • ffmpeg wrong framerate when converting x264 to x265

    11 avril 2023, par Andreas

    I want to convert the video files from my Samsung phone to a more efficient format. Samsung uses x264 with a very high bitrate, instead I am using x265 with the following settings :

    &#xA;

    ffmpeg -i IN.mp4 -c:v libx265 -c:a copy -x265-params crf=25 OUT.mp4&#xA;

    &#xA;

    However, there seems to be a problem with the framerate. Samsung specifies 60 fps in the metadata, but the video stream shows 29.95 fps.&#xA;If I use the above command to convert to x265, it even outputs a stream with 120 fps. ffmpeg also shows the warning "More than 1000 frames duplicated".

    &#xA;

    How can I keep the original framerate ?

    &#xA;

    Here is the ffmpeg output :

    &#xA;

    ffmpeg -i IN.mp4 -c:v libx265 -c:a copy -x265-params crf=25 OUT.mp4&#xA;ffmpeg version N-110223-gb18a9c2971-20230410 Copyright (c) 2000-2023 the FFmpeg developers&#xA;  built with gcc 12.2.0 (crosstool-NG 1.25.0.152_89671bf)&#xA;  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --disable-libmfx --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20230410&#xA;  libavutil      58.  6.100 / 58.  6.100&#xA;  libavcodec     60.  9.100 / 60.  9.100&#xA;  libavformat    60.  4.101 / 60.  4.101&#xA;  libavdevice    60.  2.100 / 60.  2.100&#xA;  libavfilter     9.  5.100 /  9.  5.100&#xA;  libswscale      7.  2.100 /  7.  2.100&#xA;  libswresample   4. 11.100 /  4. 11.100&#xA;  libpostproc    57.  2.100 / 57.  2.100&#xA;Input #0, mov,mp4,m4a,3gp,3g2,mj2, from &#x27;IN.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: isommp42&#xA;    creation_time   : 2023-03-17T13:51:19.000000Z&#xA;    com.android.version: 13&#xA;    com.android.capture.fps: 60.000000&#xA;  Duration: 00:01:16.64, start: 0.000000, bitrate: 26864 kb/s&#xA;  Stream #0:0[0x1](eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080, 26603 kb/s, 29.95 fps, 120 tbr, 90k tbn (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-03-17T13:51:19.000000Z&#xA;      handler_name    : VideoHandle&#xA;      vendor_id       : [0][0][0][0]&#xA;  Stream #0:1[0x2](eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-03-17T13:51:19.000000Z&#xA;      handler_name    : SoundHandle&#xA;      vendor_id       : [0][0][0][0]&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))&#xA;  Stream #0:1 -> #0:1 (copy)&#xA;Press [q] to stop, [?] for help&#xA;x265 [info]: HEVC encoder version 3.5&#x2B;95-38cf1c379&#xA;x265 [info]: build info [Windows][GCC 12.2.0][64 bit] 8bit&#x2B;10bit&#x2B;12bit&#xA;x265 [info]: using cpu capabilities: MMX2 SSE2Fast LZCNT SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2&#xA;x265 [info]: Main profile, Level-5 (Main tier)&#xA;x265 [info]: Thread pool created using 16 threads&#xA;x265 [info]: Slices                              : 1&#xA;x265 [info]: frame threads / pool features       : 4 / wpp(17 rows)&#xA;x265 [info]: Coding QT: max CU size, min CU size : 64 / 8&#xA;x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra&#xA;x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 3&#xA;x265 [info]: Keyframe min / max / scenecut / bias  : 25 / 250 / 40 / 5.00&#xA;x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2&#xA;x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0&#xA;x265 [info]: References / ref-limit  cu / depth  : 3 / off / on&#xA;x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1&#xA;x265 [info]: Rate Control / qCompress            : CRF-25.0 / 0.60&#xA;x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip mode=1 signhide tmvp&#xA;x265 [info]: tools: b-intra strong-intra-smoothing lslices=6 deblock sao&#xA;Output #0, mp4, to &#x27;OUT.mp4&#x27;:&#xA;  Metadata:&#xA;    major_brand     : mp42&#xA;    minor_version   : 0&#xA;    compatible_brands: isommp42&#xA;    com.android.capture.fps: 60.000000&#xA;    com.android.version: 13&#xA;    encoder         : Lavf60.4.101&#xA;  Stream #0:0(eng): Video: hevc (hev1 / 0x31766568), yuv420p(tv, bt709, progressive), 1920x1080, q=2-31, 120 fps, 15360 tbn (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-03-17T13:51:19.000000Z&#xA;      handler_name    : VideoHandle&#xA;      vendor_id       : [0][0][0][0]&#xA;      encoder         : Lavc60.9.100 libx265&#xA;    Side data:&#xA;      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A&#xA;  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default)&#xA;    Metadata:&#xA;      creation_time   : 2023-03-17T13:51:19.000000Z&#xA;      handler_name    : SoundHandle&#xA;      vendor_id       : [0][0][0][0]&#xA;[vost#0:0/libx265 @ 00000249776f1440] More than 1000 frames duplicated40.0kbits/s dup=991 drop=0 speed=0.484x&#xA;frame= 9197 fps= 52 q=37.0 Lsize=   32338kB time=00:01:16.61 bitrate=3457.6kbits/s dup=6902 drop=0 speed=0.43x&#xA;video:29752kB audio:2393kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.600966%&#xA;x265 [info]: frame I:     79, Avg QP:25.98  kb/s: 25459.52&#xA;x265 [info]: frame P:   2332, Avg QP:31.54  kb/s: 9763.15&#xA;x265 [info]: frame B:   6786, Avg QP:36.46  kb/s: 653.28&#xA;x265 [info]: Weighted P-Frames: Y:5.5% UV:5.3%&#xA;&#xA;encoded 9197 frames in 177.98s (51.68 fps), 3176.26 kb/s, Avg QP:35.12&#xA;

    &#xA;

  • How to achieve 1x writing speed for 4K encoding in ffmpeg ?

    27 avril 2023, par Anand92

    Is it possible to encode 4K asset in 1x writing speed ?

    &#xA;&#xA;

    Below are our encoding commands and details of CPU, source assets, and encoding command output :

    &#xA;&#xA;

    Encoding command

    &#xA;&#xA;

    ffmpeg -i 4K_Source.mp4 -c:v libx265 -preset ultrafast&#xA;    -x265-params fps=60:profile=main:min-keyint=60:crf=19 -vf "scale=3840:2160"&#xA;    -sc_threshold 0 4K_UF_3840x2160_CRF19.mp4&#xA;

    &#xA;&#xA;

    Source Asset Details

    &#xA;&#xA;

    Overall bit rate mode      : Constant&#xA;Overall bit rate           : 51.6 Mb/s&#xA;Format                     : HEVC&#xA;Format/Info                : High Efficiency Video Coding&#xA;Format profile             : Main 10@L5.1@High&#xA;Duration                   : 1 min 33 s&#xA;Width                      : 3 840 pixels&#xA;Height                     : 2 160 pixels&#xA;Display aspect ratio       : 16:9&#xA;Frame rate                 : 59.940 (60000/1001) FPS&#xA;

    &#xA;&#xA;

    CPU details

    &#xA;&#xA;

    Intel(R) Xeon(R) CPU E7-8870 v3 @ 2.10GHz (144 core)&#xA;

    &#xA;&#xA;

    FFMPEG command output

    &#xA;&#xA;

    ffmpeg version 3.2.4-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2017 the FFmpeg developers&#xA;  built with gcc 5.4.1 (Debian 5.4.1-5) 20170205&#xA;  configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-5 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg&#xA;  libavutil      55. 34.101 / 55. 34.101&#xA;  libavcodec     57. 64.101 / 57. 64.101&#xA;  libavformat    57. 56.101 / 57. 56.101&#xA;  libavdevice    57.  1.100 / 57.  1.100&#xA;  libavfilter     6. 65.100 /  6. 65.100&#xA;  libswscale      4.  2.100 /  4.  2.100&#xA;  libswresample   2.  3.100 /  2.  3.100&#xA;  libpostproc    54.  1.100 / 54.  1.100&#xA;[mpegts @ 0x3a2b600] start time for stream 1 is not set in estimate_timings_from_pts&#xA;[mpegts @ 0x3a2b600] Could not find codec parameters for stream 1 (Audio:  &#xA;aac ([15][0][0][0] / 0x000F), 0 channels, fltp): unspecified sample rate&#xA;Consider increasing the value for the &#x27;analyzeduration&#x27; and &#x27;probesize&#x27;   &#xA;options&#xA;Input #0, mpegts, from &#x27;Samsung_SUHD_Colorful_Food.mp4&#x27;:&#xA;  Duration: 00:01:33.11, start: 1.050044, bitrate: 52076 kb/s&#xA;  Program 1&#xA;    Stream #0:0[0x101]: Video: hevc (Main 10) ([36][0][0][0] / 0x0024), yuv420p10le(tv), 3840x2160 [SAR 1:1 DAR 16:9], 59.94 fps, 59.94 tbr, 90k  &#xA; tbn, 59.94 tbc&#xA;    Stream #0:1[0x102](und): Audio: aac ([15][0][0][0] / 0x000F), 0 channels, fltp&#xA;[libx265 @ 0x3a53d40] Unknown option: profile.&#xA;x265 [info]: HEVC encoder version 2.2&#x2B;35-fe2f2dd96f8c&#xA;x265 [info]: build info [Linux][GCC 5.4.1][64 bit] 10bit&#xA;x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2&#xA;x265 [info]: Main 10 profile, Level-5.1 (Main tier)&#xA;x265 [info]: Thread pool 0 using 64 threads on numa nodes 0,1,2,3&#xA;x265 [info]: Thread pool 1 using 64 threads on numa nodes 0,1,2,3&#xA;x265 [info]: Slices                              : 1&#xA;x265 [info]: frame threads / pool features       : 8 / wpp(68 rows)&#xA;x265 [info]: Coding QT: max CU size, min CU size : 32 / 16&#xA;x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra&#xA;x265 [info]: ME / range / subpel / merge         : dia / 57 / 0 / 2&#xA;x265 [info]: Keyframe min / max / scenecut / bias: 60 / 250 / 0 / 5.00&#xA;x265 [info]: Lookahead / bframes / badapt        : 5 / 3 / 0&#xA;x265 [info]: b-pyramid / weightp / weightb       : 1 / 0 / 0&#xA;x265 [info]: References / ref-limit  cu / depth  : 1 / off / off&#xA;x265 [info]: AQ: mode / str / qg-size / cu-tree  : 1 / 0.0 / 32 / 1&#xA;x265 [info]: Rate Control / qCompress            : CRF-19.0 / 0.60&#xA;x265 [info]: tools: rd=2 psy-rd=2.00 early-skip rskip tmvp fast-intra&#xA;x265 [info]: tools: strong-intra-smoothing lslices=8 deblock&#xA;Output #0, mp4, to &#x27;Samsung_UF_3840x2160_CRF19.mp4&#x27;:&#xA;  Metadata:&#xA;    encoder         : Lavf57.56.101&#xA;    Stream #0:0: Video: hevc (libx265) ([35][0][0][0] / 0x0023), yuv420p10le, 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 60k tbn, 59.94 tbc&#xA;    Metadata:&#xA;      encoder         : Lavc57.64.101 libx265&#xA;Stream mapping:&#xA;  Stream #0:0 -> #0:0 (hevc (native) -> hevc (libx265))&#xA;Press [q] to stop, [?] for help&#xA;frame= 5581 fps= 20 q=-0.0 Lsize=  212585kB time=00:01:33.05&#xA;bitrate=18713.8kbits/s speed=0.336x&#xA;video:212514kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.033184%&#xA;x265 [info]: frame I:     23, Avg QP:24.29  kb/s: 133747.47&#xA;x265 [info]: frame P:   1401, Avg QP:26.43  kb/s: 31994.19&#xA;x265 [info]: frame B:   4157, Avg QP:29.67  kb/s: 13602.20&#xA;x265 [info]: consecutive B-frames: 1.3% 1.4% 1.5% 95.9%&#xA;encoded 5581 frames in 276.59s (20.18 fps), 18714.28 kb/s, Avg QP:28.83 &#xA;

    &#xA;&#xA;

    The encoding speed we get is 0.3x only. we are trying encode HEVC codec asset to HEVC codec itself with 4K resolution in 1x writing speed.

    &#xA;&#xA;

    Are we missing any parameters in ffmpeg command which can tweak encoding speed ?

    &#xA;