Unable to cut out part of video with ffmpeg

3

2

What I want to do

I'm trying to cut a video for a science project under Ubuntu 11.10 with latest ffmpeg, I also tried Kino and avidemux where the video failed to even open properly although it plays well in both VLC and mplayer.

The closest I have come so far is with these parameters:

ffmpeg -ss 01:58 -t 21 -i row.avi -vcodec copy row_cut.avi

Also tried

ffmpeg -ss 1 -i row.avi -vcodec copy -t 3 row_cut.avi

and still have the same error :(

Where I get at least a 21s video as output and no apparent errors but the video won't play in VLC (ticker rolls but only displays VLC-logo) nor mplayer ("Internal data stream error").


FFmpeg output when encoding

ffmpeg version git-2012-02-02-c853124 Copyright (c) 2000-2012 the FFmpeg developers
built on Feb  2 2012 23:17:50 with gcc 4.6.1
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable --libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
 libavutil      51. 37.100 / 51. 37.100
 libavcodec     54.  0.102 / 54.  0.102
 libavformat    54.  0.100 / 54.  0.100
 libavdevice    53.  4.100 / 53.  4.100
 libavfilter     2. 61.100 /  2. 61.100
 libswscale      2.  1.100 /  2.  1.100
 libswresample   0.  6.100 /  0.  6.100
 libpostproc    52.  0.100 / 52.  0.100
Input #0, avi, from 'row.avi':
 Duration: 00:03:13.93, start: 0.000000, bitrate: 46210 kb/s
  Stream #0:0: Video: rawvideo, pal8, 640x300, 30 tbr, 30 tbn, 30 tbc
File 'row_cut.avi' already exists. Overwrite ? [y/N] y
Output #0, avi, to 'row_cut.avi':
 Metadata:
  ISFT            : Lavf54.0.100
  Stream #0:0: Video: rawvideo, pal8, 640x300, q=2-31, 30 tbn, 30 tbc
Stream mapping:
 Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=  631 fps=125 q=-1.0 Lsize=  118334kB time=00:00:21.03 bitrate=46088.4kbits/s    
video:118312kB audio:0kB global headers:0kB muxing overhead 0.018043%

FFmpeg output when loading the videos

My guess is that the video has some type of weird format, misunderstood the ffmpeg's parameters or perhaps the Metada:encoder:Lavf53.3.0 part in the output?

user@computer:/somewhere$ ffmpeg -i row.avi
Input #0, avi, from 'row.avi':
 Duration: 00:03:13.93, start: 0.000000, bitrate: 46210 kb/s
  Stream #0.0: Video: rawvideo, pal8, 640x300, 30 tbr, 30 tbn, 30 tbc

and

user@computer:/somewhere$ ffmpeg -i row_cut.avi
Input #0, avi, from 'row_cut.avi':
 Metadata:
  encoder         : Lavf54.0.100
Duration: 00:00:21.03, start: 0.000000, bitrate: 46088 kb/s
 Stream #0.0: Video: rawvideo, bgr24, 640x300, 30 tbr, 30 tbn, 30 tbc

Mediainfo output

General
Complete name                            : row.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
Format profile                           : OpenDML
File size                                : 1.04 GiB
Duration                                 : 3mn 13s
Overall bit rate                         : 46.2 Mbps

Video
ID                                       : 0
Format                                   : RGB
Codec ID                                 : 0x00000000
Codec ID/Info                            : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration                                 : 3mn 13s
Bit rate                                 : 46.1 Mbps
Width                                    : 640 pixels
Height                                   : 300 pixels
Display aspect ratio                     : 2.2:1
Frame rate                               : 30.000 fps
Bit depth                                : 8 bits
Bits/(Pixel*Frame)                       : 8.000
Stream size                              : 1.04 GiB (100%)

and

General
Complete name                            : row_cut.avi
Format                                   : AVI
Format/Info                              : Audio Video Interleave
File size                                : 116 MiB
Duration                                 : 21s 33ms
Overall bit rate                         : 46.1 Mbps
Writing application                      : Lavf54.0.100

Video
ID                                       : 0
Format                                   : RGB
Codec ID                                 : 0x00000000
Codec ID/Info                            : Basic Windows bitmap format. 1, 4 and 8 bpp versions are palettised. 16, 24 and 32bpp contain raw RGB samples
Duration                                 : 21s 33ms
Bit rate                                 : 46.1 Mbps
Width                                    : 640 pixels
Height                                   : 4294966 996 pixels
Display aspect ratio                     : 0.000
Frame rate                               : 30.000 fps
Bit depth                                : 8 bits
Stream size                              : 116 MiB (100%)

SlimJim

Posted 2012-02-02T19:42:18.780

Reputation: 161

Tip: You're using ffmpeg version 0.7.3. It's really old. Get the latest version, they're at 0.10 now. You're on Ubuntu, so follow this tutorial, it's quite easy and step-by-step with everything necessary. Try with the newest version and report back ;)

– slhck – 2012-02-02T21:30:29.183

Interestingly, it seems that the color space is not written correctly to the AVI container. While when encoding, you still get pal8, reading the file back gives you bgr24 – something must be wrong there. – slhck – 2012-02-02T21:32:12.567

updated x264 and ffmpeg following the link provided, still have the same problem :( – SlimJim – 2012-02-02T23:08:04.093

Can you [edit] your post and update the output? Can you maybe post the sample file somewhere for me to check? I'll look into it. – slhck – 2012-02-02T23:21:04.727

use mediainfo to see what's inside it. – barlop – 2012-02-02T23:30:08.130

Try -acodec copy, not just -vcodec copy – barlop – 2012-02-02T23:31:06.020

and Try different parameters for -ss and -t like -ss 1 -t 3 so you at least see it working. -ss 1 means one second in. so keep it simple as a test, seconds. – barlop – 2012-02-02T23:32:18.093

@barlop FFmpeg already shows what's inside it. Also the audio shouldn't matter if the video is not playing. // SlimJim, have you tried placing the -t parameter after -vcodec copy? Just a minor thing, but it could matter. – slhck – 2012-02-03T11:39:55.240

i will try this after, im in a hurry right now :D thx for the help guys :D – SlimJim – 2012-02-03T15:24:11.283

@slhck what do you mean "the audio shouldn't matter if the video is not playing". It's an avi file some call that a video, but it has video and audio, and if it's not opening, or not playing, then perhaps it could be an audio codec issue? like if the video only plays alongside certain audio codecs. (i'm not that experienced with it though) I can't really see the video and audio codecs in each file, from what he posted in his question. Maybe he can post a more complete show of codecs for row.avi the output for row_cut.avi is a bit more complete it seems.. though I know these things are tricky. – barlop – 2012-02-03T15:43:06.473

When you say it "won't play", does it play with a black image, or doesn't play at all? Do you receive an error? Try the ffmpeg command with -f avi before the output file name. It seems the format is incorrectly written, thus setting the wrong codec ID (to 0x00000000). Using the flag will force the format. – slhck – 2012-02-03T15:53:31.447

@barlop there shouldn't be any audio in this clip and what a great idea to keep it simple, always forget that little detail when I'm testing. – SlimJim – 2012-02-03T18:05:46.283

@slhck I think the sample file is to big, I don't have anywhere to post it besides I don't know if I'm allowed since it research-material. And adding -vcodec copy or reordering -t didn't have any effect. – SlimJim – 2012-02-03T18:13:34.607

@slhck so the source-video row.api has some problems with it's codec if codec ID is 0x0 ? – SlimJim – 2012-02-03T18:16:08.043

Ah, I didn't see that it's on the source as well. Where does that video come from, exactly? I'm in video research too, so I do understand if it's a problem to post it. However, if it's possible to supply only maybe one second of generated output, that would be more than helpful for me to be able to try. – slhck – 2012-02-03T18:20:18.773

@slhck the video is from neuro-scientists trying to do research on rat-whiskers. 1s of video output: link Haven't had to much experience asking things on forums but superuser seems to be the boss, you guys are awesome :D

– SlimJim – 2012-02-03T18:37:11.887

Okay, so I've been trying a lot to get this file playing, but it just won't. The last resort I can offer is posting to the FFmpeg user mailing list, which I also follow. Some developers are involved, and as this goes beyond my knowledge, you might find an answer there. Make sure to post complete ffmpeg commands and their output, like you did here. I guess the problem is that the input you get (pixel format pal8) is very uncommon. Please keep me posted :)

– slhck – 2012-02-03T23:19:52.633

thanks a lot for the help @slhck really appreciate it :D – SlimJim – 2012-02-04T08:35:23.870

@slhck can one just mail them without being on their mailing list? I have no real experience with this type of mailing lists. – SlimJim – 2012-02-04T09:16:30.730

I guess you don't need to sign up, you can just send a mail. I'd however sign up right away, you can cancel the subscription later on without problems! – slhck – 2012-02-04T09:48:04.940

Answers

3

Answer from the ffmpeg mailing list:

You cannot use -vcodec copy on pal8 rawvideo (this may be a bug), but you can use -vcodec rawvideo as a work-around.

It kinda works plays in VLC but not mplayer so it will do for now. The final working command would be

ffmpeg -ss 1 -i row.avi -vcodec rawvideo -t 3 row_cut.avi

SlimJim

Posted 2012-02-02T19:42:18.780

Reputation: 161