Recherche avancée

Médias (1)

Mot : - Tags -/book

Autres articles (20)

  • Publier sur MédiaSpip

    13 juin 2013

    Puis-je poster des contenus à partir d’une tablette Ipad ?
    Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir

  • Creating farms of unique websites

    13 avril 2011, par

    MediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
    This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)

  • Submit enhancements and plugins

    13 avril 2011

    If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
    You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.

Sur d’autres sites (5765)

  • VLC and ffplay not receiving video from RTMP stream on Nginx

    14 janvier, par Ekobadd

    I'm streaming via OBS 30.1.2 to an RTMP server on a digitalocean droplet. The server is running on nginx 1.26.0 using the RTMP plugin (libnginx-mod-rtmp in apt).

    


    OBS is configured to output H.264-encoded, 1200kbps, 24fps, 1920x1080 video and aac-encoded, stereo, 44.1kHz, 160kbps audio.

    


    Below is the minimal reproducible example. When I attempt to play the rtmp stream with ffplay or VLC, it's a random chance whether I get video or not. Audio is always fine. The output from ffplay or ffprobe (example below) occasionally does not show any video stream.

    


    rtmp {&#xA;        server {&#xA;                listen 1935;&#xA;                chunk_size 4096;&#xA;&#xA;                application ingest {&#xA;                        live on;&#xA;                        record off;&#xA;&#xA;                        allow publish <my ip="ip" address="address">;&#xA;                        deny publish all;&#xA;&#xA;                        allow play all;&#xA;                }&#xA;        }&#xA;}&#xA;</my>

    &#xA;

    The server has two applications, "ingest" and "live", the former uses the following ffmpeg command to transcode the stream and create a corresponding stream on the latter application :

    &#xA;

    exec_push ffmpeg -i rtmp://localhost/ingest/$name -b:v 1200k -c:v libx264 -c:a aac -ar 44100 -ac 1 -f flv -preset veryfast -tune zerolatency rtmp://localhost/live/$name 2>>/tmp/rtmp-ingest-$name.log;&#xA;

    &#xA;

    As you can see, this produces a log which shows the following :

    &#xA;

    Output #0, flv, to &#x27;rtmp://localhost/live/ekobadd&#x27;:&#xA;  Metadata:&#xA;    |RtmpSampleAccess: true&#xA;    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)&#xA;    displayWidth    : 1920&#xA;    displayHeight   : 1080&#xA;    fps             : 23&#xA;    profile         :&#xA;    level           :&#xA;    encoder         : Lavf61.1.100&#xA;  Stream #0:0: Audio: aac (LC) ([10][0][0][0] / 0x000A), 44100 Hz, mono, fltp, 69 kb/s&#xA;      Metadata:&#xA;        encoder         : Lavc61.3.100 aac&#xA;

    &#xA;

    The video is not present, though I can see on the digitalocean control panel that the server is pulling 1.2Mbps inbound, which is about the same as my OBS video bitrate. And, although the ffmpeg instance which is transcoding does not appear to see the video stream from the ingest application, ffprobe from my local machine does, sometimes :

    &#xA;

    > ffprobe rtmp://mydomain.com/ingest/ekobadd&#xA;...&#xA;Input #0, flv, from &#x27;rtmp://mydomain.com/ingest/ekobadd&#x27;:   0B f=0/0&#xA;  Metadata:&#xA;    |RtmpSampleAccess: true&#xA;    Server          : NGINX RTMP (github.com/arut/nginx-rtmp-module)&#xA;    displayWidth    : 1920&#xA;    displayHeight   : 1080&#xA;    fps             : 23&#xA;    profile         :&#xA;    level           :&#xA;  Duration: 00:00:00.00, start: 122.045000, bitrate: N/A&#xA;  Stream #0:0: Audio: aac (LC), 48000 Hz, stereo, fltp, 163 kb/s&#xA;  Stream #0:1: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 1228 kb/s, 23 fps, 23.98 tbr, 1k tbn&#xA;     126.24 A-V: -1.071 fd=   0 aq=   54KB vq=  161KB sq=    0B f=0/0&#xA;

    &#xA;

    Sometimes, however, it doesn't see the stream at all :

    &#xA;

    [rtmp @ 0000022d87d0fe00] Server error: No such stream&#xA;rtmp://mydomain.com/ingest/ekobadd: Operation not permitted&#xA;

    &#xA;

    Testing the stream with VLC gives the same results.

    &#xA;

    Of course, the "live" application also doesn't have video. I have, however, streamed video from it before. I assume if I restart nginx enough, that the exec_push ffmpeg command will randomly see the video stream much like ffprobe does. I also have HLS and DASH configured, and they're both working perfect if you're a radio talk show host.

    &#xA;

    /etc/nginx/nginx.conf : (I'm quite sure I never touched anything in the HTTP section, but it's included just in case)

    &#xA;

    rtmp {&#xA;        server {&#xA;                listen 1935;&#xA;                chunk_size 8192;&#xA;&#xA;                idle_streams off;&#xA;&#xA;                application ingest {&#xA;                        live on;&#xA;                        record off;&#xA;&#xA;                        # Transcode to h264/aac via flv, 1.2Mbps 24fps 44.1kHz, single audio channel video (HLS Ready)&#xA;                        exec_push ffmpeg -i rtmp://localhost/ingest/$name -b:v 1200k -c:v libx264 -c:a aac -ar 44100 -ac 1 -f flv -preset veryfast -tune zerolatency rtmp://localhost/live/$name 2>>/tmp/rtmp-ingest-$name.log;&#xA;&#xA;                        allow publish <my ip="ip" address="address">;&#xA;                        deny publish all;&#xA;&#xA;                        allow play all; # This was added for debugging.&#xA;                }&#xA;&#xA;                application live {&#xA;                        live on;&#xA;                        record off;&#xA;&#xA;                        hls on;&#xA;                        hls_path /var/www/mydomain.com/html/live/hls;&#xA;                        hls_fragment 6s;&#xA;                        hls_playlist_length 60;&#xA;&#xA;                        dash on;&#xA;                        dash_path /var/www/mydomain.com/html/live/dash;&#xA;&#xA;                        allow publish 127.0.0.1;&#xA;                        deny publish all;&#xA;&#xA;                        allow play all;&#xA;                }&#xA;        }&#xA;}&#xA;&#xA;http {&#xA;&#xA;        ##&#xA;        # Basic Settings&#xA;        ##&#xA;&#xA;        sendfile on;&#xA;        tcp_nopush on;&#xA;        types_hash_max_size 2048;&#xA;        server_tokens build; # Recommended practice is to turn this off&#xA;&#xA;        server_names_hash_bucket_size 64;&#xA;        # server_name_in_redirect off;&#xA;&#xA;        include /etc/nginx/mime.types;&#xA;        default_type application/octet-stream;&#xA;&#xA;        ##&#xA;        # SSL Settings&#xA;        ##&#xA;&#xA;        ssl_protocols TLSv1.2 TLSv1.3; # Dropping SSLv3 (POODLE), TLS 1.0, 1.1&#xA;        ssl_prefer_server_ciphers off; # Don&#x27;t force server cipher order.&#xA;&#xA;        ##&#xA;        # Logging Settings&#xA;        ##&#xA;&#xA;        access_log /var/log/nginx/access.log;&#xA;&#xA;        ##&#xA;        # Gzip Settings&#xA;        ##&#xA;&#xA;        gzip on;&#xA;&#xA;        # gzip_vary on;&#xA;        # gzip_proxied any;&#xA;        # gzip_comp_level 6;&#xA;        # gzip_buffers 16 8k;&#xA;        # gzip_http_version 1.1;&#xA;        # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml&#x2B;rss text/javascript;&#xA;&#xA;        ##&#xA;        # Virtual Host Configs&#xA;        ##&#xA;&#xA;        include /etc/nginx/conf.d/*.conf;&#xA;        include /etc/nginx/sites-enabled/*;&#xA;}&#xA;</my>

    &#xA;

    /etc/nginx/sites-available/mydomain.com :

    &#xA;

    server {&#xA;        listen 443 ssl;&#xA;&#xA;        ssl_certificate     /etc/letsencrypt/live/mydomain.com/fullchain.pem;&#xA;        ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;&#xA;        ssl_protocols       TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;&#xA;        ssl_ciphers         HIGH:!aNULL:!MD5;&#xA;&#xA;        root /var/www/mydomain.com/html;&#xA;&#xA;        server_name mydomain.com www.mydomain.com;&#xA;&#xA;        location / {&#xA;                root /var/www/mydomain.com/html/live;&#xA;&#xA;#               add_header Cache-Control no-cache;&#xA;                add_header Access-Control-Allow-Origin *;&#xA;        }&#xA;}&#xA;&#xA;types {&#xA;#       application/vnd.apple.mpegurl m3u8;&#xA;        application/dash&#x2B;xml mpd;&#xA;}&#xA;

    &#xA;

  • ffmpeg-next potential bug in write_header causes timebase to bet set to Rational(1/15360)

    7 septembre 2024, par Huhngut

    I am trying to encode a video using the ffmpeg_next crate. I got everything working and it successfully creates an output video.&#xA;The only problem is that the time_base of my stream is wrongly written to the file.&#xA;I can confirm that I set the timebase correctly for both the encoder as well as the stream.

    &#xA;

    By debug prints I was able to narrow the problem down. octx.write_header().unwrap(); causes the stream timebase to be reset from Rational(1/30) to Rational(1/15360). Changing the timebase back afterwards has no effect. The wrong value must have been written to the header.

    &#xA;

    I modified the src code of ffmpeg-next and recompiled it. I can confirm that the correct value is set before the call to avformat_write_header

    &#xA;

    pub fn write_header(&amp;mut self) -> Result&lt;(), Error> {&#xA;        println!(&#xA;            "_________________ {:?}",&#xA;            self.stream(0).unwrap().time_base()&#xA;        );&#xA;        unsafe {&#xA;            match avformat_write_header(self.as_mut_ptr(), ptr::null_mut()) {&#xA;                0 => Ok(()),&#xA;                e => Err(Error::from(e)),&#xA;            }&#xA;        }&#xA;    }&#xA;

    &#xA;

    To my understanding this must be a bug in the crate but I dont want to accuse someone with my non existing knowledge about ffmpeg. Also the examples in the github repo seem not to have this problem. My fault then ? Unfortunately I was not able to get the transcode-x264 to run. Most of my code comes from this example.

    &#xA;

    Relevant code bits are these. I dont know how much the set_parameters influences anything. My testing said it has no influence. I also tried to set the timebase at the very end of the function if it gets reset my the parameters. This is not working

    &#xA;

    let mut ost = octx.add_stream(codec)?;&#xA;ost.set_time_base(Rational::new(1, FPS));&#xA;&#xA;ost.set_parameters(&amp;encoder);&#xA;encoder.set_time_base(Rational::new(1, FPS));&#xA;ost.set_parameters(&amp;opened_encoder);&#xA;

    &#xA;

    By default and in the above example the streams timebase is 0/0. If I leave it out or change it to this manually it has no effect.

    &#xA;

    I also noticed that changing the value inside set_pts influences the output fps. Although not the timebase. I think this is more of a sideeffect.

    &#xA;

    I will leave a minimal reproducible example below. Any help or hints would be appreciated

    &#xA;

    abstract main function

    &#xA;

    fn main() {&#xA;    let output_file = "output.mp4";&#xA;    let x264_opts = parse_opts("preset=medium".to_string()).expect("invalid x264 options string");&#xA;&#xA;    ffmpeg_next::init().unwrap();&#xA;    let mut octx = format::output(output_file).unwrap();&#xA;&#xA;    let mut encoder = Encoder::new(&amp;mut octx, x264_opts).unwrap();&#xA;&#xA;    format::context::output::dump(&amp;octx, 0, Some(&amp;output_file));&#xA;    //This line somehow clears the streams time base&#xA;    octx.write_header().unwrap();&#xA;&#xA;    // Without this line, the next logs returns Rational(1/30) Rational(1/15360) indicating streams timebase is wrong. even thought I set it above&#xA;    // this line changes it back but only for the print but not the actual output. Because the faulty data is written into the header&#xA;    // octx.stream_mut(0)&#xA;    //     .unwrap()&#xA;    //     .set_time_base(Rational::new(1, FPS));&#xA;&#xA;    println!(&#xA;        "---------------- {:?} {:?}",&#xA;        encoder.encoder.time_base(),&#xA;        octx.stream(0).unwrap().time_base(),&#xA;    );&#xA;&#xA;    for frame_num in 0..100 {&#xA;        let mut frame = encoder.create_frame();&#xA;        frame.set_pts(Some(frame_num));&#xA;        encoder.add_frame(&amp;frame, &amp;mut octx);&#xA;    }&#xA;&#xA;    encoder.close(&amp;mut octx);&#xA;    octx.write_trailer().unwrap();&#xA;}&#xA;

    &#xA;

    Encoder struct containing the implementation logic

    &#xA;

    struct Encoder {&#xA;    encoder: encoder::Video,&#xA;}&#xA;&#xA;impl Encoder {&#xA;    fn new(&#xA;        octx: &amp;mut format::context::Output,&#xA;        x264_opts: Dictionary,&#xA;    ) -> Result {&#xA;        let set_header = octx&#xA;            .format()&#xA;            .flags()&#xA;            .contains(ffmpeg_next::format::flag::Flags::GLOBAL_HEADER);&#xA;&#xA;        let codec = encoder::find(codec::Id::H264);&#xA;        let mut ost = octx.add_stream(codec)?;&#xA;        ost.set_time_base(Rational::new(1, FPS));&#xA;&#xA;        let mut encoder = codec::context::Context::new_with_codec(&#xA;            encoder::find(codec::Id::H264)&#xA;                .ok_or(ffmpeg_next::Error::InvalidData)&#xA;                .unwrap(),&#xA;        )&#xA;        .encoder()&#xA;        .video()&#xA;        .unwrap();&#xA;        ost.set_parameters(&amp;encoder);&#xA;&#xA;        encoder.set_width(WIDTH);&#xA;        encoder.set_height(HEIGHT);&#xA;        encoder.set_aspect_ratio(WIDTH as f64 / HEIGHT as f64);&#xA;        encoder.set_format(util::format::Pixel::YUV420P);&#xA;        encoder.set_frame_rate(Some(Rational::new(FPS, 1)));&#xA;        encoder.set_time_base(Rational::new(1, FPS));&#xA;&#xA;        if set_header {&#xA;            encoder.set_flags(ffmpeg_next::codec::flag::Flags::GLOBAL_HEADER);&#xA;        }&#xA;&#xA;        let opened_encoder = encoder&#xA;            .open_with(x264_opts.to_owned())&#xA;            .expect("error opening x264 with supplied settings");&#xA;        ost.set_parameters(&amp;opened_encoder);&#xA;&#xA;        println!(&#xA;            "\nost time_base: {}; encoder time_base: {}; encoder frame_rate: {}\n",&#xA;            ost.time_base(),&#xA;            &amp;opened_encoder.time_base(),&#xA;            &amp;opened_encoder.frame_rate()&#xA;        );&#xA;&#xA;        Ok(Self {&#xA;            encoder: opened_encoder,&#xA;        })&#xA;    }&#xA;&#xA;    fn add_frame(&amp;mut self, frame: &amp;frame::Video, octx: &amp;mut format::context::Output) {&#xA;        self.encoder.send_frame(frame).unwrap();&#xA;        self.process_packets(octx);&#xA;    }&#xA;&#xA;    fn close(&amp;mut self, octx: &amp;mut format::context::Output) {&#xA;        self.encoder.send_eof().unwrap();&#xA;        self.process_packets(octx);&#xA;    }&#xA;&#xA;    fn process_packets(&amp;mut self, octx: &amp;mut format::context::Output) {&#xA;        let mut encoded = Packet::empty();&#xA;        while self.encoder.receive_packet(&amp;mut encoded).is_ok() {&#xA;            encoded.set_stream(0);&#xA;            encoded.write_interleaved(octx).unwrap();&#xA;        }&#xA;    }&#xA;&#xA;    fn create_frame(&amp;self) -> frame::Video {&#xA;        return frame::Video::new(&#xA;            self.encoder.format(),&#xA;            self.encoder.width(),&#xA;            self.encoder.height(),&#xA;        );&#xA;    }&#xA;}&#xA;

    &#xA;

    other util stuff

    &#xA;

    use ffmpeg_next::{&#xA;    codec::{self},&#xA;    encoder, format, frame, util, Dictionary, Packet, Rational,&#xA;};&#xA;&#xA;const FPS: i32 = 30;&#xA;const WIDTH: u32 = 720;&#xA;const HEIGHT: u32 = 1080;&#xA;&#xA;fn parse_opts&lt;&#x27;a>(s: String) -> Option> {&#xA;    let mut dict = Dictionary::new();&#xA;    for keyval in s.split_terminator(&#x27;,&#x27;) {&#xA;        let tokens: Vec&lt;&amp;str> = keyval.split(&#x27;=&#x27;).collect();&#xA;        match tokens[..] {&#xA;            [key, val] => dict.set(key, val),&#xA;            _ => return None,&#xA;        }&#xA;    }&#xA;    Some(dict)&#xA;}&#xA;

    &#xA;

  • aaccoder : Implement Perceptual Noise Substitution for AAC

    15 avril 2015, par Rostislav Pehlivanov
    aaccoder : Implement Perceptual Noise Substitution for AAC
    

    This commit implements the perceptual noise substitution AAC extension. This is a proof of concept
    implementation, and as such, is not enabled by default. This is the fourth revision of this patch,
    made after some problems were noted out. Any changes made since the previous revisions have been indicated.

    In order to extend the encoder to use an additional codebook, the array holding each codebook has been
    modified with two additional entries - 13 for the NOISE_BT codebook and 12 which has a placeholder function.
    The cost system was modified to skip the 12th entry using an array to map the input and outputs it has. It
    also does not accept using the 13th codebook for any band which is not marked as containing noise, thereby
    restricting its ability to arbitrarily choose it for bands. The use of arrays allows the system to be easily
    extended to allow for intensity stereo encoding, which uses additional codebooks.

    The 12th entry in the codebook function array points to a function which stops the execution of the program
    by calling an assert with an always ’false’ argument. It was pointed out in an email discussion with
    Claudio Freire that having a ’NULL’ entry can result in unexpected behaviour and could be used as
    a security hole. There is no danger of this function being called during encoding due to the codebook maps introduced.

    Another change from version 1 of the patch is the addition of an argument to the encoder, ’-aac_pns’ to
    enable and disable the PNS. This currently defaults to disable the PNS, as it is experimental.
    The switch will be removed in the future, when the algorithm to select noise bands has been improved.
    The current algorithm simply compares the energy to the threshold (multiplied by a constant) to determine
    noise, however the FFPsyBand structure contains other useful figures to determine which bands carry noise more accurately.

    Some of the sample files provided triggered an assertion when the parameter to tune the threshold was set to
    a value of ’2.2’. Claudio Freire reported the problem’s source could be in the range of the scalefactor
    indices for noise and advised to measure the minimal index and clip anything above the maximum allowed
    value. This has been implemented and all the files which used to trigger the asserion now encode without error.

    The third revision of the problem also removes unneded variabes and comparisons. All of them were
    redundant and were of little use for when the PNS implementation would be extended.

    The fourth revision moved the clipping of the noise scalefactors outside the second loop of the two-loop
    algorithm in order to prevent their redundant calculations. Also, freq_mult has been changed to a float
    variable due to the fact that rounding errors can prove to be a problem at low frequencies.
    Considerations were taken whether the entire expression could be evaluated inside the expression
    , but in the end it was decided that it would be for the best if just the type of the variable were
    to change. Claudio Freire reported the two problems. There is no change of functionality
    (except for low sampling frequencies) so the spectral demonstrations at the end of this commit’s message were not updated.

    Finally, the way energy values are converted to scalefactor indices has changed since the first commit,
    as per the suggestion of Claudio Freire. This may still have some drawbacks, but unlike the first commit
    it works without having redundant offsets and outputs what the decoder expects to have, in terms of the
    ranges of the scalefactor indices.

    Some spectral comparisons : https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/Original.png (original),
    https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/PNS_NO.png (encoded without PNS),
    https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/PNS1.2.png (encoded with PNS, const = 1.2),
    https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/Difference1.png (spectral difference).
    The constant is the value which multiplies the threshold when it gets compared to the energy, larger
    values means more noise will be substituded by PNS values. Example when const = 2.2 :
    https://trac.ffmpeg.org/attachment/wiki/Encode/AAC/PNS_2.2.png

    Reviewed-by : Claudio Freire <klaussfreire@gmail.com>
    Signed-off-by : Michael Niedermayer <michaelni@gmx.at>

    • [DH] libavcodec/aaccoder.c
    • [DH] libavcodec/aacenc.c
    • [DH] libavcodec/aacenc.h