Re: [FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-04-16 Thread Gabriel Balaich
I was able to mostly solve this issue by utilizing the reset_timestamps
segment option and encoding .ts instead of .mp4. No matter
what I did I could not get this option to work when encoding .mp4 for some
reason:

ffmpeg -y -thread_queue_size  -indexmem  -guess_layout_max 0 -f
dshow -video_size 3440x1440 -rtbufsize 2147.48M ^
-framerate 200 -pixel_format nv12 -i video="Video (00 Pro Capture HDMI
4K+)":audio="SPDIF/ADAT (1+2) (RME Fireface UC)" ^
-map 0:0,0:1 -map 2:1 -c:v h264_nvenc -r 100 -rc-lookahead 200 -forced-idr
1 -strict_gop 1 -sc_threshold 0 -flags +cgop ^
-force_key_frames expr:gte(t,n_forced*2) -preset: llhp -pix_fmt nv12 -b:v
250M -minrate 250M -maxrate 250M -bufsize 250M ^
-c:a aac -ar 44100 -b:a 384k -ac 2 -af "atrim=0.035, asetpts=PTS-STARTPTS,
aresample=async=250" -vsync 1 -ss 00:00:01.096 ^
-max_muxing_queue_size  -f segment -segment_time 600 -segment_wrap 9
-reset_timestamps 1 ^
C:\Users\djcim\Videos\PC\PC\PC%02d.ts

However it isn't perfect, the audio still moves around a tiny bit but it's
anchored to the original position. Basically things can be off
by around 12-16 millisecond after the first segment but not exponentially.
I've also found that after I apply this option when I try to
concat segments back together the audio will drift. Strange behavior and
opposite of what happens when you omit
-reset_timestamps, the audio drifts segment to segment, but lines up
perfectly after concat. I am able to alleviate the drift after
concat by using  aresample=async= but then I can here the audio
stretching an squeezing at times:

ffmpeg -f concat -safe 0 -i "C:\Users\djcim\Google
Drive\Notepad++\FFMPEG\Concatenate.txt" -c:v copy -c:a aac -ar 44100 ^
-b:a 384k -af "aresample=async=250" C:\Users\djcim\Videos\AllCOutputs.ts

Wish there was a more elegant solution but I haven't found anything else
that works. But at least now my audio doesn't
exponentially drift segment to segment. If anyone has any extra advice
surrounding this issue it would be much appreciated.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-03-26 Thread Gabriel Balaich
> -rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map
> 0:0,1:0 -map 1:0 -c:v h264_nvenc -preset: llhp ^
>
> I believe only options from 19.0 - 19.1 in the ffmpeg documentation can be
> applied on a per segment basis, correct me if I'm
>
wrong.
>

Sorry I don't mean to spam but a few quick corrections to my last sent
message:

I'm not sure where I got 19.0 - 19.1, I was referring to 2.0 - 2.1 in the
formats documentation:
https://www.ffmpeg.org/ffmpeg-formats.html

I am also unsure how I managed to make one line in my block of code purple,
it was an accident, it is of no significance.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-03-26 Thread Gabriel Balaich
On Mon, Mar 26, 2018 at 7:27 AM, Jim Shupert 
wrote:

> On 3/25/2018 9:30 PM, Gabriel Balaich wrote:
>
>>
>> -i video="Video (00 Pro Capture HDMI 4K+)"
>>>
>>> a question - what is your capture card?
> ___
>
>
It is the Magewell Pro Capture HDMI 4K Plus:
http://www.magewell.com/pro-capture-hdmi-4k-plus

Also just a few more updates, I assumed it was something to do with
negative time stamps but that doesn't seem to be the
case. After adding -segment_format_options avoid_negative_ts=make_zero the
problem persists:

ffmpeg -y -thread_queue_size  -f dshow -video_size 3440x1440 -rtbufsize
2147.48M -framerate 100 -pixel_format nv12 ^
-itsoffset 00:00:00.015 -i video="Video (00 Pro Capture HDMI 4K+)"
-thread_queue_size  -guess_layout_max 0 -f dshow ^
-rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map
0:0,1:0 -map 1:0 -c:v h264_nvenc -preset: llhp ^
-pix_fmt nv12 -b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -b:a 384k
-ac 2 -r 100 -vsync 1 ^
-max_muxing_queue_size  -f segment -segment_time 300 -segment_wrap 9 ^
-segment_format_options avoid_negative_ts=make_zero
C:\Users\djcim\Videos\PC\PC\PC%02d.mp4

Unless when shifting a negative time stamp to zero it is also shifts other
timestamps the same amount? I'm not really sure how
to view time stamps, so it's hard for me to know this is having any effect
at all. But if that is the case Maybe there is a way to
route that format option to only audio (per segment), but options seem
limited with -segment_format_options. Or I guess
options seem limited in general when applying any type of "option" or
effect per segment as opposed to the initial segment and
nothing after. I believe only options from 19.0 - 19.1 in the ffmpeg
documentation can be applied on a per segment basis,
correct me if I'm wrong. When trying -segment_format_options async=1 for
example it threw an error. Even if there was a way
for me to slightly delay the audio per segment perhaps I could alleviate my
issues to an extent, would be nice if I could find an
actual fix though.

I found a forum post on the "creative cow" forum by a user who seems to be
experiencing the same thing as me:
https://forums.creativecow.net/thread/291/1587

However he has a mic plugged into a camera directly, pulling video and
audio from said camera, and is still experiencing
audio drift when implementing segmentation. So I assume my issues have
nothing to do with my audio and video streams
coming from different sources. Unfortunately it seems no solution was found
in this forum post.

Every time I've thought that I hit a roadblock using ffmpeg I've always
found a way forward, even after searching for fixes for
weeks at time. I've been trying to figure out this last part for months,
things are looking dismal. Any suggestions at all, even
crazy ones, would be extremely appreciated.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-03-26 Thread Jim Shupert

On 3/25/2018 9:30 PM, Gabriel Balaich wrote:



-i video="Video (00 Pro Capture HDMI 4K+)"


a question - what is your capture card?
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-03-25 Thread Gabriel Balaich
On Sat, Mar 24, 2018 at 4:05 PM, Gabriel Balaich 
wrote:

> Hey all, I was hoping I could a get  a bit of help on a problem I'm having.
>
> Here is my code:
> ffmpeg -y -thread_queue_size 5096 -f dshow -video_size 3440x1440
> -rtbufsize 2147.48M -framerate 100 -pixel_format nv12 ^
> -itsoffset 00:00:00.015 -i video="Video (00 Pro Capture HDMI 4K+)"
> -thread_queue_size 5096 -guess_layout_max 0 -f dshow ^
> -rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map
> 0:0,1:0 -map 1:0 -c:v h264_nvenc -preset: llhp ^
> -pix_fmt nv12 -b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -b:a
> 384k -ac 2 -r 100 -async 1 -vsync 1 ^
> -max_muxing_queue_size 5096 -segment_time 300 -segment_wrap 9 -f segment
> C:\Users\djcim\Videos\PC\PC\PC%02d.mp4
>
> My goal is to continuously record without filling up my hard drive keeping
> the last hour and 30 minutes of footage at all times.
> I'd like to have the ability to edit a group or even just a single segment
> without any dependencies. As in be able to drag one
> or more clips into a video editing program like adobe premiere regardless
> of how long I have been recording and have
> everything line up perfectly, including desirable audio to video
> synchronization.Segmentation seemed perfect for this... but
> when I drag the segments into a video editing program like Adobe premiere
> the audio slowly drifts from the video after each
> break. If I remove segmentation and record one continuous clip this does
> not seem to be a problem, video and audio stay
> synchronized. Is there anyway to force the beginning of each segment to
> pick up exactly where the last one left off?
>
> Apologies if any part of my code is redundant, and thank you for any help.
>
>
After further testing I found that if I use concat to rejoin the segments
back together in ffmpeg everything is back in-sync.
While this wouldn't be horrible to do every time it relies on stitching the
segments back together in the order they were
written. Basically I need all of the segments for this to work, but the
problem is once I record for over 1 hour and 30
minutes the segments start to be overwritten. Keeping all segments would
defeat the purpose (for me) as eventually
they would fill up my hard drive.

Further-more it seems that the audio gets ahead of the video, could this
have something to do with segment
segmenting on key frames only in video? Perhaps audio can't be segmented
down to a single sample or something?
It almost seems like I need to force key frames or maybe mess with time
stamps but I just don't even know where to
begin.

Perhaps what I am looking to do is impossible.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-user] Audio Desynchronization When Utilizing Segmentation

2018-03-24 Thread Gabriel Balaich
 Hey all, I was hoping I could a get  a bit of help on a problem I'm having.

Here is my code:
ffmpeg -y -thread_queue_size 5096 -f dshow -video_size 3440x1440 -rtbufsize
2147.48M -framerate 100 -pixel_format nv12 ^
-itsoffset 00:00:00.015 -i video="Video (00 Pro Capture HDMI 4K+)"
-thread_queue_size 5096 -guess_layout_max 0 -f dshow ^
-rtbufsize 2147.48M -i audio="SPDIF/ADAT (1+2) (RME Fireface UC)" -map
0:0,1:0 -map 1:0 -c:v h264_nvenc -preset: llhp ^
-pix_fmt nv12 -b:v 250M -minrate 250M -maxrate 250M -bufsize 250M -b:a 384k
-ac 2 -r 100 -async 1 -vsync 1 ^
-max_muxing_queue_size 5096 -segment_time 300 -segment_wrap 9 -f segment
C:\Users\djcim\Videos\PC\PC\PC%02d.mp4

My goal is to continuously record without filling up my hard drive keeping
the last hour and 30 minutes of footage at all times.
I'd like to have the ability to edit a group or even just a single segment
without any dependencies. As in be able to drag one
or more clips into a video editing program like adobe premiere regardless
of how long I have been recording and have
everything line up perfectly, including desirable audio to video
synchronization.Segmentation seemed perfect for this... but
when I drag the segments into a video editing program like Adobe premiere
the audio slowly drifts from the video after each
break. If I remove segmentation and record one continuous clip this does
not seem to be a problem, video and audio stay
synchronized. Is there anyway to force the beginning of each segment to
pick up exactly where the last one left off?

Apologies if any part of my code is redundant, and thank you for any help.
___
ffmpeg-user mailing list
ffmpeg-user@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".