8

Does anyone have experience using ffmpeg with AIR? I have been able to load and play a video but I have not been able to communicate with ffmpeg through stdin in order to control the stream – to seek, pause, etc.

Apparently I need to use filters to communicate with a running instance of ffmpeg but I am struggling with the syntax (or else am misinformed ).

Based on a few things gleaned from the web I am trying this but it doesn't do anything:

var cmd:String = "-f lavfi -i movie=filename='" + videoPath + "':streams=0+1[out0][out1]  -c:a copy -c:v copy -f flv -"

ffmpegProcess.standardInput.writeUTF(cmd + "\n");

Any tips would be most welcome!


Loading code (set up of the NetStream, etc. done elsewhere). This works.

ffmpegArgs = new Vector.<String>();
ffmpegArgs.push("-re", "-i",videoPath,"-c:a", "copy", "-c:v", "copy","-f", "flv", "-");

var nativeProcessStartupInfo:NativeProcessStartupInfo = new NativeProcessStartupInfo();
nativeProcessStartupInfo.executable = ffmpegFile;
nativeProcessStartupInfo.arguments = ffmpegArgs;
ffmpegProcess.start(nativeProcessStartupInfo);
spring
  • 18,009
  • 15
  • 80
  • 160
  • Is this related to your previous question, **[Exhibit A](http://stackoverflow.com/q/39254244/2057709)**? If yes, **you should** mention that your ultimate goal is to do frame accurate seeking. FFmpeg doesn't "play, pause, etc" = → passing ffmpeg result bytes back into AS3 code via **[stdout](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/desktop/NativeProcess.html#standardOutput)**. You playback the bytes and control them via NetStream's **[`appendBytes`](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/NetStream.html#appendBytes())** API – VC.One Sep 25 '16 at 00:38
  • PS: Also I don't think you can do frame accurate seek if using `-c:v copy` option (but double-check this). You have to wait for re-encode since the seeked-to frame must now become a key-frame and it spawns further related P/B frames etc. Frame accurate seeking can be done with 100% actionscript only. Maybe ffmpeg could convert or re-mux any input videos into FLV format? Just remember, seeking is a decoder process not FFmpeg process.... – VC.One Sep 25 '16 at 00:53
  • VLC uses FFmpeg to handle encoding / decoding of formats. After that VLC's own additional code handles the video stream control. Source code is on VideoLan site. FFmpeg can seek within input file _before_ generating output from seeked position. Output is as a file on disk (load the url via NS) or as bytes when using `"-"` option in your settings (so get bytes via **stdout** and append them to NS). Only `stdin` option is Quit or Help. I can show you how to _"control the stream once it has started"_ but only via NS (ie: FFmpeg provides stream, NS code controls the stream). Is that acceptable? – VC.One Sep 27 '16 at 02:11
  • http://www.purplesquirrels.com.au/2013/02/converting-video-with-ffmpeg-and-adobe-air/ – Yogesh Rathi Sep 30 '16 at 17:30

0 Answers0