Commit Graph

303 Commits

Author SHA1 Message Date
Isaac Connor 0a31a8dab6 Just use pts instead of tracking both first pts and first dts. Should prevent conflicts 2019-09-15 17:53:25 -04:00
Isaac Connor eafa0da06f fixes, handle when audio codec isn't open in ffmpeg_camera 2019-09-13 16:06:25 -04:00
Isaac Connor 3a5d1ff3ca Hack in missing bits for ubuntu trusty/libav/avresample 2019-09-13 15:51:35 -04:00
Isaac Connor 5ddd20ed1a refactor code. Handle resample buffering during encoding instead of when closing file 2019-09-13 14:34:53 -04:00
Isaac Connor 701aa8d924 add flushing the resample buffer to get the remaining samples encoded 2019-09-13 10:55:30 -04:00
Isaac Connor 788b5b480b hack to make sync work on resample 2019-09-12 17:59:08 -04:00
Isaac Connor d9d4c6b4ca fix build 2019-09-12 17:26:19 -04:00
Isaac Connor 0a8aba2b76 rework how pts/dts is handled. We still use video_first_pts, but if the result is negative, normalize it to 0. Also now use audio_next_pts/dts to calculate pts when resampling and re-encoding. I believe this resolves the issues with wrong duration in the audio stream. 2019-09-12 16:52:59 -04:00
Isaac Connor 097ce5e778 add const to cast 2019-09-09 17:09:01 -04:00
Isaac Connor 792af28c54 return a value from write_packet 2019-09-09 16:55:22 -04:00
Isaac Connor d5aa95e45f cpplint fixes 2019-09-09 16:13:32 -04:00
Isaac Connor d5d4d9d19b ret should be a heap var, not a member of the object. Somehow this also seems to fix crashing on debian buster. I assume the compiler is confused 2019-09-08 16:10:57 -04:00
Isaac Connor bd3395ac98 introduce VideoStore::write_packet to refactor out duplicated code. Add the ability to receive multiple packets from audio encoder per input packet 2019-08-28 12:19:54 -04:00
Isaac Connor 39620c01ff Add rescaling of pkt pts/dts from audio_out_ctx to audio_out_stream 2019-08-26 16:37:32 -04:00
Isaac Connor b26ed9bf62 Yet more debugging. Also, move pts adjustment to before audio encoding 2019-08-26 16:17:45 -04:00
Isaac Connor 2fe9442257 Fix time_base conversion when flushing audio queue. Add more debugging. COrrect pkt_Duration when resampling audio 2019-08-23 18:17:26 -04:00
Isaac Connor 396be10d6f Merge branch 'master' into zma_to_thread 2019-08-22 12:57:00 -04:00
Isaac Connor 6a9464044b Demote warnings about fixing non-monotonic dts to debug 2019-08-02 08:03:02 -04:00
Isaac Connor 1e0c39c632 mostly spacing cleanups. Don't bother setting pkt_duration on resampled frame 2019-07-19 16:28:18 -04:00
Isaac Connor 13c91bdf60 Add pts adjustment to the delayed flushed encoder packets 2019-07-11 17:56:53 -04:00
Isaac Connor 94cc85aa36 Sorta fix pts on encoded audio packets. Sync is off, but at least it is close 2019-07-07 08:57:22 -04:00
Isaac Connor 5ea5bd9bde Only do audio_first_pts if we have audio_in_stream 2019-07-02 12:26:33 -04:00
Isaac Connor 4e8ac47060 Use the video_first_pts to set the audio_first_pts 2019-07-02 11:58:22 -04:00
Isaac Connor dd57fd95ce Clean up cruft from videostore api. Fix packetqueue clear_unwanted_packets to take a pre_event_count and take it into consideration when finding the right spot in the queue to start recording. 2019-06-27 11:11:14 -04:00
Isaac Connor 46f3aabc25 Merge branch 'hwdecode' into storageareas 2019-06-25 15:35:56 -04:00
Isaac Connor 86c4051c44 handle zm_receive_frame returning AVERROR instead of boolean 2019-06-25 15:34:36 -04:00
Isaac Connor 9a353d0b6d don't set frame size 2019-06-24 11:44:21 -04:00
Isaac Connor 44e4d93445 Merge branch 'master' into storageareas 2019-06-24 11:35:36 -04:00
Isaac Connor dab9544845
Revert audio sync fixes (#2646)
* Reference /run/zm instead of /var/run/zm because systemd-tmpfiles complains about it

* Spacing, google code style and tabs to spaces

* Revert the work I did to srt packets by dts after changing their time_base.  It doesn't work.  Instead since dts doesn't actually matter to playback, only ffmpeg storing, munge it to whatever is neccessary to make ffmpeg happy.
2019-06-24 11:27:47 -04:00
Isaac Connor 55d98e4a9f fix crash 2019-06-20 15:56:25 -04:00
Isaac Connor 470da03322 Merge sync fixes from storageareas 2019-06-20 15:14:20 -04:00
Isaac Connor 4c8b8d0c16 Only check pts vs dts if pts isn't AV_NOPTS_VALUE. Also set frame_size in output codec when doing passthrough 2019-06-20 15:09:30 -04:00
Isaac Connor 16b035f76c Use common first_dts/pts instead of separate video and audio first pts/dts 2019-06-19 09:22:21 -04:00
Isaac Connor acb95709e6 Fix issues with too much audio in events by storing packets in the queue with their timestamps converted to AV_TIME_BASE_Q, so that we can sort video and audio packets together. 2019-06-11 10:19:42 -04:00
Isaac Connor 8b4fddadfb out_frame->pts is calculated in resample_audio 2019-05-27 12:29:29 -04:00
Isaac Connor c257fb46f6 Merge branch 'storageareas' of github.com:connortechnology/zoneminder into storageareas 2019-05-13 10:34:45 -04:00
Isaac Connor 22c5d46c65 rescale audio packet duration and pts before feeding to codec after resample 2019-05-12 12:14:03 -04:00
Isaac Connor d7daf8550f Merge branch 'master' into storageareas 2019-05-12 09:37:41 -04:00
Isaac Connor 453bc2afd8 more frame dumping in resample 2019-05-12 09:36:26 -04:00
Isaac Connor 67c20aa976 fix frame->duration to frame->pkt_duration 2019-05-10 12:58:54 -04:00
Isaac Connor d3a680aaa3 Set out_frame duration when resampling. Better error message if failed to write to fifo 2019-05-10 12:31:10 -04:00
Isaac Connor 50070a9a7c Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into storageareas 2019-05-03 14:59:14 -04:00
Isaac Connor 1e08b333b4 choose cur_dts instead of 0 for dts 2019-05-03 14:59:09 -04:00
Isaac Connor 18285e1b94 fix using in_frame->nb_samples instead of out_frame->nb_samples in resample fifo. 2019-04-25 18:45:43 -04:00
Isaac Connor 8bbcf0f631 merge storageareas 2019-04-25 14:49:16 -04:00
Isaac Connor 077ad75516 Merge branch 'storageareas' into origin/zma_to_thread 2019-04-25 12:41:48 -04:00
Isaac Connor 3664084862 Handle out of order dts in writeAudioFrame 2019-04-15 13:27:13 -04:00
Isaac Connor 96b7d30d7d Merge branch 'master' into zma_to_thread 2019-04-15 10:47:26 -04:00
Isaac Connor 439a7b3ab3 Don't set bitrate, etc when h264. Causing crashes in ffmpeg 4.11. 2019-04-14 13:50:10 -04:00
Isaac Connor fab548b119 Merge branch 'master' of github.com:ZoneMinder/ZoneMinder 2019-04-08 16:46:28 -04:00
Isaac Connor 1b98f3529f allow non-increasing dts in muxer 2019-04-08 14:18:59 -04:00
Isaac Connor 7f2440177b remove duplicate dump_codec 2019-04-08 13:51:55 -04:00
Isaac Connor 3c57d79669 Go back to using video_first_dts 2019-04-08 10:04:26 -04:00
Isaac Connor 8d3fa807e2 compilation fixes for old ffmpeg 2019-04-03 16:51:41 -04:00
Isaac Connor 94479fc850 copy pkt flags as well. When pts is NOPTS_VALUE set it to zero 2019-04-03 16:03:21 -04:00
Isaac Connor 055efdc950 Merge branch 'master' of github.com:ConnorTechnology/ZoneMinder 2019-04-03 14:56:18 -04:00
Isaac Connor bd9b5afe46 old ffmpeg doesn't have av_frame_unref and it doesn't seem to be needed 2019-04-03 14:56:14 -04:00
Isaac Connor b53e4aa803 fix segfault 2019-04-03 14:51:10 -04:00
Isaac Connor b6f35db4de put back codec closing in destructure, testing with bionic 2019-04-03 14:25:18 -04:00
Isaac Connor aece64049f We cannot avcodec_open2 a context that has been duped. This code currently works without crashes and leaks on ffmpeg 2.8 2019-04-03 13:23:00 -04:00
Isaac Connor bd412fa9ca Merge branch 'master' of github.com:ZoneMinder/ZoneMinder 2019-04-02 14:25:50 -04:00
Isaac Connor cd28559c03 when encoding audio, pts and dts have to come from the encoder. 2019-04-02 14:08:46 -04:00
Isaac Connor 87cb716500 Merge branch 'master' of github.com:ZoneMinder/ZoneMinder 2019-04-01 14:02:46 -04:00
Isaac Connor cb33318c4a fix invalid memory access due to incorrect opening/closing/copying of contexts 2019-04-01 14:02:39 -04:00
Isaac Connor ed5a448a1d Correct pts on audio frame before sending it to the encoder so that when we flush the encoder the resulting packets have the right pts. 2019-04-01 11:13:14 -04:00
Isaac Connor e6547953b0 fix segfault using old ffmpeg 2019-03-28 09:24:32 -04:00
Isaac Connor 5615cafc19 fix compile on old ffmpeg 2019-03-21 17:50:17 -04:00
Isaac Connor c159dd8d10 cleanup and fix code that assumed H264 2019-03-21 14:13:56 -04:00
Isaac Connor fcb9f76561 Fix out_frame->pts being nothing because we freed in_frame 2019-03-20 16:06:55 -04:00
Isaac Connor 3931baa2b6 fix build on old ffmpeg 2019-03-20 10:21:43 -04:00
Isaac Connor a437c407a7 fix video_out_ctx init so that ffmpeg doesn't complain 2019-03-19 13:17:26 -04:00
Isaac Connor 9b713a489d fix sleep time by using a comparison between the frame display time and the distance between now and when we started playing.
handle infinite fps
2019-03-06 14:50:36 -05:00
Isaac Connor 6c8eac1ac8 Merge branch 'storageareas' into h265 2019-03-06 11:10:01 -05:00
Isaac Connor 73ae3f49ed Merge branch 'master' into storageareas 2019-03-05 11:35:55 -05:00
Isaac Connor b1838de701 test turning off frag_custom 2019-03-05 11:35:16 -05:00
Isaac Connor 4b3519c84a Merge branch 'storageareas' into zma_to_thread 2019-02-18 17:04:42 -05:00
Isaac Connor 5029d7214a Merge branch 'master' into storageareas 2019-02-18 17:00:45 -05:00
Isaac Connor 7d6286d517 Merge branch 'storageareas' into zma_to_thread 2019-02-18 16:23:17 -05:00
Isaac Connor 9996b3e718 Merge branch 'master' into break_videostorage 2019-02-17 12:10:32 -05:00
Isaac Connor 9656032906 spacing 2019-02-15 17:52:51 -05:00
Isaac Connor 96906734b8 add an audio_fifo to handle input audio < 1024 samples per frame 2019-02-15 17:26:30 -05:00
Isaac Connor 4e463c9354 use swr_convert_frame instead of swr_convert 2019-02-14 17:48:58 -05:00
Isaac Connor 281775cc80 try setting out_frame pts from in_frame 2019-02-14 15:54:47 -05:00
Isaac Connor 9e07d5cd17 try setting out_frame pts from in_frame 2019-02-14 15:54:00 -05:00
Isaac Connor a9e2011727 Merge branch 'storageareas' into zma_to_thread 2019-02-13 12:24:38 -05:00
Isaac Connor 060751602b fix missing ; 2019-02-13 10:34:09 -05:00
Isaac Connor d1b3b23c09 Merge branch 'master' into storageareas 2019-02-13 09:42:03 -05:00
Isaac Connor 0bfaf87d27 Mostly code style and whitespacing. However, I do setup more values in the output frame when doing audio resampling 2019-02-12 16:40:27 -05:00
Isaac Connor 3177764db4 spacing 2019-02-12 14:20:33 -05:00
Isaac Connor ed6b22ac06 spacing 2019-02-11 16:29:36 -05:00
Isaac Connor a39b92154c wip 2019-01-17 08:49:48 -05:00
Isaac Connor 87d1390fed Merge branch 'storageareas' into h265 2019-01-16 15:20:17 -05:00
Isaac Connor 5f6bcec4ca Use start_pts instead of start_dts when calculating output pkt.dts. Because start_dts is often lower than start_pts, we can get into a situation where we calculate a dts that is > pts. 2019-01-15 11:35:37 -05:00
Isaac Connor f726666f54 Merge branch 'master' into h265 2019-01-14 12:36:11 -05:00
Isaac Connor 9f8be169f9 set channels and sample rate in output frame. Use new zm_dump_frame() 2019-01-14 10:48:29 -05:00
Isaac Connor c4c6d5b642 switch to swr_convert_frame as a test 2019-01-05 10:15:22 -05:00
Isaac Connor 28dafd5931 Merge branch 'storageareas' into zma_to_thread 2018-12-26 12:02:00 -05:00
Isaac Connor 55e0d82f20 spacing 2018-12-24 11:30:22 -05:00
Andrew Bauer 6eb7892fc7
Merge pull request #2357 from connortechnology/libswresample
Implement libswresample support as an alternative to libavresample, w…
2018-12-20 16:44:06 -06:00
Isaac Connor 7a8beffdcc Merge branch 'master' into storageareas 2018-12-20 15:10:52 -05:00