ffmpeg -i video.flv -an -s 320×240 -ss 00:00:02 -r 1 -y %d.jpg
-s 320×240 specifies the frame size of the output (Default is the size of the original video.)
-ss 00:00:02 Seek to given time position in seconds.
ffmpeg -i video.flv -an -s 320×240 -ss 00:00:02 -r 1 -y %d.jpg
-s 320×240 specifies the frame size of the output (Default is the size of the original video.)
-ss 00:00:02 Seek to given time position in seconds.
mencoder <input-file> -oac copy -ovc copy -ffourcc XVID -o <output-file>-oac stands for "output audio codec"-ovc stands for "output video codec"-ffourcc is for forcing the changing of the fourcc setting. The non-playable files had a FourCC setting of FMP4. I changed it to XVID, which made them playable.-o is for output file mencoder The.Big.Show.S01E03.avi -oac copy -ovc copy -ffourcc XVID -o The.Big.Show.S01E03-XVID.avi
mkvmerge -o output.mkv -atrack !2 input.mkv mkvmerge -o output.mkv --no-subtitles input.mkvfor i in *mkv; do mkvmerge -o ./newfiles/`basename "$i" mkv`.mkv --no-subtitles "$i" ; done
ubuntu% sudo apt-get install mkvtoolnixubuntu% sudo apt-get install gpac
ubuntu% mediainfo video.mkv
General
Complete name : video.mkv
Format : Matroska
File size : 1.09 GiB
Duration : 41mn 48s
Overall bit rate : 3 740 Kbps
Video
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Codec ID : V_MPEG4/ISO/AVC
Width : 1 280 pixels
Height : 720 pixels
Frame rate : 23.976 fps
Audio
Format : AC-3
Format/Info : Audio Coding 3
Codec ID : A_AC3
Channel(s) : 6 channels
Channel positions : Front: L C R, Surround: L R, LFE
ubuntu% mkvinfo video.mkv
| + Track number: 1
| + Track type: video
| + Codec ID: V_MPEG4/ISO/AVC
| + Video track
| + Pixel width: 1280
| + Pixel height: 720
| + Track number: 2
| + Track type: audio
| + Codec ID: A_AC3
So what is this file? It's a 2-track mkv
file: track 1 is H.264 video (1280x720), track 2 is AC3 6-channel
audio. Both formats are supported by the PS3, and since they're high
quality it would be a shame to transcode them. Let's try a simple
remuxing into... no, not MP4 because it doesn't support AC3: we have to
use MPEG-2 TS.MUXOPT --no-pcr-on-video-pid --new-audio-pes --vbr V_MPEG4/ISO/AVC, video.mkv, level=4.1, insertSEI, contSPS, track=1, lang=eng A_AC3, video.mkv, track=2, lang=engIgnore the first line and look at the next two. On each of them, we're describing a stream and telling tsMuxer what format it is and where to find it (file name and track number). Don't worry, this information is dumped by mediainfo or mkvinfo (go back and check), so you shouldn't have any problem writing the file :)
ubuntu% tsMuxeR tsmuxer.meta video.m2tsoutput removed
Mux successful complete.
Muxing time: 5 min 25 secubuntu% ffmpeg -i video.mkv -acodec copy -vcodec copy -r 23.976 -f vob video.mpg[NULL @ 0x8076d00]error, non monotone timestamps 15030 >= 7470
av_interleaved_write_frame(): Error while opening fileubuntu% mkvextract tracks video.mkv 1:video.h264 2:audio.ac3ubuntu% ffmpeg -i video.h264 -i audio.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -r 23.976 -f vob video.mpgubuntu% mkvextract tracks video.mkv 1:video.h264 2:audio.ac3
ubuntu% ffmpeg -i audio.ac3 -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac
ubuntu% MP4Box -new -add audio.aac -add video.h264 -fps 23.976 video.mp4AAC import - sample rate 44100 - MPEG-4 audio - 2 channels
AVC-H264 import - frame size 1280 x 720 at 23.976 FPS
Import results: 60146 samples - Slices: 1027 I 36894 P 22225 B - 1 SEI - 968 IDR
Stream uses B-slice references - max frame delay 2
Saving video-ps3.mp4: 0.500 secs Interleaving
ubuntu% mediainfo video2.mkv General Complete name : video2.mkv Format : Matroska Video Format : AVC Format/Info : Advanced Video Codec Format profile : High@L5.1 Muxing mode : Container profile=Unknown@5.1 Codec ID : V_MPEG4/ISO/AVC Frame rate : 23.976 fps Audio Format : DTS Format/Info : Digital Theater Systems Codec ID : A_DTS ubuntu% mkvinfo video2.mkv | + A track | + Track number: 1 | + Track type: video | + Codec ID: V_MPEG4/ISO/AVC | + A track | + Track number: 2 | + Track type: audio | + Codec ID: A_DTSOK, so track 1 is H.264 video and track 2 is DTS audio. Let's extract them:
ubuntu% mkvextract tracks video2.mkv 1:video.h264 2:audio.dts
According to what I've said earlier, H.264 is supported, so all we have to do is to transcode the audio... right?
ubuntu% ffmpeg -i audio.dts -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac
ubuntu% MP4Box -new -add audio.aac -add video.x264 -fps 23.976 video.mp4
That's it. I'm not sure the level hack will always work, but it did in this case and we avoided any video transcoding.ubuntu% mediainfo video3.mkv General Complete name : video3.mkv Format : Matroska File size : 73.9 MiB Duration : 50s 240ms Overall bit rate : 12.3 Mbps Video Format : MPEG Video Format version : Version 2 Format profile : Main@High Format settings, Matrix : Default Codec ID : V_MPEG2 Width : 1 920 pixels Height : 1 080 pixels Audio #1 Format : DTS Format/Info : Digital Theater Systems Codec ID : A_DTS Language : Russian Audio #2 Format : AC-3 Format/Info : Audio Coding 3 Codec ID : A_AC3 Language : English ubuntu% mkvinfo video3.mkv | + Track number: 1 | + Track type: video | + Codec ID: V_MPEG2 | + Track number: 2 | + Track type: audio | + Codec ID: A_DTS | + Track number: 3 | + Track type: audio | + Codec ID: A_AC3Track #1 is full HD MPEG-2 video, track #2 is DTS audio in Russian and track #3 is AC3 audio in English. Let's extract them:
ubuntu% mkvextract tracks video3.mkv 1:video.mpeg 2:audio.dts 3:audio.ac3ubuntu% ffmpeg -i video.mpeg -i audio.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -f vob video.mpg
That's it!
ubuntu% mediainfo audio.dts
General
Complete name : audio.dts
Format : DTS
Format/Info : Digital Theater Systems
File size : 9.04 MiB
Duration : 49s 381ms
Overall bit rate : 1 536 Kbps
Audio
Format : DTS
Format/Info : Digital Theater Systems
Bit rate mode : Constant
Bit rate : 1 536 Kbps
Channel(s) : 6 channels
Channel positions : Front: L C R, Surround: L R, LFE
Sampling rate : 48.0 KHz
Resolution : 16 bits
Since the DTS stream has 6 channels, we can either transcode it to 2-channel AC3 or 6-channel AC3. Let me show you both:
ubuntu% ffmpeg -i audio.dts -acodec ac3 -ar 48000 -ab 448k -ac 2 audio-2ch.ac3
ubuntu% ffmpeg -i audio.dts -acodec ac3 -ar 48000 -ab 448k -ac 6 audio-6ch.ac3ubuntu% ffmpeg -i video.mpeg -i audio-6ch.ac3 -map 0.0:0 -map 1.0:0 -acodec copy -vcodec copy -f vob video.mpg
That's it.
ubuntu% mkvextract tracks video3.mkv 1:video.mpeg 3:audio.ac3
ubuntu% ffmpeg -i audio.ac3 -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac
ubuntu% ffmpeg
-i video.mpeg -f rawvideo - | x264 --level 4.1 --crf 21 --bframes 16
--b-pyramid --ref 4 --mixed-refs --weightb --partitions all --threads 2
-o video.h264 - 1920x1080
ubuntu% MP4Box -new -add video.h264 -add audio.aac -fps 25 video.mp4We have already inspected the file, so let's extract the streams:
mkvextract tracks video.mkv 1:video.h264 2:audio.ac3
Then, we need to transcode the audio stream to AAC (let's use high-quality VBR):
ffmpeg -i audio.ac3 -acodec libfaac -aq 255 -ar 44100 -ac 2 -async 1 -vsync 1 audio.aac
Now, we'll use MP4Box to remux the initial video stream and the new audio stream into an MP4 container:
MP4Box -new -add audio.aac -add video.h264 -fps 23.976 video.mp4
AAC import - sample rate 44100 - MPEG-4 audio - 2 channels
AVC-H264 import - frame size 1280 x 720 at 23.976 FPS
Import results: 60146 samples - Slices: 1027 I 36894 P 22225 B - 1 SEI - 968 IDR
Stream uses B-slice references - max frame delay 2
Saving video-ps3.mp4: 0.500 secs Interleaving
That's it :)
The following bash command adds Medibuntu's repository to Ubuntu. It also adds Medibuntu's GPG key to your keyring, which is needed to authenticate the Medibuntu packages.
This command should be run in the Terminal (Applications → Accessories → Terminal):
sudo -E wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update
Medibuntu's repository is deactivated by upgrading to a newer Ubuntu release, so you should run this command again after the release upgrade.
You may also wish to add the following packages. The first will cause many apps from the Medibuntu repository to appear in Ubuntu Software Center (Ubuntu 9.10+) or Add/Remove Applications (versions prior to 9.10). The second will allow users to generate crash reports against Medibuntu packages and submit them to the Medibuntu bugtracker.
sudo apt-get install app-install-data-medibuntu apport-hooks-medibuntu