Prosíme přihlašte se nebo zaregistrujte.

Přihlašte se svým uživatelským jménem a heslem.
Vaše pomoc je stále potřeba!

Autor Téma: Lama a její Creative Zen MX a formát CMV  (Přečteno 2127 krát)

pastaguy

  • Návštěvník
  • Příspěvků: 18
Lama a její Creative Zen MX a formát CMV
« kdy: 19 Června 2010, 08:00:52 »
Tak jsem měl bohužel tu smůlu a dostal jsem přehrávač Creative ZEN, který je natolik pitomý a video přehrává jen ve formátu CMV. Přiložený software na převod filmů mi bohužel v ubuntu nefunguje a tak bych se rád zeptal, jestli s tím nemáte někdo zkušenosti. Díky mockrát.

pacholik

  • Závislák
  • ***
  • Příspěvků: 2072
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #1 kdy: 19 Června 2010, 14:49:41 »
našel sem skript od jistýho Stanisława Pituchy
potřebuješ ffmpeg a python PIL
Kód: [Vybrat]
sudo aptitude install ffmpeg python-imaging
Kód: [Vybrat]
#!/usr/bin/env python

import sys, struct, subprocess, os

def make_jpeg_strip(files, output):
subprocess.call(["montage"] + files + ["-geometry", "+0+0", "-tile", "1x25", output])

for x in files:
try:
os.remove(x)
except OSError, x:
if x.errno != 2: # ENOENT
raise x

def join_frames(tmpdir, frames):
chunk = []
chunk_num = 0

while len(frames) > 0:
chunk.append(frames.pop(0))
if len(chunk) == 25:
make_jpeg_strip(chunk, "%s/chunk%06d.jpeg" % (tmpdir, chunk_num,))
chunk = []
chunk_num += 1
if chunk_num % 10 == 0:
print "chunk", chunk_num

if len(chunk) > 0:
while len(chunk) != 25:
chunk.append(chunk[-1])

make_jpeg_strip(chunk, "%s/chunk%06d.jpeg" % (tmpdir, chunk_num))
chunk = []
chunk_num += 1

return chunk_num

def find_biggest(tmpdir):
stats = (os.stat(".tmp/%s" % (x,)) for x in os.listdir(tmpdir) if x.startswith("chunk") and x.endswith(".jpeg"))
sizes = (x.st_size for x in stats)
return max(sizes)

def write_i24(file, i):
file.write(struct.pack("<I", i)[:3])

def write_chunk(file, max_size, chunk):
chunk_file = open(chunk, "r")
c = chunk_file.read()
write_i24(file, len(c))
file.write(c)
file.write("\x00" * (max_size - len(c)))
chunk_file.close()

def append_video(chunks, max_size, output):
file = open(output, "a")
file.write("CMV")
file.write("001000") # major, minor version
write_i24(file, 320) # width
write_i24(file, 192) # height
write_i24(file, 16) # block width
write_i24(file, 1) # block height
write_i24(file, max_size+3) # chunk = len + max block size
write_i24(file, 25) # frames per chunk
write_i24(file, len(chunks)*25) # frames in file
write_i24(file, 1) # unknown 1
write_i24(file, 0) # unknown 0
write_i24(file, 25) # fps
for x in range(4):
write_i24(file, 0x010101)

first = True
for x in chunks:
write_chunk(file, max_size, x)
if first:
write_chunk(file, max_size, x)
first = False

file.close()

def process(input, output):
tmpdir = '.tmp'

try:
os.mkdir(tmpdir)
except OSError, e:
if e.errno != 17: # EEXIST
raise e

subprocess.call(["ffmpeg", "-i", input,
"-vcodec", "mjpeg", "-r", "25", "-an", "-f", "image2", "-s",
"%ix%i" % (320, 192), "%s/frame%%06d.jpeg" % (tmpdir,)])

frames = ["%s/%s" % (tmpdir, x) for x in os.listdir(tmpdir) if x.startswith("frame") and x.endswith(".jpeg")]
chunk_num = join_frames(tmpdir, frames)
print "got", chunk_num, "chunks"
max_size = find_biggest(tmpdir)
print "max size", max_size

subprocess.call(["ffmpeg", "-i", input, "-vn", "-acodec", "adpcm_ima_wav", "-ar", "24000", tmpdir + "/" + input + ".wav"])
chunks = ["%s/%s" % (tmpdir, x) for x in os.listdir(tmpdir) if x.startswith("chunk") and x.endswith(".jpeg")]
append_video(chunks, max_size, tmpdir + "/" + input + ".wav")
os.rename(tmpdir + "/" + input + ".wav", output)

if __name__ == "__main__":
input = sys.argv[1]
output = sys.argv[2] if len(sys.argv)>2 else (input + '.cmv')

process(input, output)
ulož to jako cmv_create.py, nastav tomu spustitelnej příznak a potom
Kód: [Vybrat]
./cmv_create.py video.avi video.cmvpřehrávač nemam, takže neručim za to jestli to vůbec funguje, ale .cmv soubor se mi vytvořit podařilo

pastaguy

  • Návštěvník
  • Příspěvků: 18
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #2 kdy: 21 Června 2010, 09:38:06 »
Díky moc. Tvá rada zdá se, že bude fungovat. Bohužel u mě zdá se nefunguje tak, jak by měla. Terminál se pokusí, spustí, ale nakonec neuspěje. Tohle je výsledek jeho snažení:

pastaguy@Pastapot2:~$ ./cmv_create.py video.avi video.cmv
FFmpeg version SVN-r0.5.1-4:0.5.1-1ubuntu1, Copyright (c) 2000-2009 Fabrice Bellard, et al.
  configuration: --extra-version=4:0.5.1-1ubuntu1 --prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libgsm --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libdc1394 --enable-shared --disable-static
  libavutil     49.15. 0 / 49.15. 0
  libavcodec    52.20. 1 / 52.20. 1
  libavformat   52.31. 0 / 52.31. 0
  libavdevice   52. 1. 0 / 52. 1. 0
  libavfilter    0. 4. 0 /  0. 4. 0
  libswscale     0. 7. 1 /  0. 7. 1
  libpostproc   51. 2. 0 / 51. 2. 0
  built on Mar  4 2010 12:35:30, gcc: 4.4.3
[NULL @ 0x8603570]Invalid and inefficient vfw-avi packed B frames detected

Seems stream 0 codec frame rate differs from container frame rate: 30000.00 (30000/1) -> 25.00 (25/1)
Input #0, avi, from 'video.avi':
  Duration: 00:08:04.04, start: 0.000000, bitrate: 1006 kb/s
    Stream #0.0: Video: mpeg4, yuv420p, 640x480 [PAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 30k tbc
    Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s
Output #0, image2, to '.tmp/frame%06d.jpeg':
    Stream #0.0: Video: mjpeg, yuvj420p, 320x192 [PAR 4:5 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0.0 -> #0.0
Press [q] to stop encoding
[mpeg4 @ 0x8603570]Invalid and inefficient vfw-avi packed B frames detected
frame=12101 fps=  9 q=24.8 Lsize=      -0kB time=484.04 bitrate=  -0.0kbits/s   
video:45293kB audio:0kB global headers:0kB muxing overhead -100.000047%
chunk 10
chunk 20
chunk 30
chunk 40
chunk 50
chunk 60
chunk 70
chunk 80
chunk 90
chunk 100
chunk 110
chunk 120

pacholik

  • Závislák
  • ***
  • Příspěvků: 2072
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #3 kdy: 21 Června 2010, 12:47:00 »
v čem spočívá ten neúspěch ?

pastaguy

  • Návštěvník
  • Příspěvků: 18
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #4 kdy: 21 Června 2010, 13:40:47 »
Asi v tom, že nikde nemam ten převedenej .cmv soubor

pacholik

  • Závislák
  • ***
  • Příspěvků: 2072
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #5 kdy: 21 Června 2010, 17:02:44 »
to je podivný, mě to vypsalo +- to samý a .cmv soubor se (i když to trvalo věky) nakonec objevil...

pastaguy

  • Návštěvník
  • Příspěvků: 18
Re: Lama a její Creative Zen MX a formát CMV
« Odpověď #6 kdy: 21 Června 2010, 17:11:43 »
Nu jo no, jsem zkrátka smolař :'(

 

Provoz zaštiťuje spolek OpenAlt.