Edited video produces smaller image that original, even with higher resolution - encoding

I've a .ts format recording from my Humax, which completely fills the window horizontally when played with VLC. In full-screen it fills the screen horizontally in letterbox style, and the same on the TV when played through my PS/3. All good so far.
This is the ffprobe output:
Duration: 02:16:37.72, start: 74238.902878, bitrate: 2554 kb/s
Stream #0:0[0x931]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv), 704x576 [SAR 16:11 DAR 16:9], max. 15000 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
I used ffmpeg to change the audio track:
ffmpeg -i movie.ts -c:v libx264 -c:a ac3 -crf 20 -map 0:v:0 -map 0:a:1 movie.mp4
and produced an .mp4 which also plays correctly.
ffprobe:
Duration: 02:16:37.68, start: 0.005333, bitrate: 1129 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 704x576 [SAR 16:11 DAR 16:9], 932 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
However, if I edit it using OpenShot, I cannot find any export format that produces an image that fills the window horizontally in the same way, regardless of what resolution or aspect ratio I use.
Example: export format "DV/DVD Widescreen PAL (720x576)" produces this (sample) file:
Duration: 00:00:39.12, start: 0.040000, bitrate: 563 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x576, 477 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
OpenShot appears not to set the AR, so it initially shows in VLC in 5:4 aspect, but even changing the VLC AR to the maximum of 2.39:1 does not stretch it fully from side-to-side.
I've used ffmpeg to experiment with changing the aspect ratio, changing the resolution, and setting the SAR and DAR, all without success.
This can't be a resolution issue, as I've exported 720p and 1080i, plenty of pixels but all produce roughly the same result - a small image that doesn't fill the window, and ditto on the TV. The original recording is only 704x576 but fills the window. Also the aspect ratio of the original recording is 16:9 (VLC agrees) but the actual measured AR of the screen image is closer to 2.04:1.
I'm hoping that while this could be an OpenShot issue, the cause of the problem should be visible to ffprobe and perhaps fixable with ffmpeg. Help wil be appreciated.

Related

Scene background from camera - FPS

I can use AVCaptureDevice as background.contents of SCNScene. And it works, but there is one problem with it. I would like to use video format that has resolution 1920x1080, and 60 FPS. But I can clearly see, that different format is used, it is 30 FPS. I am configuring used device before applying it to background, but somehow SCNScene is changing it. SceneView itself works in 60 FPS, but camera preview is a different story. Can I somehow force SCNScene to use video format I choose?
I know I could just add layer with camera preview under SceneView, but I have reasons why this approach is not working correctly, so I need to use this background property od the scene.
Sample project is here: https://www.dropbox.com/s/b820wxlg8voya58/SampleApp.zip?dl=1
In terminal you can clearly see, that after starting SceneView active format for device changes:
Selected format is:
<AVCaptureDeviceFormat: 0x282d58d00 'vide'/'420v' 1280x 720, { 3- 60 fps}, HRSI:4096x2304, fov:58.632, supports vis, max zoom:120.00 (upscales #2.91), AF System:2, ISO:23.0-736.0, SS:0.000013-0.333333>
2018-10-10 14:47:35.009890+0200 SampleApp[6799:1110910] [SceneKit] Error: Could not get pixel buffer (CVPixelBufferRef)
Format after 3 seconds is:
<AVCaptureDeviceFormat: 0x282d58fb0 'vide'/'420v' 1920x1080, { 3- 30 fps}, HRSI:4096x2304, fov:58.632, supports vis, max zoom:16.00 (upscales #1.94), AF System:2, ISO:23.0-736.0, SS:0.000013-0.333333>

Setting high frame rate recording in Swift

i'm trying to create an app to record video at 120fps but i'm having troubles.
First, when print(device.activeFormat), i get this in the logs
AVCaptureDeviceFormat: 0x13fe49890 'vide'/'420v' 1920x1080, { 2- 30 fps}, fov:58.080, supports vis, max zoom:104.38 (upscales #1.55), AF System:1, ISO:34.0-544.0, SS:0.000024-0.500000
but my device is an iPhone 5s which supports 120fps, don't know why the range here is 2-30fps.
Second, when i do device.activeVideoMaxFrameDuration = CMTimeMake(1, 120) to change the max frame rate to 120 fps, i get this error in the logs:
[AVCaptureVideoDevice setActiveVideoMaxFrameDuration:] - the passed activeVideoMaxFrameDuration 1:120 is not supported by the device.
What am i doing wrong?
Thanks!
As you can see from your print(device.activeFormat), the max support fps is 30 given {2- 30 fps}. Therefore, setting 120 fps with device.activeVideoMaxFrameDuration = CMTimeMake(1, 120) is not supported.

mplayer under uvesafb frame buffer will show black screen before playing video [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm try using mplayer to play video under frame buffer, and I'm using uvesafb as the frame buffer driver. The board is VIA EPIA-N800
The grub boot setting is:
/boot/vmlinuz-2.6.32 root=UUID=7ece6c10-7255-4f21-8cd8-edb096233969 ro quiet console=tty2 nomodeset video=uvesafb:mode_option=1920x1080-16,mtrr=3,scroll=ywrap
But when I play the video with mplayer, the screen will become black for a while, seems like reset or re-initial the screen before playing the video. The command is like that:
mplayer -vo fbdev /opt/1.avi
And the output is
root#ytmp:/opt/ytmp# mplayer -vo fbdev /opt/1.avi
MPlayer 1.0rc3-4.4.4 (C) 2000-2009 MPlayer Team
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.
Playing /opt/1.avi.
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO: [] 720x576 24bpp 25.000 fps 5459.1 kbps (666.4 kbyte/s)
Clip info:
Software: MEncoder 1.0rc3-4.4.4
==========================================================================
Opening video decoder: [mpegpes] MPEG 1/2 Video passthrough
VDec: vo config request - 720 x 576 (preferred colorspace: Mpeg PES)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
The selected video_out device is incompatible with this codec.
Try appending the scale filter to your filter list,
e.g. -vf spp,scale instead of -vf spp.
VDecoder init failed :(
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Unsupported PixelFormat -1
Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
==========================================================================
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 224.0 kbit/14.58% (ratio: 28000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
AO: [pulse] Init failed: Connection refused
Failed to initialize audio driver 'pulse'
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Starting playback...
VDec: vo config request - 720 x 576 (preferred colorspace: Planar YV12)
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.33:1 - prescaling to correct movie aspect.
[swscaler # 0xb5f167a0]using unscaled yuv420p -> rgb565 special converter
VO: [fbdev] 720x576 => 768x576 BGR 16-bit
A: 75.0 V: 75.0 A-V: 0.000 ct: 0.024 1875/1875 19% 1% 0.7% 0 0
MPlayer interrupted by signal 2 in module: sleep_timer
A: 75.0 V: 75.0 A-V: 0.000 ct: 0.024 1876/1876 19% 1% 0.7% 0 0
Exiting... (Quit)
If I change the grub boot setting like this:
/boot/vmlinuz-2.6.32 root=UUID=7ece6c10-7255-4f21-8cd8-edb096233969 ro quiet console=tty2 vga=0x317
The problem did not appear. I did compare both mplayer output, but the output is same.
Did there any way to solve this?
In the first case (argument=nomodeset video=uvesafb:mode_option=1920x1080-16), you disabled KMS(Kernel Mode Settings), and use uvesafb instead. If KMS is disabled, when you switch between virtual terminal and X11/framebuffer, the screen will turn black for a while. In the second case you just set the resolution and KMS works. So you can switch between terminal and framebuffer without any problems.

Achieving very poor fps for my iphone app for decode + display h264 frames using ffmpeg and opengl

I have three steps process for my application which display h264 frame on iPhone screen.
decode using ffmpeg.
scale and colorspace conversion (scale to 256 X 256 Opengl ES 1 texture and convert colospace from yuv420p to rgb565 using sws_Scale from ffmpeg).
Render opengl 1 texture to frame buffer to render buffer
after these three step process, I got my picture on iPhone screen.
When I was testing the performance for 720 X 576 resolution frames, I obtain very poor FPS. It is reaching max to 180 milliseconds and hence resulting into 5 to 6 FPS.
Any direction will be grateful.

video captured from iphone gets rotated when converted to .mp4 using ffmpeg

When I try to upload videos captured from my iPhone in my app, the server performs a conversion from .mov to .mp4 so that it can be played in other platforms. However the problem is that when I shoot the video (in portrait orientation) and it is converted (using ffmpeg) and then played back from the server, it appears to be rotated. Any idea?
FFMPEG changed the default behavior to auto rotate video sources with rotation metadata in 2015. This was released as v2.7.
If your ffmpeg version is v2.7 or newer, but your rotation metadata isn't respected, the problem is likely that you are using custom rotation based on metadata. This will cause the same logic to be applied twice, changing or cancelling out the rotation.
In addition to removing your custom rotation (recommended), there's an option to turn off auto rotation with -noautorotate.
ffmpeg -noautorotate -i input.mp4...
This will also work in some older releases.
For sake of completeness, the reason this is happening is that iPhones only actually capture video in one fixed orientation. The measured orientation is then recorded in Apple-specific metadata.
The effect is that Quicktime Player reads the metadata and rotates the video to the correct orientation during playback, but other software (e.g., VLC) does not and shows it as oriented in the actual codec data.
This is why rotate=90 (or vflip, or transpose, or etc.) will work for some people, but not others. Depending on how the camera is held during recording, the rotation necessary could be 90, 180, or even 270 degrees. Without reading the metadata, you're just guessing at how much rotation is necessary and the change that fixes one video will fail for another.
What you can also do is remove the QuickTime specific metadata when rotate the .mov.
This will make sure that the video is rotated the same way in VLC and QuickTime
ffmpeg -i in.mov -vf "transpose=1" -metadata:s:v:0 rotate=0 out.mov
Here's the documentation on the -metadata option (from http://ffmpeg.org/ffmpeg.html):
-metadata[:metadata_specifier] key=value (output,per-metadata)
Set a metadata key/value pair.
An optional metadata_specifier may be given to set metadata on streams or chapters. See -map_metadata documentation for details.
This option overrides metadata set with -map_metadata. It is also possible to delete metadata by using an empty value.
For example, for setting the title in the output file:
ffmpeg -i in.avi -metadata title="my title" out.flv
To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:1 language=eng OUTPUT
Depending on which version of ffmpeg you have and how it's compiled, one of the following should work...
ffmpeg -vf "transpose=1" -i input.mov output.mp4
...or...
ffmpeg -vfilters "rotate=90" -i input.mov output.mp4
Use the vflip filter
ffmpeg -i input.mov -vf "vflip" output.mp4
Rotate did not work for me and transpose=1 was rotating 90 degrees
So - I too ran into this issue, and here my $0.02 on it:
1.) some videos DO have Orientation/Rotation metadata, some don't:
MTS (sony AVHCD) or the AVIs I have - DO NOT have an orientation tag.
MOVs and MP4s (ipad/iphone or samsung galaxy note2) DO HAVE it.
you can check the setting via 'exiftool -Rotation file'.
My videos often have 90 or 180 as the rotation.
2.) ffmpeg - regardless of the man-page with the metadata-tag, just doesn't EVER seem to set it in the output file. - the rotation-tag is ALWAYS '0'.
it correctly reports it in the output - but it's never set right to be reported by exiftool. - But hey - at least it's there and always 0.
3.) rotation angles:
if you want rotate +/- 90: transpose=1 for clockwise 90, 2 ccw
now if you need 180 degree - just add this filter TWICE.
remember - it's a filter-chain you specify. :-) - see further down.
4.) rotate then scale:
this is tricky - because you quickly get into MP4 output format violations.
Let's say you have a 1920x1080 MOV.
rotate by 90 gives 1080x1920
then we rescale to -1:720 -> 1080*(720/1920) = 405 horiz
And 405 horizontal is NOT divisable by 2 - ERROR. fix this manually.
FIXING THIS automatically - requires a bit of shell-script work.
5.) scale then rotate:
you could do it this way - but then you end up with 720x1280. yuck.
But the filter-example here would be:
"-vf yadif=1,scale=-1:720,transpose=1"
It's just not what I want - but could work quite OK.
Putting it all together: - NOTE - 'intentionally WRONG Rotation-tag', just to demonstrate - it won't show up AT ALL in the output !
This will take the input - and rotate it by 180 degree, THEN RESCALE IT - resetting the rotation-tag. - typically iphone/ipad2 can create 180deg rotated material.
you just can leave '-metadata Rotation=x' out the line...
/usr/bin/ffmpeg -i input-movie.mov -timestamp 2012-06-23 08:58:10 -map_metadata 0:0 -metadata Rotation=270 -sws_flags lanczos -vcodec libx264 -x264opts me=umh -b 2600k -vf yadif=1,transpose=1,transpose=1,scale=1280:720 -f mp4 -y output-movie.MP4
I have multiple devices - like a settop box, ipad2, note2, and I convert ALL my input-material (regardless whether it's mp4,mov,MTS,AVI) to 720p mp4, and till now ALL the resulting videos play correct (orientation,sound) on every dev.
Hope it helps.
For including into web pages my portrait-format videos from iPhone, I just discovered the following recipe for getting .mp4 files in portrait display.
Step 1: In QuickTime Player, Export your file to 480p (I assume that 720p or 1080p would work as well). You get a .mov file again.
Step 2: Take the new file in QT Player, and export to “iPad, iPhone…”. You get a .m4v file.
Step 3: I’m using Miro Video Converter, but probably any readily-available converter at all will work, to get your .mp4 file.
Works like a (long-winded) charm.
I've filmed the video with Ipad3 and it was oriented upside down, which I suppose is the common situation of all Apple devices at some versions. Besides of it, the 3-minutes long MOV file (1920x1090) took about 500 Mb in size, which made it not available to share easily. I had to convert it to MP4, and analyzing all threads I've found on stackoverflow, here's the final code string for ffmpeg I've used (ffmpeg ver. 2.8.4):
ffmpeg -i IN.MOV -s 960x540 -metadata:s:v rotate="0" -acodec libmp3lame OUT.mp4
I suppose you may just leave '-metadata:s:v rotate="0"' if you don't need the resize and audio codec change. Note that if you resize the video, width and height should fully divide to 4.
Although the topic is old.
Hope this will help some one:
Get ffmpeg latest version : https://www.ffmpeg.org/download.html
The command that worked for me (to flip 180 degrees):
ffmpeg -noautorotate -i input.mp4 -filter:v "rotate=PI" output.mp4
When the degrees are determined by -filter:v "PI/180*degrees"
for example
-filter:v "45*PI/180" for 45 degrees
A nice explanation is here
https://superuser.com/questions/578321/how-to-rotate-a-video-180-with-ffmpeg
Or... to simply change the tag in an existing file:
Read the current rotation
exiftool -Rotation <file>
then, for example:
exiftool -Rotation=180 <file>
to set it to 180