Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • Could not load or assembly or one of its dependencies

    29 juin, par Prathibha Chiranthana

    I am using Aforge.net frame work for doing image processing work. I have add 'AForge.Video.FFMPEG.dll' as a referance to my project. I am using VS2012 and 32 bit build target. When Buiding i get

     System.IO.FileNotFoundException was unhandled
      HResult=-2147024770
      Message=Could not load file or assembly 'AForge.Video.FFMPEG.dll' or one of its dependencies. The specified module could not be found.
      Source=VideoReadere
      FileName=AForge.Video.FFMPEG.dll
      FusionLog=""
      StackTrace:
           at VideoReadere.Form1..ctor()
           at VideoReadere.Program.Main() in c:\Users\Prabad\Documents\Visual Studio 2012\Projects\VideoReadere\VideoReadere\Program.cs:line 19
           at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()
      InnerException: 
    

    my code for that is occur exception

     using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    
    namespace VideoReadere
    {
        static class Program
        {
            /// 
            /// The main entry point for the application.
            /// 
            [STAThread]
            static void Main()
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
    //here below line give exception
                Application.Run(new Form1());
            }
        }
    }
    
  • Linker error with FFmpeg on Windows

    28 juin, par Tiwenty

    I'm trying to link FFmpeg libraries to a C program on Windows, but I can't successfully link the libraries. I downloaded the Dev archive from Zeranoe and put it into my project folder. The compilation works well but when I'm trying to link libraries, I get some undefined reference errors. Here is the command I'm trying:

    gcc -o .\metadata.exe .\metadata.o -L .\ffmpeg-20170628-c1d1274-win64-dev\lib\ -lavutil -lavformat -lavdevice -lavfilter -lavcodec -lswresample -lswscale -lm

    It then outputs me:

    .\metadata.o:metadata.c:(.text+0x44): undefined reference to 'av_register_all' .\metadata.o:metadata.c:(.text+0x6c): undefined reference to 'avformat_open_input' .\metadata.o:metadata.c:(.text+0xc8): undefined reference to 'av_dict_get' .\metadata.o:metadata.c:(.text+0xdf): undefined reference to 'avformat_close_input'

    Paths are good because if I change the -libs parameters or the -L parameter I get files not found errors. Finally, I took those libraries from the Makefile in the examples' folder.

    What is the source of the error? Thanks in advance, have a nice day!

  • Converting .mkv to h.264 FFmpeg

    28 juin, par herman die dev

    I would like to convert my .mkv files to .mp4 using FFmpeg. I have tried the following code:

    ffmpeg -i input.mkv -c:v libx264 -c:a libvo_aacenc output.mp4
    

    But I get the error:

    Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height.

    Is there any way to get around this? I have tried setting the bitrate of the audio but the problem seems to persist.

  • Matplotlib animation quality loss

    28 juin, par Doe a

    I'm currently trying to use matplotlib to animate a grid using imshow. However, I am finding a fairly significant quality loss in the animation.

    Below is a simple animation that illustrates my issue fairly well. If you look at any particular frame of imagelist, you will see that there is no aliasing or gradient between colours. But if I then look at one frame of my animation, that is no longer the case. There is now a 4-5 pixel gradient between my blocks of colour. Does anyone know how I can get around this compression? The file size of the animation doesn't matter too much, as long as I can get a good quality animation.

    #Create list of images
    image=np.array([[[0,0,0],(0.7,0,0),(0,0,0),(0,0,0.8)]])
    imagelist=[]
    for i in range(0,100):
        image[0][1][0]=i/100
        imagelist.append(np.copy(image))
    
    #Create figure    
    fig = plt.figure()
    plt.axis('off')
    im = plt.imshow(imagelist[0], vmin=0, vmax=255,interpolation='none');
    
    #Animation
    def updatefig(j):
        im.set_array(imagelist[j])
        return [im]
    ani = animation.FuncAnimation(fig, updatefig, frames=range(len(imagelist)), interval=20, blit=False)
    
    #Save animation
    FFMpegWriter = animation.writers['ffmpeg']
    mywriter = FFMpegWriter(fps=30, bitrate=5000)
    ani.save("test.mp4", writer=mywriter,codec="libx264")
    
  • Understanding PTS and DTS in video frames

    28 juin, par theateist

    I had fps issues when transcoding from avi to mp4(x264). Eventually the problem was in PTS and DTS values, so lines 12-15 where added before av_interleaved_write_frame function:

    1.  AVFormatContext* outContainer = NULL;
    2.  avformat_alloc_output_context2(&outContainer, NULL, "mp4", "c:\\test.mp4";
    3.  AVCodec *encoder = avcodec_find_encoder(AV_CODEC_ID_H264);
    4.  AVStream *outStream = avformat_new_stream(outContainer, encoder);
    5.  // outStream->codec initiation
    6.  // ...
    7.  avformat_write_header(outContainer, NULL);
    
    8.  // reading and decoding packet
    9.  // ...
    10. avcodec_encode_video2(outStream->codec, &encodedPacket, decodedFrame, &got_frame)
    11. 
    12. if (encodedPacket.pts != AV_NOPTS_VALUE)
    13.     encodedPacket.pts =  av_rescale_q(encodedPacket.pts, outStream->codec->time_base, outStream->time_base);
    14. if (encodedPacket.dts != AV_NOPTS_VALUE)
    15.     encodedPacket.dts = av_rescale_q(encodedPacket.dts, outStream->codec->time_base, outStream->time_base);
    16. 
    17. av_interleaved_write_frame(outContainer, &encodedPacket)
    

    After reading many posts I still do not understand:

    1. outStream->codec->time_base = 1/25 and outStream->time_base = 1/12800. The 1st one was set by me but I cannot figure out why and who set 12800? I noticed that before line (7) outStream->time_base = 1/90000 and right after it it changes to 1/12800, why? When I transcode from avi to avi, meaning changing the line (2) to avformat_alloc_output_context2(&outContainer, NULL, "avi", "c:\\test.avi"; , so before and after line (7) outStream->time_base remains always 1/25 and not like in mp4 case, why?
    2. What is the difference between time_base of outStream->codec and outStream?
    3. To calc the pts av_rescale_q does: takes 2 time_base, multiplies their fractions in cross and then compute the pts. Why it does this in this way? As I debugged, the encodedPacket.pts has value incremental by 1, so why changing it if it does has value?
    4. At the beginning the dts value is -2 and after each rescaling it still has negative number, but despite this the video played correctly! Shouldn't it be positive?