Recherche avancée

Médias (1)

Mot : - Tags -/net art

Autres articles (61)

  • Gestion des droits de création et d’édition des objets

    8 février 2011, par

    Par défaut, beaucoup de fonctionnalités sont limitées aux administrateurs mais restent configurables indépendamment pour modifier leur statut minimal d’utilisation notamment : la rédaction de contenus sur le site modifiables dans la gestion des templates de formulaires ; l’ajout de notes aux articles ; l’ajout de légendes et d’annotations sur les images ;

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

Sur d’autres sites (10679)

  • ffmpeg is adding an extra new line into a box

    4 août 2017, par newbie123

    I’m overlaying weather data over my webcam stream. I put a background box filter, but the padding between the text and the box is uneven. There is "a new line" of extended box bellow the text.

    This is how it looks like

    Why is that ? There are no empty lines in a text file I’m providing to ffmpeg. Here is my code for the ffmpeg :

    ffmpeg \
    -f lavfi -i anullsrc \
    -rtsp_transport tcp \
    -i "$SOURCE" \
    -vcodec libx264 -pix_fmt yuv420p -preset ultrafast -g 20 -b:v 1000k \
    -vf "drawtext="fontfile=${FONT}":textfile=${textfile}:x=5:y=55:reload=1: \
    fontcolor=white:fontsize=${FONTSIZE}:box=1:boxborderw=5:boxcolor=black@0.5" \
    -threads $THREADS -bufsize 512k \
    -f flv "$YOUTUBE_URL/$KEY"

    EDIT :

    I found out what the problem was. I was using printf "%s\n" "$variable1" "$variable2" to create a text file. Printf %s\n automatically prints each variable into a new line. The solution was to print the last variable without the new line. Code example :

    #!/bin/sh
    LC_CTYPE=en_US.utf8

    # Get APRS weather data from aprs.fi

    wxstation="S55MA-10"
    name="Juršče, Pivka"


    # Basic weather data
    temp="$(wget -q https://aprs.fi/weather/a/${wxstation} -O - | grep Temperature | egrep '[-+]?([0-9]*\.[0-9]+|[0-9]+)' -o)"
    humidity="$(wget -q https://aprs.fi/weather/a/${wxstation} -O - | grep Humidity | egrep '[-+]?([0-9]*\.[0-9]+|[0-9]+)' -o)"
    wind="$(wget -q https://aprs.fi/weather/a/${wxstation} -O - | grep Wind | egrep '[-+]?([0-9]*\.[0-9]+|[0-9]+)' -o | sed -n -e 2p)"
    rain="$(wget -q https://aprs.fi/weather/a/${wxstation} -O - | grep Rain | egrep '[-+]?([0-9]*\.[0-9]+|[0-9]+)' -o | sed -n -e 1p)"

    # Telemetry
    radioactivity="$(wget -q https://aprs.fi/telemetry/a/${wxstation} -O - | grep Radioactivity | egrep '[-+]?([0-9]*\.[0-9]+|[0-9]+)' -o | sed -n -e 5p)"

    printf "%s\n" "$name" "Temperature: ${temp}\°C" "Humidity: ${humidity}\%" "Wind: ${wind} m/s" "Rain: ${rain} mm/h"
    printf "Radioactivity: ${radioactivity} uSv/h"
  • Screeching white sound coming while playing audio as a raw stream

    27 avril 2020, par Sri Nithya Sharabheshwarananda

    I. Background

    



      

    1. I am trying to make an application which helps to match subtitles to the audio waveform very accurately at the waveform level, at the word level or even at the character level.
    2. 


    3. The audio is expected to be Sanskrit chants (Yoga, rituals etc.) which are extremely long compound words [ example - aṅganyā-sokta-mātaro-bījam is traditionally one word broken only to assist reading ]
    4. 


    5. The input transcripts / subtitles might be roughly in sync at the sentence/verse level but surely would not be in sync at the word level.
    6. 


    7. The application should be able to figure out points of silence in the audio waveform, so that it can guess the start and end points of each word (or even letter/consonant/vowel in a word), such that the audio-chanting and visual-subtitle at the word level (or even at letter/consonant/vowel level) perfectly match, and the corresponding UI just highlights or animates the exact word (or even letter) in the subtitle line which is being chanted at that moment, and also show that word (or even the letter/consonant/vowel) in bigger font. This app's purpose is to assist learning Sanskrit chanting.
    8. 


    9. It is not expected to be a 100% automated process, nor 100% manual but a mix where the application should assist the human as much as possible.
    10. 


    



    II. Following is the first code I wrote for this purpose, wherein

    



      

    1. First I open a mp3 (or any audio format) file,
    2. 


    3. Seek to some arbitrary point in the timeline of the audio file // as of now playing from zero offset
    4. 


    5. Get the audio data in raw format for 2 purposes - (1) playing it and (2) drawing the waveform.
    6. 


    7. Playing the raw audio data using standard java audio libraries
    8. 


    



    III. The problem I am facing is, between every cycle there is screeching sound.

    



      

    • Probably I need to close the line between cycles ? Sounds simple, I can try.
    • 


    • But I am also wondering if this overall approach itself is correct ? Any tip, guide, suggestion, link would be really helpful.
    • 


    • Also I just hard coded the sample-rate etc ( 44100Hz etc. ), are these good to set as default presets or it should depend on the input format ?
    • 


    



    IV. Here is the code

    



    import com.github.kokorin.jaffree.StreamType;
import com.github.kokorin.jaffree.ffmpeg.FFmpeg;
import com.github.kokorin.jaffree.ffmpeg.FFmpegProgress;
import com.github.kokorin.jaffree.ffmpeg.FFmpegResult;
import com.github.kokorin.jaffree.ffmpeg.NullOutput;
import com.github.kokorin.jaffree.ffmpeg.PipeOutput;
import com.github.kokorin.jaffree.ffmpeg.ProgressListener;
import com.github.kokorin.jaffree.ffprobe.Stream;
import com.github.kokorin.jaffree.ffmpeg.UrlInput;
import com.github.kokorin.jaffree.ffprobe.FFprobe;
import com.github.kokorin.jaffree.ffprobe.FFprobeResult;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.SourceDataLine;


public class FFMpegToRaw {
    Path BIN = Paths.get("f:\\utilities\\ffmpeg-20190413-0ad0533-win64-static\\bin");
    String VIDEO_MP4 = "f:\\org\\TEMPLE\\DeviMahatmyamRecitationAudio\\03_01_Devi Kavacham.mp3";
    FFprobe ffprobe;
    FFmpeg ffmpeg;

    public void basicCheck() throws Exception {
        if (BIN != null) {
            ffprobe = FFprobe.atPath(BIN);
        } else {
            ffprobe = FFprobe.atPath();
        }
        FFprobeResult result = ffprobe
                .setShowStreams(true)
                .setInput(VIDEO_MP4)
                .execute();

        for (Stream stream : result.getStreams()) {
            System.out.println("Stream " + stream.getIndex()
                    + " type " + stream.getCodecType()
                    + " duration " + stream.getDuration(TimeUnit.SECONDS));
        }    
        if (BIN != null) {
            ffmpeg = FFmpeg.atPath(BIN);
        } else {
            ffmpeg = FFmpeg.atPath();
        }

        //Sometimes ffprobe can't show exact duration, use ffmpeg trancoding to NULL output to get it
        final AtomicLong durationMillis = new AtomicLong();
        FFmpegResult fFmpegResult = ffmpeg
                .addInput(
                        UrlInput.fromUrl(VIDEO_MP4)
                )
                .addOutput(new NullOutput())
                .setProgressListener(new ProgressListener() {
                    @Override
                    public void onProgress(FFmpegProgress progress) {
                        durationMillis.set(progress.getTimeMillis());
                    }
                })
                .execute();
        System.out.println("audio size - "+fFmpegResult.getAudioSize());
        System.out.println("Exact duration: " + durationMillis.get() + " milliseconds");
    }

    public void toRawAndPlay() throws Exception {
        ProgressListener listener = new ProgressListener() {
            @Override
            public void onProgress(FFmpegProgress progress) {
                System.out.println(progress.getFrame());
            }
        };

        // code derived from : https://stackoverflow.com/questions/32873596/play-raw-pcm-audio-received-in-udp-packets

        int sampleRate = 44100;//24000;//Hz
        int sampleSize = 16;//Bits
        int channels   = 1;
        boolean signed = true;
        boolean bigEnd = false;
        String format  = "s16be"; //"f32le"

        //https://trac.ffmpeg.org/wiki/audio types
        final AudioFormat af = new AudioFormat(sampleRate, sampleSize, channels, signed, bigEnd);
        final DataLine.Info info = new DataLine.Info(SourceDataLine.class, af);
        final SourceDataLine line = (SourceDataLine) AudioSystem.getLine(info);

        line.open(af, 4096); // format , buffer size
        line.start();

        OutputStream destination = new OutputStream() {
            @Override public void write(int b) throws IOException {
                throw new UnsupportedOperationException("Nobody uses thi.");
            }
            @Override public void write(byte[] b, int off, int len) throws IOException {
                String o = new String(b);
                boolean showString = false;
                System.out.println("New output ("+ len
                        + ", off="+off + ") -> "+(showString?o:"")); 
                // output wave form repeatedly

                if(len%2!=0) {
                    len -= 1;
                    System.out.println("");
                }
                line.write(b, off, len);
                System.out.println("done round");
            }
        };

        // src : http://blog.wudilabs.org/entry/c3d357ed/?lang=en-US
        FFmpegResult result = FFmpeg.atPath(BIN).
            addInput(UrlInput.fromPath(Paths.get(VIDEO_MP4))).
            addOutput(PipeOutput.pumpTo(destination).
                disableStream(StreamType.VIDEO). //.addArgument("-vn")
                setFrameRate(sampleRate).            //.addArguments("-ar", sampleRate)
                addArguments("-ac", "1").
                setFormat(format)              //.addArguments("-f", format)
            ).
            setProgressListener(listener).
            execute();

        // shut down audio
        line.drain();
        line.stop();
        line.close();

        System.out.println("result = "+result.toString());
    }

    public static void main(String[] args) throws Exception {
        FFMpegToRaw raw = new FFMpegToRaw();
        raw.basicCheck();
        raw.toRawAndPlay();
    }
}



    



    Thank You

    


  • how to override_ffserver parameters with a ffmpeg command line ?

    1er février 2017, par Bepeho

    I’m designing a simple camera switching system with ffmpeg and ffserver.
    I’m using ffmpeg to redirect one camera stream to a single ffserver.

    I’ve setup the ffserver to generate webm output :

    <feed>
       File /tmp/PREVIEW.ffm
       FileMaxSize 1M
    </feed>
    <stream>          
          Feed PREVIEW.ffm            
          Format webm
           AudioBitRate 64
           AudioSampleRate 24000
           AudioChannels 1
           VideoCodec libvpx
           VideoSize 640x380
           VideoFrameRate 25
           AVOptionVideo flags +global_header
           AVOptionAudio flags +global_header
           AVOptionVideo cpu-used 0
           AVOptionVideo qmin 10
           AVOptionVideo qmax 42
           AVOptionVideo quality good
           PreRoll 0
           StartSendOnKey
           VideoBitRate 1M
    </stream>

    It works well when i feed it with a ffmpeg commmand line such as :

    ffmpeg -re -rtbufsize 1500M  -thread_queue_size 512  -rtsp_transport tcp -i rtsp://admin:admin@192.168.0.10:554  -f lavfi -i anullsrc  http://localhost:8090/PREVIEW.ffm

    Now I want to insert dynamic text within the generated video stream, so I’ve added to the previous command line a drawtext directive :

    ffmpeg -re -rtbufsize 1500M -re -rtbufsize 1500M -thread_queue_size 512 -override_ffserver -rtsp_transport tcp -i rtsp://admin:admin@192.168.0.10:554 -f lavfi -i anullsrc -vf drawtext='fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:textfile=mytextfile.txt:reload=1:fontcolor=white:fontsize=48:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w):y=(h-text_h)' http://localhost:8090/PREVIEW.ffm

    But of course, it’s not working !

    I suppose that it’s because ffserver commands ffmpeg stream generation directives.

    So i’ve added a -override_ffserver parameter and audio+video generation parameters :

    ffmpeg -re -rtbufsize 1500M  -thread_queue_size 512  -rtsp_transport tcp -i rtsp://admin:admin@192.168.0.10:554  -f lavfi -i anullsrc -vf drawtext='fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:textfile=mytextfile.txt:reload=1:fontcolor=white:fontsize=48:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w):y=(h-text_h)' -vcodec libvpx -flags:v +global_header -b:v 1M -acodec libopus -ac 1 -ar 24000 -flags:a +global_header -s 320x190 -r 25 -override_ffserver http://localhost:8090/PREVIEW.ffm

    Still, the stream looks incorrect as ffplay logs lines such as :

    vp8 @ 0000000004e88220] Unknown profile 4
    vp8 @ 0000000004e88220] Header size larger than data

    Can anyone give me an hint on how to solve this problem ?

    Many Thanks.

    EDIT :
    I’ve found a workaround by piping the video+audio+text mix result to a second ffmpeg process.

    Hence, There’s no need to use the override_ffserver parameter anymore :

    ffmpeg -y -re -rtbufsize 1500M  -thread_queue_size 512 -rtsp_transport tcp -i rtsp://admin:admin@192.168.0.10:554  -f lavfi -i anullsrc  -vf drawtext='fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:textfile=mytextfile.txt:reload=1:fontcolor=white:fontsize=48:box=1:boxcolor=black@0.5:boxborderw=5:x=(w-text_w):y=(h-text_h)' -f nut pipe:1 | ffmpeg  -i pipe:0 http://localhost:8090/PREVIEW.ffm

    But, if anyone has a better, leaner and simpler solution, I’m for it.