Recherche avancée

Médias (1)

Mot : - Tags -/Rennes

Autres articles (44)

  • Les formats acceptés

    28 janvier 2010, par

    Les commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
    ffmpeg -codecs ffmpeg -formats
    Les format videos acceptés en entrée
    Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
    Les formats vidéos de sortie possibles
    Dans un premier temps on (...)

  • Submit bugs and patches

    13 avril 2011

    Unfortunately a software is never perfect.
    If you think you have found a bug, report it using our ticket system. Please to help us to fix it by providing the following information : the browser you are using, including the exact version as precise an explanation as possible of the problem if possible, the steps taken resulting in the problem a link to the site / page in question
    If you think you have solved the bug, fill in a ticket and attach to it a corrective patch.
    You may also (...)

  • 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

Sur d’autres sites (6567)

  • ffmpeg unbale to initialize threading in some cases

    16 octobre 2020, par Sudipta Roy

    I am posting this again since the earlier question I posted has been closed

    


    I have a JAVA service running in wildfly which is calling an external ffmpeg binary to convert .au files to .wav files. The actual command that is being executed is as follows :

    


    ffmpeg -y -i INPUT.au OUTPUT.wav


    


    It is running smoothly, except every once in a while it is creating an empty .wav file becasue of the following error :

    


    Error: ffmpeg version c6710aa Copyright (c) 2000-2017 the FFmpeg 
developers
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609
configuration: --prefix=/tmp/ffmpeg-static/target --pkg-config-flags=- 
-static --extra-cflags=-I/tmp/ffmpeg-static/target/include --extra- 
ldflags=-L/tmp/ffmpeg-static/target/lib --extra-ldexeflags=-static -- 
bindir=/tmp/ffmpeg-static/bin --enable-pic --enable-ffplay --enable- 
ffserver --enable-fontconfig --enable-frei0r --enable-gpl --enable- 
version3 --enable-libass --enable-libfribidi --enable-libfdk-aac -- 
enable-libfreetype --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 --enable-nonfree --enable-openssl
libavutil      55. 34.101 / 55. 34.101
libavcodec     57. 64.101 / 57. 64.101
libavformat    57. 56.101 / 57. 56.101
libavdevice    57.  1.100 / 57.  1.100
libavfilter     6. 65.100 /  6. 65.100
libswscale      4.  2.100 /  4.  2.100
libswresample   2.  3.100 /  2.  3.100
libpostproc    54.  1.100 / 54.  1.100

Input #0, ogg, from 'INPUT.au'
Duration: 00:00:34.08, start: 0.01500, bitrate: 15kb/s
Stream: #0.0: Audio: speex, 8000Hz, mono, s16, 15kb/s

[AVFilterGraph @ 0x43ec6e0] Error initializing threading.
[AVFilterGraph @ 0x43ec6e0] Error creating filter 'anull'


    


    If I try to manually convert the file from command line, it works. A brief internet search (this) shows that it might be due to the fact that ffmpeg is unable to create threads for internal use. Can anyone please elaborate ?

    


    The server where I am facing the problem have relatively high load. I have seen that wildfly is creating close to 1800 threads.

    


    Thanks

    


    P.s. I have managed to recreate the problem. Below is the code :

    


    SystemCommandExecutor.java

    


        import java.io.*;&#xA;    import java.util.List;&#xA;    public class SystemCommandExecutor {&#xA;        private List<string> commandInformation;&#xA;        private String adminPassword;&#xA;        private ThreadedStreamHandler inputStreamHandler;&#xA;        private ThreadedStreamHandler errorStreamHandler;&#xA;&#xA;        public SystemCommandExecutor(final List<string> commandInformation)&#xA;        {&#xA;        if (commandInformation==null) throw new NullPointerException("The commandInformation is required.");&#xA;        this.commandInformation = commandInformation;&#xA;        this.adminPassword = null;&#xA;        }&#xA;&#xA;    public int executeCommand()&#xA;            throws IOException, InterruptedException&#xA;    {&#xA;        int exitValue = -99;&#xA;&#xA;        try&#xA;        {&#xA;            ProcessBuilder pb = new ProcessBuilder(commandInformation);&#xA;            Process process = pb.start();&#xA;            OutputStream stdOutput = process.getOutputStream();&#xA;            InputStream inputStream = process.getInputStream();&#xA;            InputStream errorStream = process.getErrorStream();&#xA;            inputStreamHandler = new ThreadedStreamHandler(inputStream, stdOutput, adminPassword);&#xA;            errorStreamHandler = new ThreadedStreamHandler(errorStream);&#xA;            inputStreamHandler.start();&#xA;            errorStreamHandler.start();&#xA;            exitValue = process.waitFor();&#xA;            inputStreamHandler.interrupt();&#xA;            errorStreamHandler.interrupt();&#xA;            inputStreamHandler.join();&#xA;            errorStreamHandler.join();&#xA;        }&#xA;        catch (IOException e)&#xA;        {&#xA;            throw e;&#xA;        }&#xA;        catch (InterruptedException e)&#xA;        {&#xA;            throw e;&#xA;        }&#xA;        finally&#xA;        {&#xA;            return exitValue;&#xA;        }&#xA;    }&#xA;&#xA;    public StringBuilder getStandardOutputFromCommand()&#xA;    {&#xA;        return inputStreamHandler.getOutputBuffer();&#xA;    }&#xA;&#xA;    public StringBuilder getStandardErrorFromCommand()&#xA;    {&#xA;        return errorStreamHandler.getOutputBuffer();&#xA;    }&#xA;}&#xA;</string></string>

    &#xA;

    ThreadedStreamHandler.java

    &#xA;

    import java.io.*;&#xA;&#xA;class ThreadedStreamHandler extends Thread&#xA;{&#xA;    InputStream inputStream;&#xA;    String adminPassword;&#xA;    OutputStream outputStream;&#xA;    PrintWriter printWriter;&#xA;    StringBuilder outputBuffer = new StringBuilder();&#xA;    private boolean sudoIsRequested = false;&#xA;&#xA;    &#xA;    ThreadedStreamHandler(InputStream inputStream)&#xA;    {&#xA;        this.inputStream = inputStream;&#xA;    }&#xA;&#xA;    &#xA;    ThreadedStreamHandler(InputStream inputStream, OutputStream outputStream, String adminPassword)&#xA;    {&#xA;        this.inputStream = inputStream;&#xA;        this.outputStream = outputStream;&#xA;        this.printWriter = new PrintWriter(outputStream);&#xA;        this.adminPassword = adminPassword;&#xA;        this.sudoIsRequested = true;&#xA;    }&#xA;&#xA;    public void run()&#xA;    {&#xA;        &#xA;        if (sudoIsRequested)&#xA;        {&#xA;            printWriter.println(adminPassword);&#xA;            printWriter.flush();&#xA;        }&#xA;&#xA;        BufferedReader bufferedReader = null;&#xA;        try&#xA;        {&#xA;            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));&#xA;            String line = null;&#xA;            while ((line = bufferedReader.readLine()) != null)&#xA;            {&#xA;                outputBuffer.append(line &#x2B; "\n");&#xA;            }&#xA;        }&#xA;        catch (IOException ioe)&#xA;        {&#xA;            ioe.printStackTrace();&#xA;        }&#xA;        catch (Throwable t)&#xA;        {&#xA;            t.printStackTrace();&#xA;        }&#xA;        finally&#xA;        {&#xA;            try&#xA;            {&#xA;                bufferedReader.close();&#xA;            }&#xA;            catch (IOException e)&#xA;            {&#xA;                // ignore this one&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    private void doSleep(long millis)&#xA;    {&#xA;        try&#xA;        {&#xA;            Thread.sleep(millis);&#xA;        }&#xA;        catch (InterruptedException e)&#xA;        {&#xA;            // ignore&#xA;        }&#xA;    }&#xA;&#xA;    public StringBuilder getOutputBuffer()&#xA;    {&#xA;        return outputBuffer;&#xA;    }&#xA;&#xA;}&#xA;

    &#xA;

    FfmpegRunnable.java

    &#xA;

    import java.io.IOException;&#xA;import java.util.List;&#xA;&#xA;public class FfmpegRunnable implements Runnable {&#xA;    private List<string> command;&#xA;    SystemCommandExecutor executor;&#xA;&#xA;    public FfmpegRunnable(List<string> command) {&#xA;        this.command = command;&#xA;        this.executor = new SystemCommandExecutor(command);&#xA;    }&#xA;&#xA;    @Override&#xA;    public void run() {&#xA;        try {&#xA;            int id = (int) Thread.currentThread().getId();&#xA;            int result = executor.executeCommand();&#xA;            if(result != 0) {&#xA;                StringBuilder err = executor.getStandardErrorFromCommand();&#xA;                System.out.println("[" &#x2B; id &#x2B; "]" &#x2B; "[ERROR] " &#x2B; err);&#xA;            } else {&#xA;                System.out.println("[" &#x2B; id &#x2B; "]" &#x2B; "[SUCCESS]");&#xA;            }&#xA;        } catch (IOException e) {&#xA;            e.printStackTrace();&#xA;        } catch (InterruptedException e) {&#xA;            e.printStackTrace();&#xA;        }&#xA;    }&#xA;}&#xA;</string></string>

    &#xA;

    FfmpegMain.java

    &#xA;

    import java.util.ArrayList;&#xA;import java.util.List;&#xA;import java.util.concurrent.Executor;&#xA;import java.util.concurrent.Executors;&#xA;import java.util.concurrent.ThreadPoolExecutor;&#xA;public class FfmpegMain {&#xA;    public static void main(String[] args) {&#xA;        //boolean threading = false;&#xA;        System.out.println(args[0]);&#xA;        int nrThread = Integer.parseInt(args[0]);&#xA;        boolean threading = Boolean.parseBoolean(args[1]);&#xA;        System.out.println("nrThread : " &#x2B; nrThread &#x2B; ", threading : " &#x2B; threading);&#xA;        if(threading) {&#xA;            System.out.println("ffmpeg threading enabled");&#xA;        } else {&#xA;            System.out.println("ffmpeg threading not enabled");&#xA;        }&#xA;        ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nrThread);&#xA;        for(int i=0; i cmd = new ArrayList<string>();&#xA;            String dest = "/tmp/OUTPUT/output_" &#x2B; (Math.random()*1000) &#x2B; ".wav";&#xA;            String cmdStr = "/tmp/FFMPEG/ffmpeg" &#x2B; (threading ? " -threads 1 " : " ")&#xA;                    &#x2B; "-y -i /tmp/input.au " &#x2B; dest;&#xA;            cmd.add("/bin/sh");&#xA;            cmd.add("-c");&#xA;            cmd.add(cmdStr);&#xA;&#xA;            executor.submit(new FfmpegRunnable(cmd));&#xA;        }&#xA;        executor.shutdown();&#xA;    }&#xA;}&#xA;</string>

    &#xA;

    I have created a jar with the class files and run the jar from two seperate terminal with the following command

    &#xA;

    java -jar JAR.jar 40 true&#xA;

    &#xA;

    Here 40 is the number of threads, simulating varous users accessing the system. Every once in a while I get above mentioned error.

    &#xA;

  • ffmpeg unbale to initialize threading [closed]

    16 octobre 2020, par Sudipta Roy

    I have a JAVA service running in wildfly which is calling an external ffmpeg binary to convert .au files to .wav files. The actual command that is being executed is as follows :

    &#xA;

    ffmpeg -y -i INPUT.au OUTPUT.wav&#xA;

    &#xA;

    It is running smoothly, except every once in a while it is creating an empty .wav file becasue of the following error :

    &#xA;

    Error: ffmpeg version c6710aa Copyright (c) 2000-2017 the FFmpeg &#xA;developers&#xA;built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 20160609&#xA;configuration: --prefix=/tmp/ffmpeg-static/target --pkg-config-flags=- &#xA;-static --extra-cflags=-I/tmp/ffmpeg-static/target/include --extra- &#xA;ldflags=-L/tmp/ffmpeg-static/target/lib --extra-ldexeflags=-static -- &#xA;bindir=/tmp/ffmpeg-static/bin --enable-pic --enable-ffplay --enable- &#xA;ffserver --enable-fontconfig --enable-frei0r --enable-gpl --enable- &#xA;version3 --enable-libass --enable-libfribidi --enable-libfdk-aac -- &#xA;enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb -- &#xA;enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus -- &#xA;enable-librtmp --enable-libsoxr --enable-libspeex --enable-libtheora - &#xA;-enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis -- &#xA;enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 -- &#xA;enable-libxvid --enable-libzimg --enable-nonfree --enable-openssl&#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;&#xA;Input #0, ogg, from &#x27;INPUT.au&#x27;&#xA;Duration: 00:00:34.08, start: 0.01500, bitrate: 15kb/s&#xA;Stream: #0.0: Audio: speex, 8000Hz, mono, s16, 15kb/s&#xA;&#xA;[AVFilterGraph @ 0x43ec6e0] Error initializing threading.&#xA;[AVFilterGraph @ 0x43ec6e0] Error creating filter &#x27;anull&#x27;&#xA;

    &#xA;

    If I try to manually convert the file from command line, it works. A brief internet search (this) shows that it might be due to the fact that ffmpeg is unable to create threads for internal use. Can anyone please elaborate ?

    &#xA;

    The server where I am facing the problem have relatively high load. I have seen that wildfly is creating close to 1800 threads.

    &#xA;

    Thanks

    &#xA;

    P.s. I have managed to recreate the problem. Below is the code :

    &#xA;

    SystemCommandExecutor.java

    &#xA;

        import java.io.*;&#xA;    import java.util.List;&#xA;    public class SystemCommandExecutor {&#xA;        private List<string> commandInformation;&#xA;        private String adminPassword;&#xA;        private ThreadedStreamHandler inputStreamHandler;&#xA;        private ThreadedStreamHandler errorStreamHandler;&#xA;&#xA;        public SystemCommandExecutor(final List<string> commandInformation)&#xA;        {&#xA;        if (commandInformation==null) throw new NullPointerException("The commandInformation is required.");&#xA;        this.commandInformation = commandInformation;&#xA;        this.adminPassword = null;&#xA;        }&#xA;&#xA;    public int executeCommand()&#xA;            throws IOException, InterruptedException&#xA;    {&#xA;        int exitValue = -99;&#xA;&#xA;        try&#xA;        {&#xA;            ProcessBuilder pb = new ProcessBuilder(commandInformation);&#xA;            Process process = pb.start();&#xA;            OutputStream stdOutput = process.getOutputStream();&#xA;            InputStream inputStream = process.getInputStream();&#xA;            InputStream errorStream = process.getErrorStream();&#xA;            inputStreamHandler = new ThreadedStreamHandler(inputStream, stdOutput, adminPassword);&#xA;            errorStreamHandler = new ThreadedStreamHandler(errorStream);&#xA;            inputStreamHandler.start();&#xA;            errorStreamHandler.start();&#xA;            exitValue = process.waitFor();&#xA;            inputStreamHandler.interrupt();&#xA;            errorStreamHandler.interrupt();&#xA;            inputStreamHandler.join();&#xA;            errorStreamHandler.join();&#xA;        }&#xA;        catch (IOException e)&#xA;        {&#xA;            throw e;&#xA;        }&#xA;        catch (InterruptedException e)&#xA;        {&#xA;            throw e;&#xA;        }&#xA;        finally&#xA;        {&#xA;            return exitValue;&#xA;        }&#xA;    }&#xA;&#xA;    public StringBuilder getStandardOutputFromCommand()&#xA;    {&#xA;        return inputStreamHandler.getOutputBuffer();&#xA;    }&#xA;&#xA;    public StringBuilder getStandardErrorFromCommand()&#xA;    {&#xA;        return errorStreamHandler.getOutputBuffer();&#xA;    }&#xA;}&#xA;</string></string>

    &#xA;

    ThreadedStreamHandler.java

    &#xA;

    import java.io.*;&#xA;&#xA;class ThreadedStreamHandler extends Thread&#xA;{&#xA;    InputStream inputStream;&#xA;    String adminPassword;&#xA;    OutputStream outputStream;&#xA;    PrintWriter printWriter;&#xA;    StringBuilder outputBuffer = new StringBuilder();&#xA;    private boolean sudoIsRequested = false;&#xA;&#xA;    &#xA;    ThreadedStreamHandler(InputStream inputStream)&#xA;    {&#xA;        this.inputStream = inputStream;&#xA;    }&#xA;&#xA;    &#xA;    ThreadedStreamHandler(InputStream inputStream, OutputStream outputStream, String adminPassword)&#xA;    {&#xA;        this.inputStream = inputStream;&#xA;        this.outputStream = outputStream;&#xA;        this.printWriter = new PrintWriter(outputStream);&#xA;        this.adminPassword = adminPassword;&#xA;        this.sudoIsRequested = true;&#xA;    }&#xA;&#xA;    public void run()&#xA;    {&#xA;        &#xA;        if (sudoIsRequested)&#xA;        {&#xA;            printWriter.println(adminPassword);&#xA;            printWriter.flush();&#xA;        }&#xA;&#xA;        BufferedReader bufferedReader = null;&#xA;        try&#xA;        {&#xA;            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));&#xA;            String line = null;&#xA;            while ((line = bufferedReader.readLine()) != null)&#xA;            {&#xA;                outputBuffer.append(line &#x2B; "\n");&#xA;            }&#xA;        }&#xA;        catch (IOException ioe)&#xA;        {&#xA;            ioe.printStackTrace();&#xA;        }&#xA;        catch (Throwable t)&#xA;        {&#xA;            t.printStackTrace();&#xA;        }&#xA;        finally&#xA;        {&#xA;            try&#xA;            {&#xA;                bufferedReader.close();&#xA;            }&#xA;            catch (IOException e)&#xA;            {&#xA;                // ignore this one&#xA;            }&#xA;        }&#xA;    }&#xA;&#xA;    private void doSleep(long millis)&#xA;    {&#xA;        try&#xA;        {&#xA;            Thread.sleep(millis);&#xA;        }&#xA;        catch (InterruptedException e)&#xA;        {&#xA;            // ignore&#xA;        }&#xA;    }&#xA;&#xA;    public StringBuilder getOutputBuffer()&#xA;    {&#xA;        return outputBuffer;&#xA;    }&#xA;&#xA;}&#xA;

    &#xA;

    FfmpegRunnable.java

    &#xA;

    import java.io.IOException;&#xA;import java.util.List;&#xA;&#xA;public class FfmpegRunnable implements Runnable {&#xA;    private List<string> command;&#xA;    SystemCommandExecutor executor;&#xA;&#xA;    public FfmpegRunnable(List<string> command) {&#xA;        this.command = command;&#xA;        this.executor = new SystemCommandExecutor(command);&#xA;    }&#xA;&#xA;    @Override&#xA;    public void run() {&#xA;        try {&#xA;            int id = (int) Thread.currentThread().getId();&#xA;            int result = executor.executeCommand();&#xA;            if(result != 0) {&#xA;                StringBuilder err = executor.getStandardErrorFromCommand();&#xA;                System.out.println("[" &#x2B; id &#x2B; "]" &#x2B; "[ERROR] " &#x2B; err);&#xA;            } else {&#xA;                System.out.println("[" &#x2B; id &#x2B; "]" &#x2B; "[SUCCESS]");&#xA;            }&#xA;        } catch (IOException e) {&#xA;            e.printStackTrace();&#xA;        } catch (InterruptedException e) {&#xA;            e.printStackTrace();&#xA;        }&#xA;    }&#xA;}&#xA;</string></string>

    &#xA;

    FfmpegMain.java

    &#xA;

    import java.util.ArrayList;&#xA;import java.util.List;&#xA;import java.util.concurrent.Executor;&#xA;import java.util.concurrent.Executors;&#xA;import java.util.concurrent.ThreadPoolExecutor;&#xA;public class FfmpegMain {&#xA;    public static void main(String[] args) {&#xA;        //boolean threading = false;&#xA;        System.out.println(args[0]);&#xA;        int nrThread = Integer.parseInt(args[0]);&#xA;        boolean threading = Boolean.parseBoolean(args[1]);&#xA;        System.out.println("nrThread : " &#x2B; nrThread &#x2B; ", threading : " &#x2B; threading);&#xA;        if(threading) {&#xA;            System.out.println("ffmpeg threading enabled");&#xA;        } else {&#xA;            System.out.println("ffmpeg threading not enabled");&#xA;        }&#xA;        ThreadPoolExecutor executor = (ThreadPoolExecutor) Executors.newFixedThreadPool(nrThread);&#xA;        for(int i=0; i cmd = new ArrayList<string>();&#xA;            String dest = "/tmp/OUTPUT/output_" &#x2B; (Math.random()*1000) &#x2B; ".wav";&#xA;            String cmdStr = "/tmp/FFMPEG/ffmpeg" &#x2B; (threading ? " -threads 1 " : " ")&#xA;                    &#x2B; "-y -i /tmp/input.au " &#x2B; dest;&#xA;            cmd.add("/bin/sh");&#xA;            cmd.add("-c");&#xA;            cmd.add(cmdStr);&#xA;&#xA;            executor.submit(new FfmpegRunnable(cmd));&#xA;        }&#xA;        executor.shutdown();&#xA;    }&#xA;}&#xA;</string>

    &#xA;

    I have created a jar with the class files and run the jar from two seperate terminal with the following command

    &#xA;

    java -jar JAR.jar 40 true&#xA;

    &#xA;

    Here 40 is the number of threads, simulating varous users accessing the system. Every once in a while I get above mentioned error.

    &#xA;

  • FFMPEG RTSP stream to MPEG4/H264 file using libx264

    16 octobre 2020, par Phi

    Heyo folks,

    &#xA;&#xA;

    I'm attempting to transcode/remux an RTSP stream in H264 format into a MPEG4 container, containing just the H264 video stream. Basically, webcam output into a MP4 container.

    &#xA;&#xA;

    I can get a poorly coded MP4 produced, using this code :

    &#xA;&#xA;

    // Variables here for demo&#xA;AVFormatContext * video_file_output_format = nullptr;&#xA;AVFormatContext * rtsp_format_context = nullptr;&#xA;AVCodecContext * video_file_codec_context = nullptr;&#xA;AVCodecContext * rtsp_vidstream_codec_context = nullptr;&#xA;AVPacket packet = {0};&#xA;AVStream * video_file_stream = nullptr;&#xA;AVCodec * rtsp_decoder_codec = nullptr;&#xA;int errorNum = 0, video_stream_index = 0;&#xA;std::string outputMP4file = "D:\\somemp4file.mp4";&#xA;&#xA;// begin&#xA;AVDictionary * opts = nullptr;&#xA;av_dict_set(&amp;opts, "rtsp_transport", "tcp", 0);&#xA;&#xA;if ((errorNum = avformat_open_input(&amp;rtsp_format_context, uriANSI.c_str(), NULL, &amp;opts)) &lt; 0) {&#xA;    errOut &lt;&lt; "Connection failed: avformat_open_input failed with error " &lt;&lt; errorNum &lt;&lt; ":\r\n" &lt;&lt; ErrorRead(errorNum);&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;rtsp_format_context->max_analyze_duration = 50000;&#xA;if ((errorNum = avformat_find_stream_info(rtsp_format_context, NULL)) &lt; 0) {&#xA;    errOut &lt;&lt; "Connection failed: avformat_find_stream_info failed with error " &lt;&lt; errorNum &lt;&lt; ":\r\n" &lt;&lt; ErrorRead(errorNum);&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;video_stream_index = errorNum = av_find_best_stream(rtsp_format_context, AVMEDIA_TYPE_VIDEO, -1, -1, NULL, 0);&#xA;&#xA;if (video_stream_index &lt; 0) {&#xA;    errOut &lt;&lt; "Connection in unexpected state; made a connection, but there was no video stream.\r\n"&#xA;        "Attempts to find a video stream resulted in error " &lt;&lt; errorNum &lt;&lt; ": " &lt;&lt; ErrorRead(errorNum);&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;rtsp_vidstream_codec_context = rtsp_format_context->streams[video_stream_index]->codec;&#xA;&#xA;av_init_packet(&amp;packet);&#xA;&#xA;if (!(video_file_output_format = av_guess_format(NULL, outputMP4file.c_str(),  NULL))) {&#xA;    TacticalAbort();&#xA;    throw std::exception("av_guess_format");&#xA;}&#xA;&#xA;if (!(rtsp_decoder_codec = avcodec_find_decoder(rtsp_vidstream_codec_context->codec_id))) {&#xA;    errOut &lt;&lt; "Connection failed: connected, but avcodec_find_decoder returned null.\r\n"&#xA;        "Couldn&#x27;t find codec with an AV_CODEC_ID value of " &lt;&lt; rtsp_vidstream_codec_context->codec_id &lt;&lt; ".";&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;video_file_format_context = avformat_alloc_context();&#xA;video_file_format_context->oformat = video_file_output_format;&#xA;&#xA;if (strcpy_s(video_file_format_context->filename, sizeof(video_file_format_context->filename), outputMP4file.c_str())) {&#xA;    errOut &lt;&lt; "Couldn&#x27;t open video file: strcpy_s failed with error " &lt;&lt; errno &lt;&lt; ".";&#xA;    std::string log = errOut.str();&#xA;    TacticalAbort();&#xA;    throw std::exception("strcpy_s");&#xA;}&#xA;&#xA;if (!(video_file_encoder_codec = avcodec_find_encoder(video_file_output_format->video_codec))) {&#xA;    TacticalAbort();&#xA;    throw std::exception("avcodec_find_encoder");&#xA;}&#xA;&#xA;// MARKER ONE&#xA;&#xA;if (!outputMP4file.empty() &amp;&amp;&#xA;    !(video_file_output_format->flags &amp; AVFMT_NOFILE) &amp;&amp;&#xA;    (errorNum = avio_open2(&amp;video_file_format_context->pb, outputMP4file.c_str(), AVIO_FLAG_WRITE, nullptr, &amp;opts)) &lt; 0) {&#xA;    errOut &lt;&lt; "Couldn&#x27;t open video file \"" &lt;&lt; outputMP4file &lt;&lt; "\" for writing : avio_open2 failed with error " &lt;&lt; errorNum &lt;&lt; ": " &lt;&lt; ErrorRead(errorNum);&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;// Create stream in MP4 file&#xA;if (!(video_file_stream = avformat_new_stream(video_file_format_context, video_file_encoder_codec))) {&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;&#xA;AVCodecContext * video_file_codec_context = video_file_stream->codec;&#xA;&#xA;// MARKER TWO&#xA;&#xA;// error -22/-21 in avio_open2 if this is skipped&#xA;if ((errorNum = avcodec_copy_context(video_file_codec_context, rtsp_vidstream_codec_context)) != 0) {&#xA;    TacticalAbort();&#xA;    throw std::exception("avcodec_copy_context");&#xA;}&#xA;&#xA;//video_file_codec_context->codec_tag = 0;&#xA;&#xA;/*&#xA;// MARKER 3 - is this not needed? Examples suggest not.&#xA;if ((errorNum = avcodec_open2(video_file_codec_context, video_file_encoder_codec, &amp;opts)) &lt; 0)&#xA;{&#xA;    errOut &lt;&lt; "Couldn&#x27;t open video file codec context: avcodec_open2 failed with error " &lt;&lt; errorNum &lt;&lt; ": " &lt;&lt; ErrorRead(errorNum);&#xA;    std::string log = errOut.str();&#xA;    TacticalAbort();&#xA;    throw std::exception("avcodec_open2, video file");&#xA;}*/&#xA;&#xA;//video_file_format_context->flags |= AVFMT_FLAG_GENPTS;&#xA;if (video_file_format_context->oformat->flags &amp; AVFMT_GLOBALHEADER)&#xA;{&#xA;    video_file_codec_context->flags |= CODEC_FLAG_GLOBAL_HEADER;&#xA;}&#xA;&#xA;if ((errorNum = avformat_write_header(video_file_format_context, &amp;opts)) &lt; 0) {&#xA;    errOut &lt;&lt; "Couldn&#x27;t open video file: avformat_write_header failed with error " &lt;&lt; errorNum &lt;&lt; ":\r\n" &lt;&lt; ErrorRead(errorNum);&#xA;    std::string log = errOut.str();&#xA;    TacticalAbort();&#xA;    return;&#xA;}&#xA;

    &#xA;&#xA;

    However, there are several issues :

    &#xA;&#xA;

      &#xA;
    1. I can't pass any x264 options to the output file. The output H264 matches the input H264's profile/level - switching cameras to a different model switches H264 level.
    2. &#xA;

    3. The timing of the output file is off, noticeably.
    4. &#xA;

    5. The duration of the output file is off, massively. A few seconds of footage becomes hours, although playtime doesn't match. (FWIW, I'm using VLC to play them.)
    6. &#xA;

    &#xA;&#xA;

    Passing x264 options

    &#xA;&#xA;

    If I manually increment PTS per packet, and set DTS equal to PTS, it plays too fast, 2-3 seconds' worth of footage in one second playtime, and duration is hours long. The footage also blurs past several seconds, about 10 seconds' footage in a second.

    &#xA;&#xA;

    If I let FFMPEG decide (with or without GENPTS flag), the file has a variable frame rate (probably as expected), but it plays the whole file in an instant and has a long duration too (over forty hours for a few seconds). The duration isn't "real", as the file plays in an instant.

    &#xA;&#xA;

    At Marker One, I try to set the profile by passing options to avio_open2. The options are simply ignored by libx264. I've tried :

    &#xA;&#xA;

    av_dict_set(&amp;opts, "vprofile", "main", 0);&#xA;av_dict_set(&amp;opts, "profile", "main", 0); // error, missing &#x27;(&#x27;&#xA;// FF_PROFILE_H264_MAIN equals 77, so I also tried&#xA;av_dict_set(&amp;opts, "vprofile", "77", 0); &#xA;av_dict_set(&amp;opts, "profile", "77", 0);&#xA;

    &#xA;&#xA;

    It does seem to read the profile setting, but it doesn't use them. At Marker Two, I tried to set it after the avio_open2, before avformat_write_header .

    &#xA;&#xA;

    // I tried all 4 av_dict_set from earlier, passing it to avformat_write_header.&#xA;// None had any effect, they weren&#x27;t consumed.&#xA;av_opt_set(video_file_codec_context, "profile", "77", 0);&#xA;av_opt_set(video_file_codec_context, "profile", "main", 0);&#xA;video_file_codec_context->profile = FF_PROFILE_H264_MAIN;&#xA;av_opt_set(video_file_codec_context->priv_data, "profile", "77", 0);&#xA;av_opt_set(video_file_codec_context->priv_data, "profile", "main", 0);&#xA;

    &#xA;&#xA;

    Messing with privdata made the program unstable, but I was trying anything at that point.&#xA;I'd like to solve issue 1 with passing settings, since I imagine it'd bottleneck any attempt to solve issues 2 or 3.

    &#xA;&#xA;

    I've been fiddling with this for the better part of a month now. I've been through dozens of documentation, Q&As, examples. It doesn't help that quite a few are outdated.

    &#xA;&#xA;

    Any help would be appreciated.

    &#xA;&#xA;

    Cheers

    &#xA;