[FFmpeg-user] More issues with the -t option (segment extraction)

Jeanne Rich jrich at laika.com
Mon Sep 23 06:31:17 CEST 2013


I am trying to extract a segment out of an mjpeg quicktime movie using the -ss and -t options. However, when I do this I get more frames than I wanted. In this case I am trying to extract 10 frames, the audio is short with with a start_pts that is not 0, and the video is 1 frame too long. I tried using the frames:v option, but when I did that the audio was too short. Finally I tried the trim filter but that did nothing. I am using the git-head from Friday. 

Below is the command with the -t option, and below that is the ffprobe output. 

'ffmpeg' '-i' '/laika/tmp/jrich/trans/outmjpeg.mov' '-vcodec' 'copy' '-r' '24.000000' '-acodec' 'copy' '-ar' '48000' '-ss' '0.416667' '-t' '0.416667' '-movflags' 'faststart' '-y' -v debug '/laika/tmp/jrich/trans/outVideoSegment1.mov' 
ffmpeg version 2.0-bed611f Copyright (c) 2000-2013 the FFmpeg developers 
built on Sep 20 2013 15:22:34 with gcc 4.1.2 (GCC) 
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/2.0.1.bed611f --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libfdk-aac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/fdk-aac/0.1.2/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/fdk-aac/0.1.2/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC' 
libavutil 52. 45.100 / 52. 45.100 
libavcodec 55. 33.100 / 55. 33.100 
libavformat 55. 18.101 / 55. 18.101 
libavdevice 55. 3.100 / 55. 3.100 
libavfilter 3. 86.102 / 3. 86.102 
libswscale 2. 5.100 / 2. 5.100 
libswresample 0. 17.103 / 0. 17.103 
libpostproc 52. 3.100 / 52. 3.100 
Splitting the commandline. 
Reading option '-i' ... matched as input file with argument '/laika/tmp/jrich/trans/outmjpeg.mov'. 
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'copy'. 
Reading option '-r' ... matched as option 'r' (set frame rate (Hz value, fraction or abbreviation)) with argument '24.000000'. 
Reading option '-acodec' ... matched as option 'acodec' (force audio codec ('copy' to copy stream)) with argument 'copy'. 
Reading option '-ar' ... matched as option 'ar' (set audio sampling rate (in Hz)) with argument '48000'. 
Reading option '-ss' ... matched as option 'ss' (set the start time offset) with argument '0.416667'. 
Reading option '-t' ... matched as option 't' (record or transcode "duration" seconds of audio/video) with argument '0.416667'. 
Reading option '-movflags' ... matched as AVOption 'movflags' with argument 'faststart'. 
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'. 
Reading option '-v' ... matched as option 'v' (set logging level) with argument 'debug'. 
Reading option '/laika/tmp/jrich/trans/outVideoSegment1.mov' ... matched as output file. 
Finished splitting the commandline. 
Parsing a group of options: global . 
Applying option y (overwrite output files) with argument 1. 
Applying option v (set logging level) with argument debug. 
Successfully parsed a group of options. 
Parsing a group of options: input file /laika/tmp/jrich/trans/outmjpeg.mov. 
Successfully parsed a group of options. 
Opening an input file: /laika/tmp/jrich/trans/outmjpeg.mov. 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2191b20] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2191b20] ISO: File Type Major Brand: qt 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2191b20] File position before avformat_find_stream_info() is 44611 
[mjpeg @ 0x2192a20] marker=d8 avail_size_in_buf=258058 
[mjpeg @ 0x2192a20] marker parser used 0 bytes (0 bits) 
[mjpeg @ 0x2192a20] marker=fe avail_size_in_buf=258056 
[mjpeg @ 0x2192a20] marker parser used 16 bytes (128 bits) 
[mjpeg @ 0x2192a20] marker=db avail_size_in_buf=258038 
[mjpeg @ 0x2192a20] index=0 
[mjpeg @ 0x2192a20] qscale[0]: 1 
[mjpeg @ 0x2192a20] marker parser used 67 bytes (536 bits) 
[mjpeg @ 0x2192a20] marker=c4 avail_size_in_buf=257969 
[mjpeg @ 0x2192a20] class="0" index=0 nb_codes=12 
[mjpeg @ 0x2192a20] class="0" index=1 nb_codes=12 
[mjpeg @ 0x2192a20] class="1" index=0 nb_codes=251 
[mjpeg @ 0x2192a20] class="1" index=1 nb_codes=251 
[mjpeg @ 0x2192a20] marker parser used 418 bytes (3344 bits) 
[mjpeg @ 0x2192a20] marker=c0 avail_size_in_buf=257549 
[mjpeg @ 0x2192a20] sof0: picture: 1920x1080 
[mjpeg @ 0x2192a20] component 0 2:2 id: 0 quant:0 
[mjpeg @ 0x2192a20] component 1 1:1 id: 1 quant:0 
[mjpeg @ 0x2192a20] component 2 1:1 id: 2 quant:0 
[mjpeg @ 0x2192a20] pix fmt id 22111100 
[mjpeg @ 0x2192a20] marker parser used 17 bytes (136 bits) 
[mjpeg @ 0x2192a20] escaping removed 9667 bytes 
[mjpeg @ 0x2192a20] marker=da avail_size_in_buf=257530 
[mjpeg @ 0x2192a20] component: 0 
[mjpeg @ 0x2192a20] component: 1 
[mjpeg @ 0x2192a20] component: 2 
[mjpeg @ 0x2192a20] marker parser used 247862 bytes (1982891 bits) 
[mjpeg @ 0x2192a20] marker=d9 avail_size_in_buf=0 
[mjpeg @ 0x2192a20] decode frame unused 0 bytes 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2191b20] All info found 
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x2191b20] File position after avformat_find_stream_info() is 306767 
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/laika/tmp/jrich/trans/outmjpeg.mov': 
Metadata: 
major_brand : qt 
minor_version : 512 
compatible_brands: qt 
encoder : Lavf55.18.101 
Duration: 00:02:09.13, start: 0.000000, bitrate: 49109 kb/s 
Stream #0:0(eng), 1, 1/12288: Video: mjpeg (jpeg / 0x6765706A), yuvj420p(pc), 1920x1080, 1/12288, 47570 kb/s, 24 fps, 24 tbr, 12288 tbn, 12288 tbc (default) 
Metadata: 
handler_name : DataHandler 
Stream #0:1(eng), 1, 1/48000: Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default) 
Metadata: 
handler_name : DataHandler 
Successfully opened the file. 
Parsing a group of options: output file /laika/tmp/jrich/trans/outVideoSegment1.mov. 
Applying option vcodec (force video codec ('copy' to copy stream)) with argument copy. 
Applying option r (set frame rate (Hz value, fraction or abbreviation)) with argument 24.000000. 
Applying option acodec (force audio codec ('copy' to copy stream)) with argument copy. 
Applying option ar (set audio sampling rate (in Hz)) with argument 48000. 
Applying option ss (set the start time offset) with argument 0.416667. 
Applying option t (record or transcode "duration" seconds of audio/video) with argument 0.416667. 
Successfully parsed a group of options. 
Opening an output file: /laika/tmp/jrich/trans/outVideoSegment1.mov. 
Successfully opened the file. 
Output #0, mov, to '/laika/tmp/jrich/trans/outVideoSegment1.mov': 
Metadata: 
major_brand : qt 
minor_version : 512 
compatible_brands: qt 
encoder : Lavf55.18.101 
Stream #0:0(eng), 0, 1/12288: Video: mjpeg (jpeg / 0x6765706A), yuvj420p, 1920x1080, 1/24, q=2-31, 47570 kb/s, 24 fps, 12288 tbn, 24 tbc (default) 
Metadata: 
handler_name : DataHandler 
Stream #0:1(eng), 0, 1/48000: Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, 1536 kb/s (default) 
Metadata: 
handler_name : DataHandler 
Stream mapping: 
Stream #0:0 -> #0:0 (copy) 
Stream #0:1 -> #0:1 (copy) 
Press [q] to stop, [?] for help 
No more output streams to write to, finishing. 
[mov @ 0x21935c0] Starting second pass: moving the moov atom to the beginning of the file 
[AVIOContext @ 0x2198900] Statistics: 2646132 bytes read, 0 seeks 
frame= 11 fps=0.0 q=-1.0 Lsize= 2585kB time=00:00:00.45 bitrate=46210.6kbits/s 
video:2506kB audio:78kB subtitle:0 global headers:0kB muxing overhead 0.052266% 
0 frames successfully decoded, 0 decoding errors 
[AVIOContext @ 0x2192900] Statistics: 60 seeks, 234 writeouts 
[AVIOContext @ 0x219a240] Statistics: 5524089 bytes read, 0 seeks 


ffprobe output 

ffprobe -show_streams -show_format /laika/tmp/jrich/trans/outVideoSegment1.mov ffprobe version 2.0-bed611f Copyright (c) 2007-2013 the FFmpeg developers 
built on Sep 20 2013 15:22:34 with gcc 4.1.2 (GCC) 
configuration: --prefix=/local/prod/b3p/2.0/ffmpeg/2.0.1.bed611f --enable-gpl --enable-nonfree --enable-pthreads --enable-static --enable-shared --enable-postproc --disable-debug --enable-avfilter --enable-zlib --enable-libvorbis --enable-libfaac --enable-libfdk-aac --enable-libx264 --enable-libmp3lame --enable-libvpx --enable-filter=movie --enable-libfreetype --extra-cflags='-I/local/prod/b3p/2.0/faac/1.28/include -I/local/prod/b3p/2.0/fdk-aac/0.1.2/include -I/local/prod/b3p/2.0/x264/r2245/include -I/local/prod/b3p/2.0/lame/3.98.4/include -I/local/prod/b3p/2.0/libogg/1.3.0/include -I/local/prod/b3p/2.0/libvpx/1.1.0/include -I/local/prod/b3p/2.0/libvorbis/1.3.2/include' --extra-ldflags='-L/local/prod/b3p/2.0/faac/1.28/lib -L/local/prod/b3p/2.0/fdk-aac/0.1.2/lib -L/local/prod/b3p/2.0/x264/r2245/lib -L/local/prod/b3p/2.0/lame/3.98.4/lib -L/local/prod/b3p/2.0/libogg/1.3.0/lib -L/local/prod/b3p/2.0/libvpx/1.1.0/lib -L/local/prod/b3p/2.0/libvorbis/1.3.2/lib -fPIC' 
libavutil 52. 45.100 / 52. 45.100 
libavcodec 55. 33.100 / 55. 33.100 
libavformat 55. 18.101 / 55. 18.101 
libavdevice 55. 3.100 / 55. 3.100 
libavfilter 3. 86.102 / 3. 86.102 
libswscale 2. 5.100 / 2. 5.100 
libswresample 0. 17.103 / 0. 17.103 
libpostproc 52. 3.100 / 52. 3.100 
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/laika/tmp/jrich/trans/outVideoSegment1.mov': 
Metadata: 
major_brand : qt 
minor_version : 512 
compatible_brands: qt 
encoder : Lavf55.18.101 
Duration: 00:00:00.46, start: 0.000000, bitrate: 46143 kb/s 
Stream #0:0(eng): Video: mjpeg (jpeg / 0x6765706A), yuvj420p(pc), 1920x1080, 44796 kb/s, 24 fps, 24 tbr, 12288 tbn, 12288 tbc (default) 
Metadata: 
handler_name : DataHandler 
Stream #0:1(eng): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default) 
Metadata: 
handler_name : DataHandler 
[STREAM] 
index=0 
codec_name=mjpeg 
codec_long_name=MJPEG (Motion JPEG) 
profile=unknown 
codec_type=video 
codec_time_base=1/12288 
codec_tag_string=jpeg 
codec_tag=0x6765706a 
width=1920 
height=1080 
has_b_frames=0 
sample_aspect_ratio=0:1 
display_aspect_ratio=0:1 
pix_fmt=yuvj420p 
level=-99 
timecode=N/A 
id=N/A 
r_frame_rate=24/1 
avg_frame_rate=24/1 
time_base=1/12288 
start_pts=0 
start_time=0.000000 
duration_ts=5632 
duration=0.458333 
bit_rate=44796741 
nb_frames=11 
nb_read_frames=N/A 
nb_read_packets=N/A 
DISPOSITION:default=1 
DISPOSITION:dub=0 
DISPOSITION:original=0 
DISPOSITION:comment=0 
DISPOSITION:lyrics=0 
DISPOSITION:karaoke=0 
DISPOSITION:forced=0 
DISPOSITION:hearing_impaired=0 
DISPOSITION:visual_impaired=0 
DISPOSITION:clean_effects=0 
DISPOSITION:attached_pic=0 
TAG:language=eng 
TAG:handler_name=DataHandler 
[/STREAM] 
[STREAM] 
index=1 
codec_name=pcm_s16le 
codec_long_name=PCM signed 16-bit little-endian 
profile=unknown 
codec_type=audio 
codec_time_base=1/48000 
codec_tag_string=sowt 
codec_tag=0x74776f73 
sample_fmt=s16 
sample_rate=48000 
channels=2 
bits_per_sample=16 
id=N/A 
r_frame_rate=0/0 
avg_frame_rate=0/0 
time_base=1/48000 
start_pts=480 
start_time=0.010000 
duration_ts=19904 
duration=0.414667 
bit_rate=1536000 
nb_frames=19904 
nb_read_frames=N/A 
nb_read_packets=N/A 
DISPOSITION:default=1 
DISPOSITION:dub=0 
DISPOSITION:original=0 
DISPOSITION:comment=0 
DISPOSITION:lyrics=0 
DISPOSITION:karaoke=0 
DISPOSITION:forced=0 
DISPOSITION:hearing_impaired=0 
DISPOSITION:visual_impaired=0 
DISPOSITION:clean_effects=0 
DISPOSITION:attached_pic=0 
TAG:language=eng 
TAG:handler_name=DataHandler 
[/STREAM] 
[FORMAT] 
filename=/laika/tmp/jrich/trans/outVideoSegment1.mov 
nb_streams=2 
nb_programs=0 
format_name=mov,mp4,m4a,3gp,3g2,mj2 
format_long_name=QuickTime / MOV 
start_time=0.000000 
duration=0.459000 
size=2647479 
bit_rate=46143424 
probe_score=100 
TAG:major_brand=qt 
TAG:minor_version=512 
TAG:compatible_brands=qt 
TAG:encoder=Lavf55.18.101 
[/FORMAT] 

-jeanne 


More information about the ffmpeg-user mailing list