Newest 'ffmpeg' Questions - Stack Overflow

http://stackoverflow.com/questions/tagged/ffmpeg

Les articles publiés sur le site

  • FFmpeg : How to get AVCodecID from AVFrame ?

    17 novembre 2014, par philip

    How to get AVCodecID from AVFrame?

    I'm decoding a audio stream with AAC codec type using FFMpeg , But the AAC has AAC-ADTS & AAC-LATM encapsulation type.

    So I must alloc:

    avcodec_find_decoder(AV_CODEC_ID_AAC_LATM);    
    

    or:

    avcodec_find_decoder(AV_CODEC_ID_AAC);    
    

    as the Decoder.

    And I can using:

    (av_read_frame(pFormatCtx, packet)>=0)
    

    to get a AVFrame .

    How could I get the codec ID from the AVFrame?

    And if not , how could I get the AVCodecID from the API from FFMpeg?

    Thanks for reply.

  • Ffmpeg 2 mp4 combining

    17 novembre 2014, par Fatih Uçar
    class Program
    {
        static void Main(string[] args)
        {
            ProcessStartInfo startInfo = new ProcessStartInfo(@"C:\ffmpeg\bin\ffmpeg.exe");
            Process.Start(startInfo);//ffmpeg open and close
            startInfo = new ProcessStartInfo(@"C:\ffmpeg\bin\ffmpeg.exe", @"cat C:\1.mp4 C:\2.mp4 | ffmpeg -f mpeg -i - -vcodec copy -acodec copy C:\merged.mp4");
            //this close:( 
    
        }
    }
    

    2mp4 combining for windows form application ?

    2 things I want to combine video All I want to combine 2 mp4

  • Can't break out of innermost while loop — Bash - Ubuntu

    16 novembre 2014, par Kenny Powers

    Whenever the two MD5 check sums ($SUMCHK1 & $SUMCHK2) match up in this script I get stuck in the innermost while loop, so the script never ends. When the two log files match, I get an endless echo of the two md5sums on the screen.

    #!/bin/bash
    
    FULLPATH=$1
    FPS=$2
    AVI=$(basename $1)
    AVIDIR=$HOME/q7video/$AVI
    TMPFILE=$AVIDIR/tmp.txt
    TMPFILE2=$AVIDIR/tmp2.txt
    NEWFILES=$AVIDIR/tmp3.txt
    FFLOG=$AVIDIR/ffmpeg.log
    LOGFILE=$AVIDIR/log.log
    FACESDIR=$AVIDIR/faces
    
    # CREATE FOLDER STRUCTURE, NO ERROR IF DIR PRE-EXISTS
    mkdir --parents $AVIDIR
    mkdir --parents $FACESDIR
    touch $TMPFILE $TMPFILE2 $NEWFILES $LOGFILE
    echo $AVI > $LOGFILE
    
    # DUMP THUMBNAILS FROM SPECIFIED AVI FILE
    ffmpeg -i $FULLPATH -f image2 -vf fps=fps=$FPS $AVIDIR/$AVI%03d.jpg null >/dev/null 2>$FFLOG &
    
    # DELAY TO ALLOW LOOP A WORKING DIRECTORY BEFORE START
    sleep 2
    
    #TOUCH FILES TO PREVENT NO FILE ERROR
    touch $TMPFILE $TMPFILE2
    
    # INITIALIZE VARIABLE FOR LOOP
    CHECK=`pgrep ffmpeg`
    I=0
    SUMCHK1=`md5sum $TMPFILE`
    SUMCHK2=`md5sum $TMPFILE2`
    
    while [[ "$CHECK" -gt "$I" ]]; do
        sleep 2
        echo FFMPEG RUNNING
        ls $AVIDIR/*.jpg > $TMPFILE
        while [[ "$SUMCHK1" != "$SUMCHK2" ]]; do
            comm -23 $TMPFILE $TMPFILE2 > $NEWFILES
            while read F ; do
                echo $F
                echo $F >> $TMPFILE2
                echo $F >> $LOGFILE
                python opencvtest.py $F >> $LOGFILE
            done < $NEWFILES
            ls $AVIDIR/*.jpg > $TMPFILE
            SUMCHK1=`md5sum $TMPFILE`
            SUMCHK2=`md5sum $TMPFILE2`
            echo $SUMCHK1
            echo $SUMCHK2
        done
        CHECK=`pgrep ffmpeg`
        echo $CHECK
    done
    
    
    
    # COPY IMAGES WITH A FACE TO FACESDIR
    
    
    # CLEANUP LOGS
    #rm $TMPFILE $TMPFILE2 $NEWFILES
    
  • Real Time Audio and Video Streaming in C#

    16 novembre 2014, par Nuwan

    I am developing an application which can be used to stream audio and video in real time. I can stream in two different ways. I used a capture card to capture live HD stream and re send it. And also I need to stream local video file in real time.

    Now I capture video using OpenCV and store frames as bitmaps in blokingCollection bitmap queue. After that I encode video frames using ffmpeg (used c# library Nreco) and stored in a queue. Then I send that encoded data through UDP (did not used RTP/RTSP) to omxplayer in raspberry pi and it works very fine.

    Then I captured audio data using ffmpeg I used this command to capture and encode audio data.

                     data = ms.ToArray();
                     ffMpegTask = ffmpegConverter.ConvertLiveMedia(
                            fileName,
                            null,
                            ms,
                            Format.avi,
                            new ConvertSettings()
                            {                                
                                CustomOutputArgs = " -tune zerolatency -ss " + second + " -t " + endTime + " -strict experimental -acodec aac -ab 160k -ac 2 -ar 44100 -vn ",                             
                            });
                    ffMpegTask.Start();
                    ffMpegTask.Stop();
                    byte[] data = ms.ToArray();
    

    After that I saved every audio data packet to queue.

    And I tried to stream these separate audio and video data to omxplayer by using two different ports. and received streams by using two omxplayers. And it works fine.

    But what I need to do is multiplex this audio and video stream and send as one stream. what I do is first stream two streams as UDP://224.1.1.1:1250(video) and UDP://224.1.1.1:1260(audio) then I used nreco invoke method. We can use it to execute ffmpeg commands.

    " -re -i udp://224.1.1.1:1250 -i udp://224.1.1.1:1260 -c copy -f avi udp://224.1.1.1:1270"

    and this works for both audio and video stream but completely out of sync.

    Next thing what I do is creating another ffmpeg ConvertLiveMedia task and write audio and video data to that task using write method. And I stream that mux data and received using ffplay. And it plays the stream and the sync problem is solved. But sometimes audio and video frames are dropping and then it begins to play out of sync.

                    combine = new MemoryStream();
                    ffMpegTaskcom = ffmpegConvertercom.ConvertLiveMedia(
                            Format.mpeg,
                            combine,
                            Format.avi,
                            new ConvertSettings()
                            {
                                CustomInputArgs = " ", // windows bitmap pixel format
                                CustomOutputArgs = " -threads 7 -c:v libx264 -preset ultrafast -tune zerolatency -strict experimental -profile:v baseline -movflags +faststart -tune film -level 3.0 -tune zerolatency -tune film -pix_fmt yuv420p -g 250 -crf 22 -b:v 4000k -minrate 3000k -maxrate 5000k -acodec aac -ab 160k -ac 2 -ar 44100",
    
                            });
                    ffMpegTaskcom.Start();
                    byte[] streamBytesvi = null;
                    byte[] streamBytesau = null;
                    encodeQueqe.TryDequeue(out streamBytesvi);
                    encodeQueqeau.TryDequeue(out streamBytesau);
                    ffMpegTaskcom.Write(streamBytesvi, 0, streamBytesvi.Length);
                    ffMpegTaskcom.Write(streamBytesau, 0, streamBytesau.Length);
    
                    //ffMpegTaskcom.Wait();
                    ffMpegTaskcom.Stop();
    

    Now I need to know a good method to deliver audio and video data with synchronization. Please tell me what is the wrong I have done or suggest a better way to do this.

    Thank You!

  • ffmpeg loop with cyrillic filename

    16 novembre 2014, par ranquild

    I want to create a video from a single image. I use this command: ffmpeg -loop 1 -i input.jpg -t 30 output.avi. It works, however, when input filename contains cyrillic letters, command fails with message "Could find no file with path 'файл.jpg' and index in the range 0-4. файл.jpg: No such file or directory". Other ffmpeg commands work fine with cyrillic names. Is there any workaround?