LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 08-16-2013, 09:57 PM   #1
Ryan1955
LQ Newbie
 
Registered: Aug 2013
Distribution: OpenSUSE 12.3
Posts: 4

Rep: Reputation: Disabled
Useful commands for multimedia and graphics using CLI


hi all,

I want to start a thread of commands related to multimedia and graphics such as playing, viewing, editing, encoding and such preferably from the command line. Hopefully, our commands can be useful to others and me.

Rip a DVD title
Code:
HandBrakeCLI -i /media/MOVIE_TITLE/VIDEO_TS/ -t <num> -o movie-name.mp4
Encode a portion of a video. This will start encoding 5 minutes from the video and encode 3 minutes of it.
Code:
HandBrakeCLI -i input_file --start-at duration:300 --stop-at duration:180 -o out.mp4
Other useful options are --gain <num>db to increase volume and -s <num> to toggle subtitles (IF available from source) into the video.

So, if you have any favorites using mplayer/mencoder, ffmpeg/avconv, sox, convert, HandBrakeCLI or whatever, let us know.

Last edited by Ryan1955; 08-16-2013 at 10:16 PM.
 
Old 08-17-2013, 12:15 AM   #2
goinglinux
LQ Newbie
 
Registered: Oct 2008
Location: California
Distribution: Linux Mint
Posts: 10

Rep: Reputation: 2
Here is a command that I used early on for my podcast for encoding videos using mencoder.

mencoder [options] file1 [specific options] [file2] [specific options]

This takes a file named 'out.ogv' created with gtk-recordmydesktop, and re-encodes it as 'out.avi' adds a title, artist, genre, copyright and comment.

Code:
mencoder out.ogv -oac mp3lame -ovc lavc -ofps 30 -vf scale=1024:768 -o out.avi -info name="Going Linux Screencast #001":artist="Larry Bushey and Tom Chaudoir":genre="screencast":subject="Using Audacity to Record a Podcast":copyright="Creative Commons License Attribution 3.0":comment="screencasts.goinglinux.com"
Reference:
http://ubuntuforums.org/showthread.php?t=806125
 
Old 08-17-2013, 10:50 AM   #3
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,136

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
For graphics, ImageMagic is awesome.
http://www.imagemagick.org/script/index.php
 
Old 08-19-2013, 08:03 AM   #4
mjolnir
Member
 
Registered: Apr 2003
Posts: 815

Rep: Reputation: 99
I use this to record my screen in Ubuntu 13.04 with audio from my Logitech webcam:
Code:
ffmpeg -f alsa -i plughw:CARD=U0x46d0x809,DEV=0  -acodec flac -f x11grab -r 30 -s 1214x776 -i :0.0 -acodec pcm_s16le -vcodec libx264 -vpre lossless_ultrafast -threads 0 -sameq capture.avi
 
Old 08-23-2013, 01:31 PM   #5
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,133
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Use your own device nodes, and file names.

Dump audio from video into .mp3 format
Code:
ffmpeg -i file.avi -vn -c:a libmp3lame -b:a 128k Output.mp3
Capture sound card (may require virtual loopback device) See footnote
Code:
ffmpeg -f alsa -i hw:1,1 -c:a copy -vn out.wav
Capture desktop with sound
Code:
ffmpeg -f alsa -i hw:1,1 -f x11grab -r 24 -s 320x240 -i :0.0 -c:a libmp3lame -b:a 32k -c:v libx264 -b:v 500k output.avi
Capture Mic
Code:
arecord -vv -fdat out.wav
Code:
ffmpeg -f alsa -i hw:0,0 -c:a copy -vn out.wav
Select audio stream from multi audio stream video, like a DVD.
Code:
ffmpeg -i file.vob -map 0:0 -map 0:2 ...Out.avi
Sync problems
Code:
ffmpeg -i file.vob -async 1 -vsync 0-3...
Change audio volume (128 = 100%, 256 = 200%) etc.
Code:
ffmpeg -i file.vob -vol 256...
Watermark a video
Top left corner
Code:
ffmpeg –i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:10 [out]" outputvideo.flv
Top right corner
Code:
ffmpeg –i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:10 [out]" outputvideo.flv
Bottom left corner
Code:
ffmpeg –i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=10:main_h-overlay_h-10 [out]" outputvideo.flv
Bottom right corner
Code:
ffmpeg –i inputvideo.avi -vf "movie=watermarklogo.png [watermark]; [in][watermark] overlay=main_w-overlay_w-10:main_h-overlay_h-10 [out]" outputvideo.flv
Join 2 media files
Code:
ffmpeg -i "concat:/path/to/file1.mp3|/path/to/file2.mp3" -c:a copy -vn Output.mp3
Copy Timestamps in - out
Code:
ffmpeg -i file.vob -copyts -vsync 2....
ffplay brightness contrast -vf mp=eq2=gam:con:bri:sat
Code:
ffplay -vf mp=eq2=1.0:1.0:0.1:1.0 file.avi
Change audio speed (from 50% to 200% in ffmpeg)
Code:
ffmpeg -i input.mp3 -filter:a "atempo=1.5" -vn ...output.mp3
Code:
sox file.mp3 fixed.mp3 speed 1.2
Change video speed +25% with increased framerate +25%
Code:
ffmpeg -i input.flv -r 40 -filter:v 'setpts=0.750*PTS' -an .....output.flv
Grab your web cam
Code:
ffmpeg -f v4l2 -s 200x150 -i /dev/video0 -c:v libx264 -b:v 300k out.avi
PES package size mismatch from video's with aac audio
Code:
ffmpeg -i vid.ts -bsf:a aac_adtstoasc -c:a copy .....out.avi
Make animated gif from vid
Code:
mplayer file.flv -ss 00:05 -endpos 6 -vo gif89a:fps=5:output=output.gif -vf scale=400:300 -nosound
Keep pitch change tempo
Code:
mplayer file.mp3 -af scaletempo -speed 1.5
Keep tempo change pitch (Change pitch with [] keys)
Code:
mplayer file.mp3 -af scaletempo=scale=1.0:speed=pitch
TV DVB (H and K to change channels)
Code:
mplayer dvb://
Capture TV channel
Code:
mplayer dvb://WNBC -dumpstream -dumpfile out.ts
or
Code:
azap -r -c ~/.mplayer/channels.conf WNBC
then
Code:
cat /dev/dvb/adapter0/dvr0 > out.ts
Audio only from video
Code:
mencoder file.flv -ovc copy -oac copy -of rawaudio -o test.mp3
Audio only from audio
Code:
mencoder -audiofile /path/to/input.wav -demuxer rawvideo -rawvideo w=1:h=1 /path/to/input.wav -ovc copy -oac mp3lame -lameopts cbr:br=192 -of rawaudio -o output.mp3
That's enough for now, post if you want to know more.


footnote
Create or modify ~/.asoundrc with
Code:
pcm.!default {
  type asym
  playback.pcm "LoopAndReal"
  #capture.pcm "looprec"
  capture.pcm "hw:0,0"
}

pcm.looprec {
    type hw
    card "Loopback"
    device 1
    subdevice 0
}


pcm.LoopAndReal {
  type plug
  slave.pcm mdev
  route_policy "duplicate"
}


pcm.mdev {
  type multi
  slaves.a.pcm pcm.MixReale
  slaves.a.channels 2
  slaves.b.pcm pcm.MixLoopback
  slaves.b.channels 2
  bindings.0.slave a
  bindings.0.channel 0
  bindings.1.slave a
  bindings.1.channel 1
  bindings.2.slave b
  bindings.2.channel 0
  bindings.3.slave b
  bindings.3.channel 1
}


pcm.MixReale {
  type dmix
  ipc_key 1024
  slave {
    pcm "hw:0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}

pcm.MixLoopback {
  type dmix
  ipc_key 1025
  slave {
    pcm "hw:Loopback,0,0"
    rate 48000
    #rate 44100
    periods 128
    period_time 0
    period_size 1024 # must be power of 2
    buffer_size 8192
  }
}
Then
Code:
modprobe snd-aloop

Last edited by teckk; 08-23-2013 at 01:33 PM.
 
Old 08-27-2013, 12:03 AM   #6
CrackerPunk
LQ Newbie
 
Registered: Aug 2013
Location: New Jersey
Distribution: FreeBSD 9.1 | Slackware 13
Posts: 17

Rep: Reputation: Disabled
I have a tip for scaling videos higher or lower i.e resizing.

Ffmpeg

For ffmpeg, the -s is still compatible with ffmpeg. However, for example, you can also use -vf scale=640:480 to resize the video. Yes, it's more typing but the neat tip is below.

Have you ever wanted to resize a video to an unusual resolution and you don't want to guess the values, give -vf scale a starting number and it will fill the rest, thus keeping proper aspect ratio of the encoded video.

In this example, 500 is the starting value of the resolution I want, the -1 will fill the second value for me. And the video will be in proper aspect ratio.

-vf scale=500:-1

As the video is being encoding, it will show the values it chosen.

**Note: Don't use -vf scale on live screen captures especially when capturing the full screen of your desktop. You can, however, use -vf scale after doing the screen capture to resize the video higher or lower.

Mencoder

mencoder uses the same -vf scale option as well. The only difference is it uses a -2

-vf scale=500:-2

Happy encoding.

Last edited by CrackerPunk; 08-27-2013 at 01:05 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting commands or programs for the CLI baldurpet Linux - Software 12 02-19-2009 01:30 PM
Running two commands symultaneously from CLI jamwaffles Linux - Software 10 02-12-2009 10:05 AM
Help:C++ and SCSI2 - Multimedia Commands jaepi Programming 0 08-09-2007 09:10 PM
help in linux commands in cli.. jaepi Linux - Newbie 9 04-27-2007 01:31 PM
Help on cli commands? bruno buys Linux - Software 2 08-15-2004 10:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration