ultramango / gear360pano

Simple script to create equirectangular panorama by stitching images from Samsung Gear 360
MIT License
225 stars 55 forks source link

processed video has longer duration and audio get out of sync #45

Closed impca closed 6 years ago

impca commented 6 years ago

Camera: 2016 model

I have noticed that when using gear360video.cmd without the --speed switch (ie using the slower, higher quality preset), the final video is slightly stretched, but the audio has correct length. So if I process a 46mn 47s long video, the final processed video is 56mn 5s long and audio goes out of sync.

Original video

General
Complete name                            : party.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 7.25 GiB
Duration                                 : 46mn 47s
Overall bit rate                         : 22.2 Mbps
Writing application                      : Lavf56.4.101

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency 
Format profile                           : Main@L5.1
Codec ID                                 : hev1
Codec ID/Info                            : High Efficiency 
Duration                                 : 46mn 47s
Bit rate                                 : 22.0 Mbps
Width                                    : 2 560 pixels
Height                                   : 1 280 pixels
Display aspect ratio                     : 2.000
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Bits/(Pixel*Frame)                       : 0.224
Stream size                              : 7.18 GiB (99%)

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio C
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 46mn 47s
Bit rate mode                            : Constant
Bit rate                                 : 192 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 64.1 MiB (1%)

Processed video:

General
Complete name                            : party_pano.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom
File size                                : 3.41 GiB
Duration                                 : 56mn 5s
Overall bit rate                         : 8 708 Kbps
Writing application                      : Lavf57.56.101

Video
ID                                       : 1
Format                                   : HEVC
Format/Info                              : High Efficiency Video Coding
Format profile                           : Main@L5.0
Codec ID                                 : hev1
Codec ID/Info                            : High Efficiency Video Coding
Duration                                 : 56mn 5s
Bit rate                                 : 8 593 Kbps
Width                                    : 2 560 pixels
Height                                   : 1 280 pixels
Display aspect ratio                     : 2.000
Frame rate mode                          : Constant
Frame rate                               : 29.970 fps
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.087
Stream size                              : 3.37 GiB (99%)

Audio
ID                                       : 2
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : LC
Codec ID                                 : 40
Duration                                 : 46mn 47s
Bit rate mode                            : Constant
Bit rate                                 : 129 Kbps
Channel(s)                               : 2 channels
Channel positions                        : Front: L R
Sampling rate                            : 48.0 KHz
Compression mode                         : Lossy
Stream size                              : 43.1 MiB (1%)

With the fast preset (--speed), the video is processed correctly.

Any ideas why?

ultramango commented 6 years ago

I'll have a look into that. In the past there was a problem with framerate but I fixed that (and anyway it's correct from the media info you pasted).

There could be something around combination of audio and video or maybe some frames are skipped... But the difference is quite bit - nearly 10 minutes (~18k frames).

FlorianFranzen commented 6 years ago

I have serious issues with that as well. For example a video with 663 frames has 795 after conversion. It gets even worse with longer sequences. A video with 6902 frames had 16548 (!!!) after conversion.

I am using revision 93370b5, as newer version do not work for me at all.

ultramango commented 6 years ago

Using my test videos (generated) I've noticed that every second 6 frames are added. So on average videos will be 20% bigger. I'm trying to pinpoint the cause. For the moment modify script to use "speed" option ("old" encoder).

ultramango commented 6 years ago

Fixed in newest commit. There was a missing -framerate parameter that tells ffmpeg about source material (stitched images) framerate. Default is 25 fps, this explains extra frame every 6th frame (~25/30).