Is there a way to use ffmpeg to determine the encoding of a file before transcoding?

Use ffprobe Example command $ ffprobe -v error -select_streams v:0 -show_entries stream=codec_name -of default=nokey=1:noprint_wrappers=1 input.mp4 Result h264 Option descriptions -v error Omit extra information except for fatal errors. -select_streams v:0 Select only the first video stream. Otherwise the codec_name for all other streams in the file, such as audio, will be shown as well. -show_entries … Read more

How to convert RGB from YUV420p for ffmpeg encoder?

You can use libswscale from FFmpeg like this: #include <libswscale/swscale.h> SwsContext * ctx = sws_getContext(imgWidth, imgHeight, AV_PIX_FMT_RGB24, imgWidth, imgHeight, AV_PIX_FMT_YUV420P, 0, 0, 0, 0); uint8_t * inData[1] = { rgb24Data }; // RGB24 have one plane int inLinesize[1] = { 3*imgWidth }; // RGB stride sws_scale(ctx, inData, inLinesize, 0, imgHeight, dst_picture.data, dst_picture.linesize); Note that you … Read more

streaming video FROM an iPhone

You could divide your recording to separate files with a length of say, 10sec, then send them separately. If you use AVCaptureSession‘s beginConfiguration and commitConfiguration methods to batch your output change you shouldn’t drop any frames between the files. This has many advantages over frame by frame upload: The files can be directly used for … Read more

How to detect if a video file was recorded in portrait orientation, or landscape in iOS

Based on the previous answer, you can use the following to determine the video orientation: + (UIInterfaceOrientation)orientationForTrack:(AVAsset *)asset { AVAssetTrack *videoTrack = [[asset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0]; CGSize size = [videoTrack naturalSize]; CGAffineTransform txf = [videoTrack preferredTransform]; if (size.width == txf.tx && size.height == txf.ty) return UIInterfaceOrientationLandscapeRight; else if (txf.tx == 0 && txf.ty == 0) return … Read more