You are not logged in.

#1 2011-08-31 12:14:24

Drakx
Member
Registered: 2008-01-14
Posts: 27

[SOLVED] Little help with FFMpeg

Hello,

I'm wanting to record only a given window using ffmpeg I've wirtten a script to help me do this which I'll include below:

INFO=$(xwininfo -frame)
WINGEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
WINCORNORS=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/')

# For testing only                                                                       
#echo $WINGEO
#echo $WINCORNORS

# Record the given window by selecting the window when prompted                                               
ffmpeg -f alsa -ac 2 -i hw:0,0 -f x11grab -r 20 -s $WINGEO -i :0.0+$WINCORNORS -acodec aac -strict experimental -vcodec libx264 -threads 0 -sameq -y ArchLinux-Test.avi

I've named it record.sh once I start record.sh I select my given window for example firefox then I get the following error:

ffmpeg version 0.7.1, Copyright (c) 2000-2011 the FFmpeg developers
  built on Jul 24 2011 08:54:22 with gcc 4.6.1
  configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis --enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora --enable-postproc --enable-shared --enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libschroedinger --enable-libopenjpeg --enable-librtmp --enable-gpl --enable-version3 --enable-runtime-cpudetect --disable-debug
  libavutil    50. 43. 0 / 50. 43. 0
  libavcodec   52.122. 0 / 52.122. 0
  libavformat  52.110. 0 / 52.110. 0
  libavdevice  52.  5. 0 / 52.  5. 0
  libavfilter   1. 80. 0 /  1. 80. 0
  libswscale    0. 14. 1 /  0. 14. 1
  libpostproc  51.  2. 0 / 51.  2. 0
[alsa @ 0x172c0a0] Estimating duration from bitrate, this may be inaccurate
Input #0, alsa, from 'hw:0,0':
  Duration: N/A, start: 5631.261874, bitrate: N/A
    Stream #0.0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s
[x11grab @ 0x172b040] device: :0.0+0,105 -> display: :0.0 x: 0 y: 105 width: 1341 height: 969
[x11grab @ 0x172b040] shared memory extension found
[x11grab @ 0x172b040] Estimating duration from bitrate, this may be inaccurate
Input #1, x11grab, from ':0.0+0,105':
  Duration: N/A, start: 1314791831.837798, bitrate: 831634 kb/s
    Stream #1.0: Video: rawvideo, bgra, 1341x969, 831634 kb/s, 20 tbr, 1000k tbn, 20 tbc
Incompatible pixel format 'bgra' for codec 'libx264', auto-selecting format 'yuv420p'
[buffer @ 0x1724960] w:1341 h:969 pixfmt:bgra tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 0x1724d40] auto-inserting filter 'auto-inserted scaler 0' between the filter 'src' and the filter 'out'
[scale @ 0x172d9c0] w:1341 h:969 fmt:bgra -> w:1341 h:969 fmt:yuv420p flags:0x4
[libx264 @ 0x174c980] Default settings detected, using medium profile
[libx264 @ 0x174c980] width or height not divisible by 2 (1341x969)
Output #0, avi, to 'ArchLinux-Test.avi':
    Stream #0.0: Video: libx264, yuv420p, 1341x969, q=2-31, 200 kb/s, 90k tbn, 20 tbc
    Stream #0.1: Audio: aac, 48000 Hz, 2 channels, s16, 64 kb/s
Stream mapping:
  Stream #1.0 -> #0.0
  Stream #0.0 -> #0.1
Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height

As you can see its complaining about Error while opening encoder for output stream #0.0 - maybe incorrect parameters such as bit_rate, rate, width or height has any one got any idea how to fix this?

I'm using the ffmpeg from the repo's
Thanks.

Last edited by Drakx (2011-08-31 18:10:05)

Offline

#2 2011-08-31 12:59:57

satanselbow
Member
Registered: 2011-06-15
Posts: 538

Re: [SOLVED] Little help with FFMpeg

You might find having an odd height x width (1341 x 969) is causing ffmpeg to panic as it is not able to "round-up" on it's own wink You might need to feed it an even h x w ie 1340 x 970 wink

Had a not dissimilar problem with a script to batch crop some old vid a while back wink

Offline

#3 2011-08-31 14:48:41

Drakx
Member
Registered: 2008-01-14
Posts: 27

Re: [SOLVED] Little help with FFMpeg

ok ill give that a shot

Thanks

Offline

#4 2011-08-31 18:09:46

Drakx
Member
Registered: 2008-01-14
Posts: 27

Re: [SOLVED] Little help with FFMpeg

That did the trick satanselbow thanks very much.

Offline

Board footer

Powered by FluxBB