CN116915924A - Video stitching method and device, electronic equipment, storage medium and vehicle - Google Patents
Video stitching method and device, electronic equipment, storage medium and vehicle Download PDFInfo
- Publication number
- CN116915924A CN116915924A CN202310383128.XA CN202310383128A CN116915924A CN 116915924 A CN116915924 A CN 116915924A CN 202310383128 A CN202310383128 A CN 202310383128A CN 116915924 A CN116915924 A CN 116915924A
- Authority
- CN
- China
- Prior art keywords
- video
- video file
- target
- playing
- time
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000000034 method Methods 0.000 title claims abstract description 87
- 230000008569 process Effects 0.000 claims abstract description 27
- 230000036961 partial effect Effects 0.000 claims abstract description 18
- 238000004590 computer program Methods 0.000 claims description 15
- 238000009877 rendering Methods 0.000 claims description 15
- 230000004048 modification Effects 0.000 claims description 10
- 238000012986 modification Methods 0.000 claims description 10
- 230000001360 synchronised effect Effects 0.000 claims description 7
- 238000010586 diagram Methods 0.000 description 11
- 230000000694 effects Effects 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 230000006870 function Effects 0.000 description 3
- 230000004044 response Effects 0.000 description 3
- 230000005540 biological transmission Effects 0.000 description 2
- 230000001427 coherent effect Effects 0.000 description 2
- 230000009191 jumping Effects 0.000 description 2
- 230000003287 optical effect Effects 0.000 description 2
- 230000002829 reductive effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 230000008859 change Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 230000002441 reversible effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/222—Studio circuitry; Studio devices; Studio equipment
- H04N5/262—Studio circuits, e.g. for mixing, switching-over, change of character of image, other special effects ; Cameras specially adapted for the electronic generation of special effects
- H04N5/265—Mixing
-
- G—PHYSICS
- G07—CHECKING-DEVICES
- G07C—TIME OR ATTENDANCE REGISTERS; REGISTERING OR INDICATING THE WORKING OF MACHINES; GENERATING RANDOM NUMBERS; VOTING OR LOTTERY APPARATUS; ARRANGEMENTS, SYSTEMS OR APPARATUS FOR CHECKING NOT PROVIDED FOR ELSEWHERE
- G07C5/00—Registering or indicating the working of vehicles
- G07C5/08—Registering or indicating performance data other than driving, working, idle, or waiting time, with or without registering driving, working, idle or waiting time
- G07C5/0841—Registering performance data
- G07C5/085—Registering performance data using electronic data carriers
- G07C5/0866—Registering performance data using electronic data carriers the electronic data carrier being a digital video recorder in combination with video camera
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04N—PICTORIAL COMMUNICATION, e.g. TELEVISION
- H04N5/00—Details of television systems
- H04N5/76—Television signal recording
- H04N5/91—Television signal processing therefor
- H04N5/92—Transformation of the television signal for recording, e.g. modulation, frequency changing; Inverse transformation for playback
- H04N5/9201—Transformation of the television signal for recording, e.g. modulation, frequency changing; Inverse transformation for playback involving the multiplexing of an additional signal and the video signal
- H04N5/9202—Transformation of the television signal for recording, e.g. modulation, frequency changing; Inverse transformation for playback involving the multiplexing of an additional signal and the video signal the additional signal being a sound signal
Landscapes
- Engineering & Computer Science (AREA)
- Multimedia (AREA)
- Signal Processing (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Television Signal Processing For Recording (AREA)
Abstract
The disclosure relates to a video stitching method, a device, electronic equipment, a storage medium and a vehicle, and relates to the field of video processing, wherein the method comprises the following steps: unpacking the first video file and playing the unpacked partial data; acquiring the playing end time of the first video file in the process of decapsulating the first video file; the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment; the second video file is a video file with the playing sequence after the first video file; and after the first complete data of the first video file after being unpacked and the second complete data of the second video file after being unpacked are obtained, carrying out data splicing based on the first complete data and the second complete data so as to obtain a spliced video. The embodiment of the disclosure improves the consistency of video playing.
Description
Technical Field
The disclosure relates to the field of video processing, and in particular relates to a video stitching method, a video stitching device, electronic equipment, a storage medium and a vehicle.
Background
In the running process of the vehicle, the vehicle recorder stores video files according to a certain size or duration, for example, video shooting and storing are carried out by taking one minute as a unit, and then a plurality of video clips with one minute length are contained in a storage space after one running is finished. When the complete driving video is reviewed, all video clips are played according to the time sequence, and the following operations are executed when each video clip is played: reading relevant parameters of a video clip, decapsulating the video clip to obtain video data and audio data, decoding the video data through a video decoder, decoding the audio data through an audio decoder to obtain video frames and audio frames, further performing audio-video synchronization and rendering to display the rendered video frames through a display, and outputting the rendered audio frames through a loudspeaker. The next video clip is processed after the current video clip is played, so that in the process of watching back the driving video, the next video clip needs to be waited for being unpacked, a short black screen can appear between two adjacent video clips, the video playing is not consistent when watching back, and the watching experience of a user is affected.
Disclosure of Invention
In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a video stitching method, a device, an electronic apparatus, a storage medium, and a vehicle, which can improve the consistency of video playing.
In order to achieve the above object, the technical solution provided by the embodiments of the present disclosure is as follows:
in a first aspect, the present disclosure provides a video stitching method, the method comprising:
unpacking the first video file and playing the unpacked partial data;
acquiring the playing end time of the first video file in the process of decapsulating the first video file;
the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment, wherein the time interval between the first target moment and the playing end moment is greater than or equal to a preset duration, and the second video file is a video file after the first video file in the playing sequence;
and after the first complete data of the first video file after being unpacked and the second complete data of the second video file after being unpacked are obtained, carrying out data splicing based on the first complete data and the second complete data so as to obtain a spliced video.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulating the second video file at a first target time before the playing end time includes:
and calling a first unpacking thread at a first target time before the playing end time, and starting unpacking processing on the second video file through the first unpacking thread.
As an optional implementation manner of the embodiment of the present disclosure, the encoding formats of the first video file and the second video file are different;
after first complete data after the first video file is unpacked and second complete data after the second video file is unpacked are obtained, data stitching is performed based on the first complete data and the second complete data to obtain a stitched video, and the method comprises the following steps:
after first complete data after the first video file is unpacked and second complete data after the second video file is unpacked are obtained, decoding the first complete data and the second complete data through video decoders and audio decoders corresponding to different coding formats respectively to obtain a first video frame and a first audio frame which carry first timestamp information and a second video frame and a second audio frame which carry second timestamp information;
Splicing the first video frame and the second video frame to obtain a spliced video frame based on the first timestamp information and the second timestamp information, and splicing the first audio frame and the second audio frame to obtain a spliced audio frame;
and performing audio and video synchronous processing and rendering processing on the spliced video frames and the spliced audio frames to obtain spliced video.
As an optional implementation manner of the embodiment of the present disclosure, after obtaining first complete data after decapsulating a first video file and second complete data after decapsulating a second video file, performing data splicing based on the first complete data and the second complete data to obtain a spliced video, including:
decoding the first complete data through a first decoder to obtain the decoding end time of decoding the first complete data;
starting to decode the second complete data through a second decoder at a second target time before the decoding end time, wherein the time interval between the second target time and the decoding end time is greater than or equal to a preset duration;
and performing data splicing on the decoded first complete data and the decoded second complete data to obtain a spliced video.
As an optional implementation manner of the embodiment of the present disclosure, before the decapsulating the first video file and playing the decapsulated partial data, the method further includes:
Acquiring a plurality of video files to be played, wherein the plurality of video files comprise a first video file and a second video file;
and reading video parameters of the first video file and the second video file, wherein the video parameters comprise playing time length and encoding format.
As an alternative implementation of the embodiments of the present disclosure, the method further includes:
when the unpacked partial data is played, responding to a playing progress modification instruction, and determining a time to be played according to the current playing progress and the target playing progress;
acquiring the total playing time length of a plurality of video files;
positioning a target frame of a target video file according to the time to be played and the total playing time, wherein the target video file is any one of a plurality of video files;
and starting from the target frame of the target video file, performing decapsulation processing, decoding processing and rendering processing on the target video file.
As an optional implementation manner of the embodiment of the present disclosure, positioning a target frame of a target video file according to a time to be played and a total playing duration includes:
determining a target video file according to the time to be played and the total playing time, wherein the time to be played is in the playing time range of the target video file;
Calculating a frame offset according to the playing start time and the time to be played of the target video file;
and positioning the target frame according to the frame offset and the initial frame of the target video file.
In a second aspect, the present disclosure provides a video stitching apparatus comprising:
the unpacking module is used for unpacking the first video file and playing the unpacked partial data; acquiring the playing end time of the first video file in the process of decapsulating the first video file; the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment, wherein the time interval between the first target moment and the playing end moment is greater than or equal to a preset duration, and the second video file is a video file after the first video file in the playing sequence;
and the splicing module is used for carrying out data splicing based on the first complete data and the second complete data after obtaining the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked so as to obtain a spliced video.
As an optional implementation manner of the disclosed embodiment, the decapsulating module is specifically configured to invoke a first decapsulating thread at a first target time before a play end time, and start decapsulating the second video file by using the first decapsulating thread.
As an optional implementation manner of the embodiment of the present disclosure, the encoding formats of the first video file and the second video file are different;
the splicing module is specifically configured to decode the first complete data and the second complete data through video decoders and audio decoders corresponding to different encoding formats after obtaining first complete data after the first video file is unpacked and second complete data after the second video file is unpacked, so as to obtain a first video frame and a first audio frame carrying first timestamp information, and a second video frame and a second audio frame carrying second timestamp information;
splicing the first video frame and the second video frame to obtain a spliced video frame based on the first timestamp information and the second timestamp information, and splicing the first audio frame and the second audio frame to obtain a spliced audio frame;
and performing audio and video synchronous processing and rendering processing on the spliced video frames and the spliced audio frames to obtain spliced video.
As an optional implementation manner of the embodiment of the present disclosure, the splicing module is specifically configured to decode, by using a first decoder, first complete data, to obtain a decoding end time of decoding the first complete data;
Starting to decode the second complete data through a second decoder at a second target time before the decoding end time, wherein the time interval between the second target time and the decoding end time is greater than or equal to a preset duration;
and performing data splicing on the decoded first complete data and the decoded second complete data to obtain a spliced video.
As an optional implementation manner of the disclosed embodiment, the decapsulation module is further configured to obtain, before decapsulating the first video file and playing the decapsulated partial data, a plurality of video files to be played, including the first video file and the second video file;
and reading video parameters of the first video file and the second video file, wherein the video parameters comprise playing time length and encoding format.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulating module is further configured to, when playing the decapsulated portion of data, determine, in response to a play progress modification instruction, a time to be played according to a current play progress and a target play progress;
acquiring the total playing time length of a plurality of video files;
positioning a target frame of a target video file according to the time to be played and the total playing time, wherein the target video file is any one of a plurality of video files;
And starting from the target frame of the target video file, performing decapsulation processing, decoding processing and rendering processing on the target video file.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulating module is specifically configured to determine, according to a time to be played and a total playing duration, a target video file, where the time to be played is within a playing time range of the target video file;
calculating a frame offset according to the playing start time and the time to be played of the target video file;
and positioning the target frame according to the frame offset and the initial frame of the target video file.
In a third aspect, the present disclosure provides an electronic device comprising: a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor implements the video stitching method of the first aspect or any of its alternative embodiments.
In a fourth aspect, there is provided a computer-readable storage medium comprising: the computer readable storage medium has stored thereon a computer program which, when executed by a processor, implements the video stitching method according to the first aspect or any optional implementation thereof.
In a fifth aspect, there is provided a vehicle comprising a video stitching apparatus as described in the second aspect, or an electronic device as described in the third aspect. The vehicle is used for executing the video stitching method provided by any embodiment of the present disclosure.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
the embodiment of the disclosure provides a video splicing method, a video splicing device, electronic equipment, a storage medium and a vehicle, wherein the method firstly performs decapsulation processing on a first video file and plays partial decapsulated data; in the process of carrying out unpacking processing on the first video file, acquiring the playing end time of the first video file, and further, before the playing end time, and at a first target time with a time interval greater than or equal to a preset duration, starting unpacking processing on a second video file after the first video file in a playing sequence so as to start unpacking the second video file after the first video file when the first video file is played, advancing the time for starting unpacking the second video file without waiting for the unpacking of the first video file to be finished and then starting unpacking the second video file; further, after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, data are spliced based on the first complete data and the second complete data, so that spliced video is obtained, the spliced video contains the complete contents of the first video file and the second video file, the time sequence is coherent, the condition of black screen is avoided during playing, the consistency of video playing is improved, and the viewing experience of a user is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic flow chart of a video stitching method according to an embodiment of the present disclosure;
fig. 2 is a timing diagram of a play end time and a first target time according to an embodiment of the present disclosure;
fig. 3 is a schematic structural diagram of a video stitching device according to an embodiment of the present disclosure;
fig. 4 is a block diagram of an electronic device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
At present, a vehicle recorder installed on a vehicle stores videos recorded in a driving process according to a certain size or a certain time period, so that the complete videos recorded in a driving process can be divided into a plurality of video clips. When a user needs to watch the video recorded by the automobile data recorder, all video clips are played in sequence. Each video clip independently executes a decapsulation flow, a decoding flow and a rendering flow so as to realize final complete playing, and after one video clip is played, the next video clip needs to be waited for to start decapsulation, so that a short black screen exists between two video clips in the video playing process, which leads to intermittent playing of the video, has poor continuity and affects the viewing experience of a user. In addition, when the user needs to watch the video recorded by the automobile data recorder, the video clips are independent, and the user cannot jump to other video clips except the video clip currently being played in a mode of dragging the progress bar, so that the user is difficult to locate to a desired key picture.
In order to solve some or all of the above technical problems, an embodiment of the present disclosure provides a video stitching method, a device, an electronic apparatus, a storage medium, and a vehicle, where the method includes: firstly, unpacking a first video file and playing a part of unpacked data, and in the process of unpacking the first video file, acquiring the playing end time of the first video file, so that the first target time interval before the playing end time is longer than or equal to the preset time length, unpacking a second video file after the first video file in the playing order is started, unpacking the second video file after the first video file is started while the first video file is played, and starting unpacking in advance, so that the waiting time length is reduced, and the condition of black screen is avoided; further, after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, data is spliced based on the first complete data and the second complete data, so that spliced video is obtained, the spliced video contains the complete video contents of the first video file and the second video file and is consecutive in time sequence, continuity of video playing can be guaranteed, and viewing experience of a user is improved.
The operating system of the vehicle terminal may include Android (Android), a mobile operating system (iOS) developed by apple corporation, an operating system (Windows) developed by microsoft corporation in the united states, and the like, which is not limited by the embodiments of the present disclosure.
It should be noted that, the protection scope of a video stitching method according to the embodiments of the present disclosure is not limited to the order of execution of the steps listed in the embodiments, and all the schemes implemented by adding or removing steps and replacing steps according to the prior art according to the principles of the present disclosure are included in the protection scope of the present disclosure.
As shown in fig. 1, fig. 1 is a flowchart of a video stitching method according to an embodiment of the present disclosure, and the method includes the following steps S101 to S104:
s101, performing decapsulation processing on the first video file, and playing the decapsulated partial data.
Wherein the first video file is any one of a plurality of video files to be played. The plurality of video files to be played comprise: the video clips recorded by the automobile data recorder and stored in a file form, and/or the video clips recorded by the user at the self-time, which are not particularly limited in the disclosure; the file sizes of the plurality of video files are the same, or the playing time lengths are the same. The first video file includes: first video data and first audio data.
In some embodiments, before the first video file is unpacked, the complete video is split into a plurality of video files for storage, and when the complete video needs to be played, a plurality of video files to be played are obtained, wherein the plurality of video files to be played are a plurality of video files corresponding to the complete video, and include the first video file and the second video file; the number of the plurality of video files is not particularly limited in the present disclosure, and other video files except the first video file and the second video file in the plurality of video files may also implement the video splicing method provided in the present disclosure to achieve the same effect, which is not described in detail herein.
Among a plurality of video files to be played, the first video file and the second video file are arranged in sequence according to the playing sequence, and the second video file is the next video file of the first video file in time sequence; after the plurality of video files are acquired, video parameters of the first video file are read, and video parameters of the second video file are read, the video parameters including a playback time length of the video file and an encoding format, such as a highly compressed digital video codec standard (h.264). And obtaining processing parameters required by the subsequent steps, determining the moment when to start to unpack the second video file according to the playing time of the first video file, and determining the subsequent decoding mode according to the encoding format.
Decapsulation is the process of reading encoded compressed video and audio data from the encapsulated format, respectively.
In some embodiments, the first video file is decapsulated to obtain first audio data and first video data in the first video file. It will be appreciated that it takes some time to unpack the entire first video file, and that the present disclosure is directed to partial data in the unpacked first video file, the method comprises the steps of partial first video data and first audio data, decoding, audio and video synchronization, rendering and the like, so that the first video file is started and played quickly, loading is realized while playing, and starting and playing waiting time is shortened.
In some embodiments, a second decapsulation thread is called to perform decapsulation processing on a first video file, where the second decapsulation thread is a decapsulation thread corresponding to the first video file, and the disclosure calls different decapsulation threads when performing decapsulation processing on different video files, and calls the first decapsulation thread when performing decapsulation on the second video file, so that the decapsulation processing on different video files is relatively independent without interfering with each other.
According to the embodiment, the plurality of video files to be played are obtained, the first video file relatively ahead in time sequence is subjected to unpacking processing, and the unpacked partial data are played, so that the first video file is unpacked and played at the same time, the first video file does not need to be played after being completely loaded, the starting time of the first video file is shortened, the user can quickly play the first video file when watching the complete driving video, and the watching experience of the user is improved.
The video splicing method provided by the embodiment of the disclosure further supports generating a playing progress modification instruction to jump to a target frame to continue playing according to the operation of dragging the video progress bar by a user. The embodiment of the disclosure provides an implementation manner, after partial data which are unpacked are played, the first video file is displayed, a playing progress modification instruction is responded, a time to be played is determined according to the current playing progress and a target playing progress indicated by the playing progress modification instruction, wherein the time to be played takes the playing start time of the first video file as a reference, and then total playing time of a plurality of video files to be played is obtained, and further, a target frame of the target video file is positioned according to the time to be played and the total playing time.
Optionally, in the process of positioning the target frame to the target video file according to the time to be played and the total playing time, the target video file is determined according to the time to be played and the total playing time. Specifically, the first video file is taken as a reference, and the time to be played is compared with the time of starting and ending playing of the first video file.
The following description will be given for (1) the time to be played is smaller than the play start time of the first video file, (2) the time to be played is larger than the play start time of the first video file and smaller than the play end time of the first video file, and (3) the time to be played is larger than the play end time of the first video file, where these three cases are respectively:
(1) The time to be played is smaller than the play starting time of the first video file
When the time to be played is smaller than the play start time of the first video file, it means that a certain frame of a certain video file before the first video file needs to be jumped to be played, and further, according to the play time range of the video file before the first video file, the target video file where the time to be played is located is determined, and the time to be played is within the play time range of the target video file, and it can be understood that the time to be played is greater than the play start time of the target video file and less than the play end time of the target video file.
The target video file is a video file before the first video file, and if the target video file is already played, video frames and audio frames corresponding to the target video file are spliced before the first video file. According to the playing starting time and the waiting time of the target video file, calculating frame offset, including video frame offset and audio frame offset, so as to locate the target frame in the target file according to the initial frame and the frame offset of the target video file for playing, specifically, locating the target video frame according to the initial video frame and the video frame offset of the target video file, locating the target audio frame according to the initial audio frame and the audio frame offset of the target video file, further performing audio and video synchronous processing and rendering processing on the target video frame and the target audio frame, and outputting the target video frame through a display, wherein the audio data output the target audio frame is displayed on a user side as jumping to the target frame for playing in response to a playing progress modification instruction.
If the target video file is not played, or the target frame positioned according to the playing starting time and the time to be played of the target video file is not played, that is, the target video file is not loaded or the target video file is not loaded after the target frame, under the condition that the target frame is positioned, the target video file is subjected to unpacking processing, decoding processing and rendering processing from the target frame of the target video file.
(2) The time to be played is larger than the playing start time of the first video file and smaller than the playing end time of the first video file
And when the time to be played is larger than the playing start time of the first video file and smaller than the playing end time of the first video file, indicating that a certain frame in the first video file needs to be jumped to play, and taking the first video file as a target video file. And calculating a frame offset according to the playing start time of the first video file and the time to be played, then shifting from the starting frame of the first video file according to the frame offset, positioning to the target frame of the first video file, and continuing playing from the target frame of the first video file.
(3) The time to be played is larger than the playing end time of the first video file
And when the time to be played is greater than the playing end time of the first video file, the condition that a certain frame of a certain video file after the first video file needs to be jumped to be played is indicated, and then the target video file at the time to be played is determined according to the playing time range of the video file after the first video file.
The target video file is a video file subsequent to the first video file. Unpacking and decoding the target video file to obtain frame data contained in the target video file; then, according to the playing starting time and the waiting time of the target video file, calculating frame offset, including video frame offset and audio frame offset, so as to position the initial frame of the target video file and the frame offset to the target frame in the target file for playing, specifically, positioning the initial frame and the video frame offset of the target video file to the target video frame, and positioning the initial audio frame and the audio frame offset of the target video file to the target audio frame; further, the target video frame and the target audio frame are subjected to audio-video synchronous processing and rendering processing so as to be displayed on a user side as jumping to the target frame for playing in response to the playing progress modification instruction.
According to the embodiment, the first video file is taken as a reference, and the playing start time and the playing end time of each video file can be obtained according to the playing time length and the playing sequence of each video file, so that when a user adjusts the video playing progress by dragging the video progress bar, the playing time is determined according to the current playing progress and the target playing progress, the time to be played is compared with the playing start time and the playing end time of each video file, so that the target video file is positioned, the target frame in the target video file is positioned according to the playing start time and the time to be played, the target video file and the video files behind the target frame are played from the target frame, the video playing mode of dragging the progress bar to the target frame is supported, the requirement that the user selectively jumps to a key picture for watching is met, and the user experience is improved.
S102, acquiring the playing end time of the first video file in the process of decapsulating the first video file.
In some embodiments, the playing start time is recorded while playing the unpackaged part of the data; and calculating the playing end time of the first video file according to the read playing time of the first video file, thereby executing step S103.
For example, the playing start time is t0, the playing duration of the first video file is Δt1, and the playing end time of the first video file is t1=t0+Δt1.
S103, at a first target time before the playing end time, the second video file is unpacked.
The time interval between the first target time and the playing end time is greater than or equal to the preset duration. The preset duration is a preset time interval, typically set to 15 seconds, which is not particularly limited by the present disclosure.
Along the above example, the playing end time is t1, the preset duration is Δt, and the first target time is t=t1- Δt.
Fig. 2 is a timing diagram of a playback end time and a first target time according to an embodiment of the disclosure. The first target time t is a time of a preset duration deltat before the play end time t 1; it can be understood that, after the first target time t, the playing of the first target video file ends after the preset duration Δt.
In some embodiments, a first decapsulation thread is invoked at a first target time, and decapsulation of the second video file is initiated by the first decapsulation thread. When the method is understood, when the first decapsulation thread is called to start the decapsulation processing of the second video file, the second decapsulation thread also performs the decapsulation processing of the rest part of data in the first video file, and the two decapsulation threads simultaneously perform the decapsulation processing within a preset duration without mutual interference. Compared with the prior art that the single decapsulation thread is utilized to decapsulate the video files in sequence, the method and the device for decapsulating the second video files advance, decapsulating the second video files through the first decapsulation thread is started at the first target moment when the first video files are decapsulated through the second decapsulation thread, waiting time for decapsulating the second video files is shortened, the second video files are started to be played immediately after the first video files are played on the user side, black screen conditions are avoided, and viewing experience of the user is improved.
S104, after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, data stitching is carried out based on the first complete data and the second complete data, so that a stitched video is obtained.
In some embodiments, after the first video file is unpacked, first complete data is obtained, where the first complete data includes first audio data and first video data, and decoding processing is further performed on the first complete data. The first video data is decoded by a video decoder to obtain a first video frame, and the first audio data is decoded by an audio decoder to obtain a first audio frame. If the encoding format of the second video file is the same as that of the first video file, the audio decoder and the video decoder may be multiplexed to decode the second complete data after the first video file is decapsulated, that is, the second video data is decoded by the video decoder to obtain a second video frame, and the second audio data is decoded by the audio decoder to obtain a second audio frame. It can be understood that, from the time dimension, the first video file completes the decapsulation process, then the first complete data after the decapsulation of the first video file is sent to the video decoder and the audio decoder, and then after the decapsulation process of the second video file is completed, the second complete data is sent to the same video decoder and the audio decoder for decoding.
In some embodiments, if the second video file is in the same coding format as the first video file, the decoding process may be performed on the first complete data and the second complete data by using a plurality of video decoders and audio decoders. Optionally, after the first video file is subjected to the decapsulation processing to obtain first complete data, the first complete data is decoded by a first decoder, and a decoding end time of decoding the first complete data is calculated. In calculating the decoding end time, the decoding end time is predicted according to the recorded decoding start time, the data amount of the first complete data and the decoding rate of the first decoder. And then, at a second target moment before the decoding end moment, the second complete data after the second video file is unpacked is decoded by a second decoder, and the time interval between the second target moment and the decoding end moment is longer than or equal to a preset duration, so that the second complete data is decoded before the decoding processing of the first complete data is finished, the second complete data is not required to be decoded after the first complete data is decoded and is idle, and the decoding waiting time of the second complete data is reduced by starting work sequentially by a plurality of decoders.
It is emphasized that the first complete data and the second complete data still keep a sequence in time, when decoding, the first complete data is decoded first, then at the second target moment, when the first complete data is not completely decoded, the second complete data is decoded, the first complete data and the second complete data are decoded and carry identification information and timestamp information, so that the audio frames and the video frames obtained by decoding at the same moment are distinguished, accurate splicing is realized in the subsequent process, and the video playing time sequence is accurate and consistent.
In the case that the encoding formats of the second video file and the first video file are different, that is, the encoding formats of the first complete data and the second complete data obtained after the decapsulation processing are different, the embodiment of the disclosure provides an implementation manner: after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, the first complete data and the second complete data are decoded respectively through video decoders and audio decoders with different coding formats.
Optionally, the encoding format of the first video file is a first format, and the encoding format of the second video file is a second format, then decoding, by a first format video decoder, the first video data included in the first complete data to obtain a first video frame carrying the first timestamp information, and decoding, by a first format audio decoder, the first audio data included in the first complete data to obtain a first audio frame carrying the first timestamp information; and decoding the second video data included in the second complete data by the second format video decoder to obtain a second video frame carrying the second timestamp information, and decoding the second audio data included in the second complete data by the second format audio decoder to obtain a second audio frame carrying the second timestamp information.
After the first complete data and the second complete data are respectively decoded to obtain a first video frame and a first audio frame which carry first timestamp information, and a second video frame and a second audio frame which carry second timestamp information, splicing the first video frame and the second video frame to obtain a spliced video frame and splicing the first audio frame and the second audio frame to obtain a spliced audio frame based on the first timestamp information and the second timestamp information; the first time stamp information and the second time stamp information can ensure the play order of the first video frame, the second video frame and the first audio frame, wherein the first video frame is arranged before the second video frame in time sequence, and the first audio frame is arranged before the second audio frame in time sequence. And then performing audio and video synchronous processing and rendering processing on the spliced audio frames and the spliced video frames to obtain spliced video.
In summary, an embodiment of the present disclosure provides a video stitching method, which performs decapsulation processing on a first video file, and plays a portion of decapsulated data; in the process of carrying out the unpacking processing on the first video file, acquiring the playing end time of the first video file, and then, at a first target time before the playing end time, starting to carry out the unpacking processing on a second video file after the first video file in the playing sequence so as to start to unpack the second video file after the first video file when the first video file is played, advancing the time for starting to unpack the second video file without waiting for the unpacking of the first video file to finish and then starting to unpack the second video file; further, after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, data is spliced based on the first complete data and the second complete data, so that spliced video is obtained, the spliced video contains the complete contents of the first video file and the second video file, the time sequence is coherent, the condition of black screen is avoided during playing, the consistency of video playing is improved, and the viewing experience of a user is further improved.
As shown in fig. 3, fig. 3 is a schematic structural diagram of a video stitching device according to an embodiment of the present disclosure, where the device includes:
the decapsulation module 301 is configured to decapsulate the first video file and play the decapsulated partial data; acquiring the playing end time of the first video file in the process of decapsulating the first video file; the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment, wherein the time interval between the first target moment and the playing end moment is greater than or equal to a preset duration, and the second video file is a video file after the first video file in the playing sequence;
and the splicing module 302 is configured to perform data splicing based on the first complete data and the second complete data after obtaining the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked, so as to obtain a spliced video.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulating module 301 is specifically configured to invoke a first decapsulating thread at a first target time before a play end time, and start decapsulating the second video file by using the first decapsulating thread.
As an optional implementation manner of the embodiment of the present disclosure, the encoding formats of the first video file and the second video file are different;
the splicing module 302 is specifically configured to decode, after obtaining first complete data after the first video file is unpacked and second complete data after the second video file is unpacked, the first complete data and the second complete data through video decoders and audio decoders corresponding to different encoding formats, respectively, to obtain a first video frame and a first audio frame that carry first timestamp information, and a second video frame and a second audio frame that carry second timestamp information;
splicing the first video frame and the second video frame to obtain a spliced video frame based on the first timestamp information and the second timestamp information, and splicing the first audio frame and the second audio frame to obtain a spliced audio frame;
and performing audio and video synchronous processing and rendering processing on the spliced video frames and the spliced audio frames to obtain spliced video.
As an optional implementation manner of the embodiment of the present disclosure, the splicing module 302 is specifically configured to decode, by using a first decoder, the first complete data, and obtain a decoding end time of decoding the first complete data;
Starting to decode the second complete data through a second decoder at a second target time before the decoding end time, wherein the time interval between the second target time and the decoding end time is greater than or equal to a preset duration; and performing data splicing on the decoded first complete data and the decoded second complete data to obtain a spliced video.
As an optional implementation manner of the disclosed embodiment, the decapsulation module 301 is further configured to obtain, before performing decapsulation processing on the first video file and playing the decapsulated partial data, a plurality of video files to be played, including the first video file and the second video file;
and reading video parameters of the first video file and the second video file, wherein the video parameters comprise playing time length and encoding format.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulating module 301 is further configured to, when playing the decapsulated portion of data, respond to a play progress modification instruction, and determine a time to be played according to a current play progress and a target play progress;
acquiring the total playing time length of a plurality of video files;
positioning a target frame of a target video file according to the time to be played and the total playing time, wherein the target video file is any one of a plurality of video files;
And starting from the target frame of the target video file, performing decapsulation processing, decoding processing and rendering processing on the target video file.
As an optional implementation manner of the embodiment of the present disclosure, the decapsulation module 301 is specifically configured to determine, according to a time to be played and a total playing duration, a target video file, where the time to be played is within a playing time range of the target video file;
calculating a frame offset according to the playing start time and the time to be played of the target video file;
and positioning the target frame according to the frame offset and the initial frame of the target video file.
As shown in fig. 4, fig. 4 is a block diagram of an electronic device according to an embodiment of the present disclosure, where the embodiment of the present disclosure provides an electronic device, the electronic device includes: a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor, implements the respective processes of the video stitching method in the method embodiments described above. And the same technical effects can be achieved, and in order to avoid repetition, the description is omitted here.
The embodiments of the present disclosure provide a computer readable storage medium, on which a computer program is stored, where the computer program when executed by a processor implements each process of the video stitching method in the foregoing method embodiments, and the same technical effects can be achieved, so that repetition is avoided, and no further description is given here.
The computer readable storage medium may be a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, an optical disk, or the like.
The embodiment of the disclosure provides a vehicle, which comprises the video stitching device or the electronic equipment. The vehicle is used for executing the video stitching method provided by any embodiment of the present disclosure.
The embodiments of the present disclosure provide a computer program product, where the computer program product stores a computer program, and when the computer program is executed by a processor, the computer program realizes each process of the vehicle-based multimedia data synchronization method in the above method embodiment, and the same technical effects can be achieved, so that repetition is avoided, and no description is repeated here.
It will be appreciated by those skilled in the art that embodiments of the present disclosure may be provided as a method, system, or computer program product. Accordingly, the present disclosure may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media having computer-usable program code embodied therein.
In the several embodiments provided in the present disclosure, it should be understood that the disclosed apparatus and method may be implemented in other manners. The apparatus embodiments described above are merely illustrative, for example, flow diagrams and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In this disclosure, the processor may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), off-the-shelf programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
In the present disclosure, memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash RAM, in a computer readable medium. Memory is an example of a computer-readable medium.
In the present disclosure, computer readable media include both permanent and non-permanent, removable and non-removable storage media. Storage media may embody any method or technology for storage of information, which may be computer readable instructions, data structures, program modules, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Disks (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (11)
1. A method of video stitching, comprising:
unpacking the first video file and playing the unpacked partial data;
acquiring the playing end time of the first video file in the process of decapsulating the first video file;
the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment, wherein the time interval between the first target moment and the playing end moment is greater than or equal to a preset duration, and the second video file is a video file after the first video file in the playing sequence;
and after the first complete data of the first video file after being unpacked and the second complete data of the second video file after being unpacked are obtained, performing data splicing based on the first complete data and the second complete data to obtain a spliced video.
2. The method of claim 1, wherein the decapsulating the second video file starts at a first target time before the playback end time, comprising:
and calling a first unpacking thread at a first target time before the playing end time, and starting unpacking processing on the second video file through the first unpacking thread.
3. The method of claim 2, wherein the encoding formats of the first video file and the second video file are different;
after the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked are obtained, performing data stitching based on the first complete data and the second complete data to obtain a stitched video, wherein the method comprises the following steps:
after first complete data after the first video file is unpacked and second complete data after the second video file is unpacked are obtained, decoding the first complete data and the second complete data through video decoders and audio decoders corresponding to different coding formats respectively to obtain a first video frame and a first audio frame which carry first timestamp information and a second video frame and a second audio frame which carry second timestamp information;
splicing the first video frame and the second video frame based on the first timestamp information and the second timestamp information to obtain a spliced video frame, and splicing the first audio frame and the second audio frame to obtain a spliced audio frame;
And performing audio and video synchronous processing and rendering processing on the spliced video frames and the spliced audio frames to obtain the spliced video.
4. The method of claim 1, wherein after obtaining the first complete data of the first video file after being unpacked and the second complete data of the second video file after being unpacked, performing data stitching based on the first complete data and the second complete data to obtain a stitched video, comprising:
decoding the first complete data through a first decoder to obtain a decoding end time for decoding the first complete data;
starting to decode the second complete data by a second decoder at a second target time before the decoding end time, wherein a time interval between the second target time and the decoding end time is greater than or equal to the preset duration;
and performing data splicing on the decoded first complete data and the decoded second complete data to obtain the spliced video.
5. The method of claim 1, wherein before decapsulating the first video file and playing the decapsulated partial data, the method further comprises:
Acquiring a plurality of video files to be played, wherein the plurality of video files comprise a first video file and a second video file;
and reading video parameters of the first video file and the second video file, wherein the video parameters comprise playing time length and encoding format.
6. The method of claim 5, wherein the method further comprises:
when the unpacked partial data is played, responding to a playing progress modification instruction, and determining a time to be played according to the current playing progress and the target playing progress;
acquiring the total playing time length of the plurality of video files;
positioning a target frame of a target video file according to the time to be played and the total playing time, wherein the target video file is any one of the plurality of video files;
and starting from the target frame of the target video file, performing decapsulation processing, decoding processing and rendering processing on the target video file.
7. The method of claim 6, wherein locating the target frame of the target video file according to the time to play and the total duration of play comprises:
determining the target video file according to the time to be played and the total playing duration, wherein the time to be played is in the playing time range of the target video file;
Calculating a frame offset according to the playing start time and the waiting time of the target video file;
and positioning the target frame according to the frame offset and the initial frame of the target video file.
8. A video stitching device, comprising:
the unpacking module is used for unpacking the first video file and playing the unpacked partial data; acquiring the playing end time of the first video file in the process of decapsulating the first video file; the method comprises the steps of starting to unpack a second video file at a first target moment before the playing end moment, wherein the time interval between the first target moment and the playing end moment is greater than or equal to a preset duration, and the second video file is a video file after the first video file in the playing sequence;
and the splicing module is used for carrying out data splicing based on the first complete data and the second complete data after obtaining the first complete data after the first video file is unpacked and the second complete data after the second video file is unpacked so as to obtain a spliced video.
9. An electronic device, comprising: a processor, a memory and a computer program stored on the memory and executable on the processor, which when executed by the processor implements the video stitching method of any one of claims 1-7.
10. A computer-readable storage medium, comprising: the computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements the video stitching method according to any of claims 1-7.
11. A vehicle, characterized by comprising:
a video stitching device according to claim 8 or an electronic device according to claim 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310383128.XA CN116915924A (en) | 2023-04-11 | 2023-04-11 | Video stitching method and device, electronic equipment, storage medium and vehicle |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310383128.XA CN116915924A (en) | 2023-04-11 | 2023-04-11 | Video stitching method and device, electronic equipment, storage medium and vehicle |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116915924A true CN116915924A (en) | 2023-10-20 |
Family
ID=88361610
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310383128.XA Pending CN116915924A (en) | 2023-04-11 | 2023-04-11 | Video stitching method and device, electronic equipment, storage medium and vehicle |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116915924A (en) |
-
2023
- 2023-04-11 CN CN202310383128.XA patent/CN116915924A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10939069B2 (en) | Video recording method, electronic device and storage medium | |
US20070110408A1 (en) | Device for displaying boot animation of optical disc player and method thereof | |
CN110418183B (en) | Audio and video synchronization method and device, electronic equipment and readable medium | |
CN112929733B (en) | Video preview playing method and device | |
CN112601127A (en) | Video display method and device, electronic equipment and computer readable storage medium | |
CN117178557A (en) | Method and apparatus for timing and event triggered updating in a scene | |
CN109068165A (en) | A kind of Dynamic Graph display methods and device | |
CN105578224A (en) | Multimedia data acquisition method, device, smart television and set-top box | |
CN116915924A (en) | Video stitching method and device, electronic equipment, storage medium and vehicle | |
WO2006054244A2 (en) | Method and apparatus for frame accurate editing audio-visual streams | |
CN114339289B (en) | Video playing processing method | |
CN114501126B (en) | Video playing method, system and storage medium | |
JP2005167689A (en) | Image reproducing apparatus | |
CN106792105B (en) | Playing processing method and device for optical disk image ISO audio/video file and television | |
CN102449695B (en) | Video information reproducing method and video information reproducing device | |
CN112486489B (en) | Rendering method and device of auction component | |
CN111629255B (en) | Audio and video recording method and device, computer equipment and storage medium | |
CN111813994B (en) | Data processing and file playback method and device based on interactive whiteboard | |
CN101964203B (en) | Recording playback apparatus, recording-playback control method, and editing system | |
WO2012029252A1 (en) | Information processing apparatus, information processing method, and program | |
US8712220B2 (en) | Video reproducing apparatus and video reproducing method | |
JP2009152946A (en) | Video reproducing apparatus | |
CN114697722A (en) | Video playing method and device, electronic equipment and storage medium | |
CN113949766A (en) | Mobile terminal screen recording processing method and device | |
CN115272536A (en) | Animation playing method and device and electronic equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |