Tuesday, 25 December 2012

mkv magic (repair and resize mkv)

I had am mkv HD film that did not work!

1st get some info:

mkvinfo -s /mnt/nfs/nas2/Movie/Fiction/Thor/video.mkv | head -5

Track 1: Video, Codec-ID: V_MPEG4/ISO/AVC (h.264-Profil: High @L4.1), Track ID für mkvmerge/mkvextract: 0, Standarddauer: 41.708ms (23.976 Bilder/Felder pro Sekunde im Falle eines Video-Tracks), Sprache: und, Pixelbreite: 1920, Pixelhöhe: 816, Anzeigebreite: 1920, Anzeigehöhe: 816
Track 2: Audio, Codec-ID: A_AC3, Track ID für mkvmerge/mkvextract: 1, Standarddauer: 32.000ms (31.250 Bilder/Felder pro Sekunde im Falle eines Video-Tracks), Sprache: und, Abtastfrequenz: 48000, Kanäle: 2
Track 3: Audio, Codec-ID: A_DTS, Track ID für mkvmerge/mkvextract: 2, Standarddauer: 10.667ms (93.750 Bilder/Felder pro Sekunde im Falle eines Video-Tracks), Sprache: und, Abtastfrequenz: 48000, Kanäle: 6
I Frame, Track 1, Zeitstempel 0 (00:00:00.000), Größe 1080, Adler 0xf822129c
I Frame, Track 2, Zeitstempel 0 (00:00:00.000), Größe 1534, Adler 0x07896a98

and extract the tracks

mkvextract tracks /mnt/nfs/nas2/Movie/Fiction/Thor/viodeo.mkv 0:mkv_video 1:mkv_audio1 2:mkv_audio2

and remerge

mkvmerge --default-duration 0:23.976fps mkv_video mkv_audio1 mkv_audio2 -o videout.mkv

did work for me

and resize:
Take the xtracted video track

ffmpeg -i mkv_video -vcodec libx264 -preset ultrafast -s 1280x544 -acodec copy video-544.h264

and remerge as before

mkvmerge --default-duration 0:23.976fps video-544.h264 mkv_audio1 mkv_audio2 -o videout-smaller.mkv

Thats it
PS Screenrecording with ffmpeg
ffmpeg -f x11grab -s wxga -r 25 -i :0.0 -sameq output.mpg
PPS copy ts to mkv (without subtitles)
ffmpeg -i Infile.ts -vcodec copy -sn -sameq -acodec copy -f matroska Outfile.mkv

Friday, 8 June 2012

Linux Kernel-3.4.0 on TS-7250

Grabbing the sources, extracted them, cp the .config from my 2.6.34.7 branch, make menuconfig (with the TS supplied cross toolchain) and finally make ended with compile errors. Googling quite some time for the errors had the result gcc to old and I need a new toolchain. Searching for one to no vain brought me to  crosstool-ng. I had to build it for myself which was straight forward. You can grab the toolchain and my environment setting here.
Finally making the kernel (config is here) was OK and I gave it a try using nfs boot. And to my surprise it worked !!!
I did not yet change anything on the flash so I boot into the stock kernel 2.4 and use the bootloader module from TS. Next I was giving it a try with mounting the rootfs from USB. And that was when the trouble started (Works flawless with Linux-2.6.34.7):

  • Kernel Loading with rootdelay=10
  • .....
  • mounting rootfs
  • usb 1-1: reset full speed USB device using ep93xx-ohci ...

 This happens only when trying to mount the usb thumb drive as rootfs. As non rootfs there is no problem at all. And this time I googled in vain. Some guys had similar problems, there was also a blog entry from 2009 describing the same behaviour. But no solution....

initramfs to the help

I really do not have any clue on how the USB subsystem in LINUX works and as of now have other priorities. So the idea was booting with a small rootfs (initramfs) and hopefully switch_root to the USB thumb drive. I did learn a lot on reading on the internet about initramfs (especially here and here and here) and finally managed to build and use one
The init works like this:
  • mounting proc and sysfs
  • mknode and mdev -s
  • mount the "real" rootfs
  • check /init
  • unmount proc and sys
  • switchroot to the "real" rootfs on the USB thumb drive
  • and again : usb 1-1: reset full speed USB device using ep93xx-ohci ...
And then I was very lucky: Somehow I thought of mounting the "real" rootfs in the initramfs read only and the magic happend: switch-root to the rootfs on the USB thumb drive worked !
Here is my initramfs.cpio.gz as of now.
Why it does work this way is still a mystery for me, but I am sure the community will know.

What has to be done:

The Booting is still not fully automatic. There is a problem with the init in initramfs, that alwas drops me to a shell. Then I can mount the "real" rootfs ro and switch-root to the USB thumb drive.


How I came into it



In 2009 I decided to start experimenting with SBCs. Soon I came across Technology Systems and got the TS-7250. It still powers the control unit for the (partial) solar heating of our house. It was all done in "non embedded" style and I am still fine with the functionality.
But something was not right: I had a Linux system and did use it like a micro controller. So I started the journey, I am still on. Impressed by the work of Mathieu Crapet, I soon got a working Linux-2.6.34.7 that used a rootfs on usb.
Using owfs and sysfs for controlling GPIOs did make the whole stuff really simple and straightforward.
That was too easy and the linux-3 kernel series came out so I wanted to give this a serious try.
Here is the result:



But how I got is worth its own Blog story.