Android Audio Video Depth 21 FFmpeg video cut

Source: Internet
Author: User
Tags gettext

Video clipping I accidentally found that the last video compression code was able to run FFmpeg video cut commands, but could not do video merge commands because the TXT file could not read the path of several videos recorded.

I'm going to talk about the video cutting process, not the code, just the log, after all, I'm not sure where the code goes.
? Last project Address
Https://github.com/979451341/FFmpegCompress

First we need to change the project code to change the parameters passed in the RunCommand function to the following

                int ret = FFmpegNativeBridge.runCommand(new String[]{"ffmpeg",                        "-ss", "00:00:00",                        "-t","00:00:10",                        "-i", et_input.getText().toString(),                        "-vcodec", "copy",                        "-acodec", "copy",                        et_output.getText().toString()});

The beginning is the parse command.

Read start time, that is-ss back "00:00:00", you can also write 0

03-10 14:19:55.430 21706-22256/org.voiddog.ffmpeg d/tag:splitting the commandline.
03-10 14:19:55.430 21706-22256/org.voiddog.ffmpeg d/tag:reading option '-ss ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as option ' SS ' (set the start time offset) with argument ' 00:00:00 '.

The read end time is the time after the-T, and you can write 10

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:reading option '-t ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as option ' t ' (Record or transcode "duration" Seconds of Audio/video) with argument ' 00:00:10 '.

Setting the input video file is the first 10 seconds of cutting this video file to form a new video

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:reading option '-I ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as input url with argument '/storage/emulated/0/ Pauserecorddemo/video/video.mp4 '.

Copy Video stream

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:reading option '-vcodec ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as option ' Vcodec ' (Force video codec (' Copy ' to copy str EAM) with argument ' copy '.

Copy Audio stream

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:reading option '-acodec ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as option ' acodec ' (Force audio Codec (' copy ' to copy str EAM) with argument ' copy '.

The final option is to select the output video file path

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:reading option '/storage/emulated/0/pauserecorddemo/video/ Compress6.mp4 ' ...
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:matched as output URL.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:finished splitting the commandline.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:parsing a group of Options:global.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:successfully parsed a group of options.

Start creating and configuring output video files

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:parsing A group of Options:input Url/storage/emulated/0/pauser Ecorddemo/video/video.mp4.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:applying option SS (set the start time offset) with argument 00:0 0:00.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:applying option T (Record or transcode "duration" Seconds of Audi O/video) with argument 00:00:10.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:successfully parsed a group of options.

and open it.

03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:opening An input file:/storage/emulated/0/pauserecorddemo/ Video/video.mp4.
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:opening '/storage/emulated/0/pauserecorddemo/video/ Video.mp4 ' for reading
03-10 14:19:55.431 21706-22256/org.voiddog.ffmpeg d/tag:setting default Whitelist ' File,crypto '
03-10 14:19:55.434 21706-22256/org.voiddog.ffmpeg D/tag:format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score= 100
03-10 14:19:55.434 21706-22256/org.voiddog.ffmpeg d/tag:iso:file Type Major brand:mp42

Parse output video file's head, don't know what to use

03-10 14:19:55.441 21706-22256/org.voiddog.ffmpeg d/tag:stts:0 ctts:7507, ctts_index:0, ctts_count:699
03-10 14:19:55.441 21706-22256/org.voiddog.ffmpeg d/tag:stts:3753 ctts:7507, ctts_index:0, ctts_count:699
03-10 14:19:55.441 21706-22256/org.voiddog.ffmpeg d/tag:stts:7507 ctts:7507, ctts_index:0, ctts_count:699
03-10 14:19:55.441 21706-22256/org.voiddog.ffmpeg d/tag:stts:11260 ctts:15015, Ctts_index:1, ctts_count:699
03-10 14:19:55.441 21706-22256/org.voiddog.ffmpeg d/tag:stts:15014 ctts:7508, Ctts_index:2, ctts_count:699

Get the encoder, and get the media format information for the input video file

03-10 14:19:55.600 21706-22256/org.voiddog.ffmpeg d/tag:parsing Mediaformat {image-data=java.nio.heapbytebuffer[pos =0 lim=104 cap=104], Mime=video/raw, Crop-top=0, crop-right=1279, slice-height=720, color-format=21, height=720, width= 1280x720, crop-bottom=719, crop-left=0, stride=1280}
03-10 14:19:55.601 21706-22256/org.voiddog.ffmpeg i/tag:output crop parameters top=0 bottom=719 left=0 right=1279, Resul Ting Dimensions width=1280 height=720
03-10 14:19:55.601 21706-22256/org.voiddog.ffmpeg D/tag:mediacodec 0XE4998B40 started successfully
03-10 14:19:55.601 21706-22256/org.voiddog.ffmpeg I/tag:mediacodec started successfully, ret = 0

Get data about the input video file

03-10 14:19:55.643 21706-22256/org.voiddog.ffmpeg d/tag:after avformat_find_stream_info () pos:1343 bytes read:93574 Seeks:2 frames:4
03-10 14:19:55.643 21706-22256/org.voiddog.ffmpeg i/tag:input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/ Pauserecorddemo/video/video.mp4 ':
03-10 14:19:55.643 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.643 21706-22256/org.voiddog.ffmpeg I/tag:major_brand:
03-10 14:19:55.643 21706-22256/org.voiddog.ffmpeg i/tag:mp42
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:minor_version:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:512
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:compatible_brands:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:isomiso2avc1mp41
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:encoder:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:handbrake 0.10.0 2014112200
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:duration:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:00:00:31.81
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:, Start:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:0.083000
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:, bitrate:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:1878 kb/s
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:0
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag: (und)
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg D/tag:, 3, 1/90000
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:: video:h264 (avc1/0x31637661), NV12, 1280x720, 1728 kb/s
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:,
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:23.98 fps,
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:23.98 TBR,
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:90k TBN,
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:90k TBC
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag: (default)
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:handler_name:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:videohandler
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:1
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag: (und)
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg D/tag:, 1, 1/48000
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:: Audio:aac (mp4a/0x6134706d), 48000 Hz, stereo, FLTP, 146 kb/ S
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag: (default)
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:handler_name:
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg I/tag:stereo
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:successfully opened the file.

Configure output video file related data

03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:parsing A group of Options:output Url/storage/emulated/0/pause Recorddemo/video/compress6.mp4.
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:applying option Vcodec (Force video codec (' copy ' to copy stream) ) with argument copy.
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:applying option Acodec (Force audio Codec (' copy ' to copy stream) ) with argument copy.
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:successfully parsed a group of options.
03-10 14:19:55.644 21706-22256/org.voiddog.ffmpeg d/tag:opening An output file:/storage/emulated/0/pauserecorddemo/ Video/compress6.mp4.
03-10 14:19:55.648 21706-22256/org.voiddog.ffmpeg d/tag:setting default Whitelist ' File,crypto '
03-10 14:19:55.649 21706-22256/org.voiddog.ffmpeg d/tag:successfully opened the file.
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:output #0, MP4, to '/storage/emulated/0/pauserecorddemo/video /compress6.mp4 ':
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:major_brand:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:mp42
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:minor_version:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:512
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:compatible_brands:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:isomiso2avc1mp41
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:encoder:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:lavf57.73.100
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:0
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag: (und)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg D/tag:, 0, 1/90000
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:: video:h264 ([33][0][0][0]/0x0021), NV12, 1280x720, q=2-31, 1 728 kb/s
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:,
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:23.98 fps,
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:23.98 TBR,
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:90k TBN,
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:90k TBC
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag: (default)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:handler_name:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:videohandler
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:1
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag: (und)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg D/tag:, 0, 1/48000
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:: AUDIO:AAC ([64][0][0][0]/0x0040), 48000 Hz, stereo, FLTP, 14 6 kb/s
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag: (default)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:metadata:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:handler_name:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:stereo

Copy the first 10 seconds of the audio and video stream of the input video file to the output video file
Clearly is the most important part, but only this one log

03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg I/tag:stream Mapping:
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:0, #0:0
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag: (copy)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:stream #0:1, #0:1
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag: (copy)
03-10 14:19:55.650 21706-22256/org.voiddog.ffmpeg i/tag:press [Q] To stop, [?] for help

A package that counts the data that was previously copied

03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg i/tag:frame= 244 fps=0.0 q=-1.0 Lsize= 2522kB time=00:00:10.06 bitrate =2052.0KBITS/S speed= 136x
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg i/tag:video:2280kb audio:233kb Subtitle:0kB other Streams:0kB global HEADERS:0KB muxing Overhead:
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg i/tag:0.355927%
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:input file #0 (/storage/emulated/0/pauserecorddemo/video/ Video.mp4):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:input stream #0:0 (VIDEO):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:245 packets Read (2343932 bytes);
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:input stream #0:1 (Audio):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:474 packets Read (238991 bytes);
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:total:719 Packets (2582923 bytes) demuxed
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:output file #0 (/storage/emulated/0/pauserecorddemo/video/ Compress6.mp4):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:output stream #0:0 (VIDEO):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:244 packets muxed (2335158 bytes);
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:output stream #0:1 (Audio):
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:473 packets muxed (238407 bytes);
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg v/tag:total:717 Packets (2573565 bytes) muxed
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg d/tag:0 frames successfully decoded, 0 decoding errors
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg d/tag:statistics:60 seeks, 764 writeouts
03-10 14:19:55.725 21706-22256/org.voiddog.ffmpeg d/tag:statistics:2662503 bytes read, 2 seeks

Effect

This compress6.mp4 is cut from the Video.mp4, Video.mp4 is 31 seconds, Compress6.mp4 is 10 seconds of time, their volume size coincide with the time ratio.

Android Audio Video Depth 21 FFmpeg video cut

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.