Newest 'ffmpeg' Questions - Stack Overflow

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

Les articles publiés sur le site

  • How to open a video/audio capture device with ffmpeg programatically ?

    28 novembre 2012, par user71512

    I am following the guide http://dranger.com/ffmpeg/tutorial01.html about ffmpeg and sdl and i would like to instead of opening a video file, use a video capture device as the source. How does one pragmatically do it? I assume one will modify the Context, but i just a specific example. I know how to do it with the command line.

    AVFormatContext *pFormatCtx;
    
    // Open video file
    if(av_open_input_file(&pFormatCtx, argv[1], NULL, 0, NULL)!=0)
      return -1; // Couldn't open file
    

    Looking at the doxygen, i don't see an analagous function for devices.

  • Understanding pts rescaling

    28 novembre 2012, par theateist

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

    if (encodedPacket.pts != AV_NOPTS_VALUE)
        encodedPacket.pts =  av_rescale_q(encodedPacket.pts, outStream->codec->time_base, outStream->time_base);
    if (encodedPacket.dts != AV_NOPTS_VALUE)
        encodedPacket.dts = av_rescale_q(encodedPacket.dts, outStream->codec->time_base, outStream->time_base);
    

    After reading many posts I still does 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?
    2. What is the difference between time_base of outStream->codec and outStream?
    3. To calc the fps 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 rescalin it always has negative number, but despite this the transcoding success! What negative value means?

    I'll be glad if someone could explain me.

  • Play AAC in SoundManager2 won't start

    27 novembre 2012, par sasa

    I converted audio file MP4 to AAC and then want to play that file in SoundManager2. If I use some software for Windows for convert, everying is fine, audio is playing well. But, on server side when MP4 file is converted to AAC using ffmpeg, file is loaded in SM2, but playing is not started.

    I use this command:

    ffmpeg -i in.mp4 out.aac
    

    Here is SoundManager2 log:

    -- SoundManager 2: HTML5 support tests (/^(probably|maybe)$/i): mp3: true (preferring flash), mp4: true (preferring flash), ogg: true, wav: true -- soundmanager2.js:1156
    -- SoundManager 2 V2.97a.20120916 (AS3/Flash 9) + HTML5 audio, high performance mode, custom (1ms) polling, wmode: transparent, flash debug mode, flashBlock mode -- soundmanager2.js:1156
    soundManager::createMovie(): Trying to load /soundmanager/swf/soundmanager2_flash9_debug.swf soundmanager2.js:1156
    soundManager::initMovie(): Waiting for ExternalInterface call from Flash... soundmanager2.js:1158
    soundManager::externalInterfaceOK() (~0 ms) soundmanager2.js:1158
    soundManager::init() soundmanager2.js:1158
    soundManager: Attempting JS to Flash call... soundmanager2.js:1158
    (Flash): SM2 SWF V2.97a.20120916 (AS3/Flash 9) soundmanager2.js:1158
    Flash security sandbox type: remote soundmanager2.js:1158
    (Flash): JS to/from Flash OK soundmanager2.js:1158
    (Flash): Enabling polling, 1 ms interval soundmanager2.js:1158
    -- SoundManager 2 loaded (OK) -- soundmanager2.js:1156
    soundManager: Firing 1 onready() item soundmanager2.js:1158
    threeSixtyPlayer.init() soundmanager2.js:1158
    threeSixtyPlayer.init(): Found 1 relevant items. soundmanager2.js:1158
    handleClick() soundmanager2.js:1158
    soundManager.createSound(): ui360Sound0 (http://[private url]/out.aac?v=1350309261) soundmanager2.js:1156
    soundManager.createSound(): Enabling usePolicyFile for data access soundmanager2.js:1158
    SMSound() merged options: {
     id: ui360Sound0, 
     url: http://[private url]/out.aac?v=1350309261, 
     onplay: { pl.removeClass(this._360data.oUIBox,this._360data.className); t... }, 
     onstop: { pl.removeClass(this._360data.oUIBox,this._360data.className); t... }, 
     onpause: { pl.removeClass(this._360data.oUIBox,this._360data.className); t... }, 
     onresume: { pl.removeClass(this._360data.oUIBox,this._360data.className); t... }, 
     onfinish: { var nextLink; pl.removeClass(this._360data.oUIBox,this._360data... }, 
     onbufferchange: { if (this.isBuffering) { pl.addClass(this._360data.oUIBox,pl.css... }, 
     whileloading: { if (this.paused) { self.updatePlaying.apply(this); } }... }, 
     whileplaying: { self.updatePlaying.apply(this); this._360data.fps++; }... }, 
     useWaveformData: false, 
     useEQData: false, 
     usePeakData: true, 
     autoLoad: false, 
     autoPlay: false, 
     loops: 1, 
     multiShot: true, 
     multiShotEvents: false, 
     pan: 0, 
     stream: true, 
     usePolicyFile: true, 
     volume: 50, 
     useMovieStar: false, 
     isMovieStar: false, 
     bufferTime: 3
    } soundmanager2.js:1158
    (Flash): SoundManager2_SMSound_AS3: Got duration: 0, autoPlay: false soundmanager2.js:1158
    SMSound.play(): Attempting to load "ui360Sound0" soundmanager2.js:1156
    SMSound.load(): http://[private url]/out.aac?v=1350309261 soundmanager2.js:1156
    SMSound.play(): "ui360Sound0" is starting to play soundmanager2.js:1158
    fanOut: ui360Sound0: http://[private url]/out.aac?v=1350309261 soundmanager2.js:1158
    (Flash): start (ui360Sound0): 0 soundmanager2.js:1158
    SMSound._onbufferchange(): 1 soundmanager2.js:1158
    SMSound._onbufferchange(): 0 soundmanager2.js:1158
    SMSound._onload(): "ui360Sound0" loaded. 
    

    What can be a problem?

  • How can I rotate video with FFmpeg ?

    27 novembre 2012, par user291247

    My existing video is .mov and plays vertically, but when I convert it to .flv with FFmpeg it plays horizontally. How can I correct the converted video to play vertically?

    function convert_flv($vidtime, $infile, $outfile, $w = 0, $h = 0, $extra_infile = '', $extra_outfile = '') {
      $parms = '';
      if($w == 0 && $h == 0) {
        //$parms .= '-sameq ';
      } else {
        $parms = '-s {$w}x{$h} ';
      }
    
      if($vidtime==60)
      {
        $cmd = ffmpeg($infile, $outfile, $parms.' '.$extra_infile, '-t 00:01:00 -ar 22050 -r 15 -f flv '.$extra_outfile);
      }
      else
      {
        $cmd = ffmpeg($infile, $outfile, $parms.' '.$extra_infile, '-t 00:04:00 -ar 22050 -r 15 -f flv '.$extra_outfile);
      }
      print_r($cmd);
      return $cmd;
    } 
    
  • What could change the fps when copying frames from mp4 file to mp4 without reencoding ?

    27 novembre 2012, par theateist

    I try to copy video from in.mp4 to out.mp4 without reincoding. I'm using the code example suggested by pogorskiy here. The copy process success, but the video is played very fast. I checked the fps of both files with MediaInfo. The fps of "in.mp4" is 25 fps and "out.mp4" it 533fps. I don't understand what changing the fps to 533 if I construct outStream from inStream?

    I hope I explained myself correctly.