Recherche avancée

Médias (0)

Mot : - Tags -/organisation

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

Autres articles (51)

  • Gestion générale des documents

    13 mai 2011, par

    MédiaSPIP ne modifie jamais le document original mis en ligne.
    Pour chaque document mis en ligne il effectue deux opérations successives : la création d’une version supplémentaire qui peut être facilement consultée en ligne tout en laissant l’original téléchargeable dans le cas où le document original ne peut être lu dans un navigateur Internet ; la récupération des métadonnées du document original pour illustrer textuellement le fichier ;
    Les tableaux ci-dessous expliquent ce que peut faire MédiaSPIP (...)

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

  • Récupération d’informations sur le site maître à l’installation d’une instance

    26 novembre 2010, par

    Utilité
    Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
    Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...)

Sur d’autres sites (8111)

  • Can ffmpeg transcode an audio track and add it as a second audio track at the same time, or if not, how to do it as separate commands ?

    31 mai 2020, par wb6vpm

    A bit of history. I am using Plex as my media server, but for reasons unknown, it has issues transcoding the DTS-HD MA 7.1 audio to EAC3 stereo and keeps buffering (the server has plenty of horsepower on all fronts, CPU/RAM/drive space & speed, gigabit networks connections for all devices. The playback device (TCL Roku TV, with a 3rd party soundbar connected via HDMI ARC) doesn't support the built-in 7.1 audio, so I get silence if I play it back directly by putting the file on a USB stick.

    



    Also, I am by no means a ffmpeg guru, I figured out what I do know by Google University and asking questions, so please be kind and forgive me if I ask follow-up questions that may seem n00b-ish, and please provide example commands (preferably in the context of my command below so that I can have a known point of reference to start with).

    



    I have a movie with 4K (HEVC Main 10 HDR) video and DTS-HD MA 7.1 audio that I am looking to leave the video and audio untouched, but to add a 2nd audio track in either EAC3 or if necessary, just AC3 in stereo

    



    So what I am looking for is as follows :

    



    video.mkv

    



      

    • Existing->4k video file (no change)
    • 


    • Existing->7.1 audio (no change)
    • 


    • Convert and add->stereo audio as a 2nd audio track to the output.mkv file
    • 


    



    Below is the command I've historically used with ffmpeg to convert and replace the audio file with the stereo audio, but since I'd prefer to leave the 7.1 audio in place, this doesn't work :
ffmpeg -i "D:\video.mkv" -c:v copy -c:a aac -b:a 128k "D:\output.mkv"

    



    And if this cannot be done as a single command, please also let me know what steps I do need to take to be able to do it.

    



    Thanks in advace,
Mike

    


  • how to send audio or video by packet though udp and sync the iamge and audio

    24 janvier 2019, par Wei Wen

    how to send part of video and audio from mp4 as packet though udp from server
    Client will play the part of packet resevice.

    import java.awt.Dimension ; import java.awt.image.BufferedImage ; import
    java.io.ByteArrayOutputStream ; import java.io.IOException ; import
    java.io.ObjectOutputStream ; import java.math.BigInteger ; import
    java.net.DatagramPacket ; import java.net.DatagramSocket ; import
    java.net.ServerSocket ; import java.net.Socket ; import
    java.nio.ByteBuffer ; import java.nio.ShortBuffer ; import
    java.util.ArrayList ; import java.util.Arrays ; import
    javax.imageio.ImageIO ; import javax.sound.sampled.AudioFileFormat ;
    import javax.sound.sampled.AudioFormat ; import javax.swing.JTextArea ;

    import org.bytedeco.javacv.FFmpegFrameGrabber ; import
    org.bytedeco.javacv.Frame ; import
    org.bytedeco.javacv.Java2DFrameConverter ;

    import Enum.EType.ClientState ; import View.SingleDisplayWindow ;

    import java.security.InvalidKeyException ; import
    java.security.NoSuchAlgorithmException ; import java.util.Timer ; import
    java.util.TimerTask ; import java.util.concurrent.CountDownLatch ;
    import java.util.concurrent.ExecutionException ;

    import javax.crypto.BadPaddingException ; import
    javax.crypto.IllegalBlockSizeException ; import
    javax.crypto.NoSuchPaddingException ; import
    org.bytedeco.javacv.FrameGrabber ;

    public class SCon private final static int PORT = 8888 ;

    private final JTextArea TEXT_AREA ; private volatile
    SingleDisplayWindow DISPLAY ; /////

    private final String BD_USER_NAME, DB_PASSWORD ; private Database
    database ;

    private boolean isRunning ;

    private RSA serverRSA, clientRSA ;

    private int keyIndex, typeID = 0 ; private String mediatype = "" ;
    private ArrayList sHandlers ;

    private FileStreamingThread fileStreamingThread ; private
    VideoStreamingThread videoStreamingThread ; private BroadcastThread
    broadcastThread ; private ConnectThread connectThread ;

    private volatile static byte[] currentVideoFrame = new byte[0],
    currentAudioFrame = new byte[0] ; // current image music

    public void run() startServer() ;

     isRunning = true;       fileStreamingThread = new

    FileStreamingThread(videoFile) ; videoStreamingThread = new
    VideoStreamingThread(videoFile) ;
    //CountDownLatch latch = new CountDownLatch(1) ; fileStreamingThread.start() ; videoStreamingThread.start() ;
    //latch.countDown() ;

             broadcastThread = new BroadcastThread();        broadcastThread.start();

     connectThread = new ConnectThread();        connectThread.start();  }

    public void stop() isRunning = false ;

     try {           new Socket("localhost", PORT);

     } catch (IOException e) {           e.printStackTrace();        }

     while (fileStreamingThread.isAlive()) {

     }

     while (broadcastThread.isAlive()) {

     }

     while (connectThread.isAlive()) {

     }

     for (SHandler sHandler : sHandlers) {           sHandler.connectionClose();
     }       sHandlers.clear();      DISPLAY.dispose();
     TEXT_AREA.append("\nServer stop\n");    }


     private class VideoStreamingThread extends Thread {         private

    FFmpegFrameGrabber grabber ; // Used to extract frames from video file.
    private Java2DFrameConverter converter ; // Used to convert frames to
    image private int curIndex ; // Current key index

     public VideoStreamingThread(String video_file) {            videoFile =

    videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ;
    converter = new Java2DFrameConverter() ; try
    grabber.restart() ;

         } catch (FrameGrabber.Exception e) {
             e.printStackTrace();            }           curIndex = keyIndex;        }

     public void run() {             try {

             while (isRunning) {
                 curIndex = keyIndex;
                 Frame frame = null;
                 System.out.println("v1");
                 if ((frame = grabber.grab()) != null) { // Grab next frame from video file
                     if (frame.image != null) { // image frame

                         BufferedImage bi = converter.convert(frame); // convert frame to image

                         // Convert BufferedImage to byte[]
                         ByteArrayOutputStream baos = new ByteArrayOutputStream();
                         ImageIO.write(bi, "jpg", baos);
                         // Encrypt data and store as the current image of byte[] type
                         currentVideoFrame = ciphers[curIndex].doFinal(baos.toByteArray());                                                                          
                         //////////////////
                         DISPLAY.setSize(new Dimension(bi.getWidth(), bi.getHeight()));
                         DISPLAY.updateImage(bi); // Display image
                     //  Thread.sleep((long) ( 999 / grabber.getFrameRate()));

                         ///////////////
                         typeID = 1;
                         mediatype = grabber.getFormat();

                     }
                 } else {
                     grabber.restart();
                 } // Restart when reached end of video
             }
             grabber.close();

         } catch (IOException e) {
             e.printStackTrace();

         } catch (IllegalBlockSizeException e) {
             e.printStackTrace();

         } catch (BadPaddingException e) {
             e.printStackTrace();

         }           //catch (InterruptedException e) {e.printStackTrace(); }        }

     public synchronized int getCurKeyIndex() {          return curIndex;        }

     public synchronized void getVideoFile(String video_file) {
         videoFile = video_file;             grabber = new

    FFmpegFrameGrabber(video_file) ; converter = new
    Java2DFrameConverter() ;

         try {
             grabber.release();
             grabber.restart();

         } catch (FrameGrabber.Exception e) {
             e.printStackTrace();            }       }   }       private class FileStreamingThread extends Thread {      private FFmpegFrameGrabber

    grabber ; // Used to extract frames from video file. private int
    curIndex ; // Current key index

     public FileStreamingThread(String video_file) {             videoFile =

    videoFile ; grabber = new FFmpegFrameGrabber(videoFile) ; try
    grabber.restart() ;

         } catch (FrameGrabber.Exception e) {
             e.printStackTrace();            }           curIndex = keyIndex;        }

     public void run() {             try {

             while (isRunning) {
                 curIndex = keyIndex;
                 Frame frame = null;

                 System.out.println("a2");
                 if ((frame = grabber.grabSamples()) != null) { // Grab next frame from video file
                     if (frame.samples != null) { // audio frame
                         // Encrypt audio

                         ShortBuffer channelSamplesShortBuffer = (ShortBuffer) frame.samples[0];
                         channelSamplesShortBuffer.rewind();

                         ByteBuffer outBuffer = ByteBuffer.allocate(channelSamplesShortBuffer.capacity() * 2);

                         for (int i = 0; i < channelSamplesShortBuffer.capacity(); i++) {
                             short val = channelSamplesShortBuffer.get(i);
                             outBuffer.putShort(val);
                         }

                         AudioFileFormat audiofileFormat = new AudioFileFormat(null, null, typeID);
                         AudioFormat audioFormat = new AudioFormat(44100, 16, 2, true, true);
                         //System.out.println(grabber.getSampleFormat());
                         // Encrypt data and store as the current audio of byte[] type
                         currentAudioFrame = ciphers[curIndex].doFinal(outBuffer.array());

                         DISPLAY.updateAudio(outBuffer.array(), grabber.getFormat()); // Display image audio
                     //  Thread.sleep((long) (1000 / grabber.getSampleRate()));

                          //                         AudioFormat audioFormat = new AudioFormat(grabber.getSampleRate(), grabber.getAudioBitrate(),

    grabber.getAudioChannels(), true, true) ;
    // DISPLAY.updateAudio(outBuffer.array(), audioFormat) ; //
    Display image audio
    outBuffer.clear() ;

                         typeID = 2;
                         mediatype = grabber.getFormat();

                     }      
                 } else {
                     grabber.restart();
                 } // Restart when reached end of video
             }
             grabber.close();

         } catch (IOException e) {
             e.printStackTrace();

         } catch (IllegalBlockSizeException e) {
             e.printStackTrace();

         } catch (BadPaddingException e) {
             e.printStackTrace();

         }       }

     public synchronized int getCurKeyIndex() {          return curIndex;        }

     public synchronized void getVideoFile(String video_file) {
         videoFile = video_file;             grabber = new

    FFmpegFrameGrabber(video_file) ;

         try {
             grabber.release();
             grabber.restart();

         } catch (FrameGrabber.Exception e) {
             e.printStackTrace();            }       }   }

    public void setVideoFile(String videoFile) this.videoFile =
    videoFile ;

    public void setThreadFile(String video_file)
    fileStreamingThread.getVideoFile(video_file) ;
    videoStreamingThread.getVideoFile(video_file) ;

    private class BroadcastThread extends Thread public void run()
    while (isRunning)
    Thread.yield() ;

             for (int i = 0; i < sHandlers.size(); i++) {
                 if (sHandlers.get(i).getClientState() == ClientState.R) {
                     sHandlers.get(i).setClientState(ClientState.W);
                     BroadcastWorker workerThread = new BroadcastWorker(sHandlers.get(i));
                     workerThread.start();
                 }
             }           }       }   }

    private class BroadcastWorker extends Thread SHandler sHandler =
    null ;

     public BroadcastWorker(SHandler sHandler) {             this.sHandler =

    sHandler ;

     public void run() {             try {
             DatagramSocket out = new DatagramSocket(); // used to send UDP packets

             while (sHandler.getClientState() == ClientState.W) {
                 Thread.yield();

                 StreamFile s = new StreamFile(typeID, currentVideoFrame, currentAudioFrame, mediatype);
                 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                 ObjectOutputStream os = new ObjectOutputStream(outputStream);
                 os.writeObject(s);
                 byte[] data = outputStream.toByteArray();
                     // Create and send UDP packet
                 DatagramPacket videoPacket = new DatagramPacket(data, data.length,
                         sHandler.getClientSocket().getInetAddress(),
                         Integer.parseInt(sHandler.getClientPort()));
                     out.send(videoPacket);

             }           } catch (IOException e) {
             e.printStackTrace();            }       }   }

    private class ConnectThread extends Thread public void run()
    TEXT_AREA.append("\nWaiting for clients’ connection.....\n") ;

         try {
             ServerSocket serverSocket = new ServerSocket(PORT);
             Socket clientSocket = null;

             while (isRunning) {
                 clientSocket = serverSocket.accept();

                 if (isRunning) {
                     SHandler sHandler = new SHandler(clientSocket, serverRSA, clientRSA, sessionKeys[keyIndex],
                             TEXT_AREA);
                     sHandler.start();
                     sHandlers.add(sHandler);
                 }
             }
             serverSocket.close();
             if (clientSocket != null) {
                 clientSocket.close();
             }

         } catch (IOException e) {
             e.printStackTrace();            }       }   } }

    my audio and image not sync.

  • FFmpeg - Add Audio to Video - Audio cuts out

    13 mars 2021, par John Doe

    I have a problem with my Batch-file FFmpeg command. I wish to concat 3 videos into one, and add background music starting after 10 seconds.

    


    The video renders properly, however the music cuts out 10 seconds into the second concat video and the rest of the video is silent.

    


    (echo file 'loading.mp4' & echo file 'slide.mp4' & echo file 'outro.mp4') | ffmpeg -y -init_hw_device qsv=hw -filter_hw_device hw -hide_banner -protocol_whitelist file,pipe -f concat -safe 0 -i pipe: -stream_loop -1 -i "music.mp3" -filter_complex "[1:a]adelay=10000|10000,afade=t=in:st=11:d=10,volume=0.2[a1];[0:a][a1]amix=duration=first[audio]" -map "0:v" -map "[audio]" -c:v h264_qsv -c:a aac -vb 10M -preset veryfast -r 30 "done.mp4"


    


    Any ideas ?