You are not logged in.
Pages: 1
Im trying to convert an H.264 mkv video to MP4 or mov so I can stream it to my xbox 360. Im using this script but it fails after five minutes of encoding.
encoding script
#!/bin/bash
#Grab process id for tmp file name
pidfile=$$.tmp
#Path to where you want the converted videos to be
o="~/hd-movies/converted/"
t="~/hd-movies/temp/"
$(echo $1 >> $pidfile)
#Breaks up filename based on '.' in name
numRecs=$(cat $pidfile | awk -F. '{print NF}')
((numRecs--))
#take everything up until the last '.' thus removing extenstion
f=$(cut -d. -f1-$numRecs $pidfile);
$(rm $pidfile)
oo="$o$f.mov"
to="$t$f.mp4"
zenity --question --text="Are you sure you want to convert $1 to $oo?"
a=$?
if [ $a -eq 0 ]
then
mode=$(zenity --list --radiolist --column="Select" --column="Mode" TRUE CBR FALSE VBR FALSE CQ)
if [ $mode = VBR ]
then
vbitrate=$(zenity --title="Video Bitrate" --entry --text "Enter Video Bitrate (eg. 500k)")
abitrate=$(zenity --title="Audio Bitrate" --entry --text "Enter Audio Bitrate (eg. 128k)")
$(ffmpeg -y -i "$1" -an -pass 1 -passlogfile logfile -vcodec libx264 -b "$vbitrate" -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -me_method epzs -subq 1 -trellis 0 -refs 1 -bf 3 -b_strategy 1 -coder 1 -me_range 12 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt "$vbitrate" -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 41 -threads 2 "$to")
$(ffmpeg -y -i "$1" -pass 2 -passlogfile logfile -vcodec libx264 -b "$vbitrate" -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs-bpyramid -me_method umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 12 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt "$vbitrate" -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 41 -acodec libfaac -ac 2 -ar 48000 -ab "$abitrate" -f mov -threads 2 "$oo")
$(rm -f "$to")
$(rm -f "x264_2pass.log")
$(rm -f "logfile-0.log")
elif [ $mode = CBR ]
then
vbitrate=$(zenity --title="Video Bitrate" --entry --text "Enter Video Bitrate (eg. 500k)")
abitrate=$(zenity --title="Audio Bitrate" --entry --text "Enter Audio Bitrate (eg. 128k)")
$(ffmpeg -y -i "$1" -vcodec libx264 -b "$vbitrate" -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs-bpyramid -me_method umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 12 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt "$vbitrate" -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 41 -acodec libfaac -ac 2 -ar 48000 -ab "$abitrate" -f mov -threads 2 "$oo")
elif [ $mode = CQ ]
then
cq=$(zenity --scale --text="Choose quality - 2 is best" --min-value=2 --max-value=31 --value=2 --step 1)
abitrate=$(zenity --title="Audio Bitrate" --entry --text "Enter Audio Bitrate (eg. 128k)")
$(ffmpeg -y -i "$1" -vcodec libx264 -cqp "$cq" -flags +loop -cmp +chroma -partitions +parti4x4+partp8x8+partb8x8 -flags2 +mixed_refs-bpyramid -me_method umh -subq 5 -trellis 1 -refs 3 -bf 3 -b_strategy 1 -coder 1 -me_range 12 -g 250 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 41 -acodec libfaac -ac 2 -ar 48000 -ab "$abitrate" -f mov -threads 2 "$oo")
else
zenity --error
exit
fi
$(zenity --info --text="Done")
fi
console error messages
[bubba@ra HD Movies]$ cls; bash convert_for_360.sh Underworld.mkv
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enabenable-pthreads --enable-x11grab --enable-swscale
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Apr 18 2009 20:24:32, gcc: 4.3.3
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (24000/1001)
Input #0, matroska, from 'Underworld.mkv':
Duration: 02:01:07.48, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16
Stream #0.2(eng): Subtitle: 0x0000
Stream #0.3: Attachment: 0x0000
Output #0, mp4, to '/home/bubba/hd-movies/temp/Underworld.mp4':
Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=10-51, pass 1, 500 kb/s, 90k tbn, 23.98 tbc
Stream mapping:
Stream #0.0 -> #0.0
[libx264 @ 0xc18f90]using SAR=1/1
[libx264 @ 0xc18f90]using cpu capabilities: MMX2 SSE2Slow
[libx264 @ 0xc18f90]profile Main, level 4.1
Press [q] to stop encoding
[matroska @ 0xad7a60]Unknown entry 0xC03kB time=357.40 bitrate= 508.0kbits/s
[matroska @ 0xad7a60]Unknown entry 0x1897ECB2
[matroska @ 0xad7a60]Unknown entry 0xEB
[matroska @ 0xad7a60]Unknown entry 0xD4
[matroska @ 0xad7a60]Unknown entry 0x80
[matroska @ 0xad7a60]Unknown entry 0xEA
[matroska @ 0xad7a60]Unknown entry 0x26C567
[matroska @ 0xad7a60]Unknown entry 0x1B59D1B9
[matroska @ 0xad7a60]Unknown entry 0xF8
[matroska @ 0xad7a60]Unknown entry 0x6712
[matroska @ 0xad7a60]Unknown entry 0xEA
[matroska @ 0xad7a60]Unknown entry 0xC0
[matroska @ 0xad7a60]Unknown entry 0x2ED241
[matroska @ 0xad7a60]Unknown entry 0xED
[h264 @ 0xaff6a0]concealing 1461 DC, 1461 AC, 1461 MV errorste= 507.5kbits/s
[matroska @ 0xad7a60]Invalid EBML number size tag 0x0c at pos 302544327 (0x120875c7)
frame= 8595 fps= 27 q=-1.0 Lsize= 22308kB time=358.65 bitrate= 509.6kbits/s
video:22206kB audio:0kB global headers:1kB muxing overhead 0.458924%
[libx264 @ 0xc18f90]slice I:126 Avg QP:29.64 size: 12880
[libx264 @ 0xc18f90]slice P:5607 Avg QP:31.98 size: 3323
[libx264 @ 0xc18f90]slice B:2862 Avg QP:33.57 size: 867
[libx264 @ 0xc18f90]consecutive B-frames: 43.2% 33.3% 5.9% 17.6%
[libx264 @ 0xc18f90]mb I I16..4: 82.8% 0.0% 17.2%
[libx264 @ 0xc18f90]mb P I16..4: 22.8% 0.0% 1.2% P16..4: 11.5% 1.6% 0.2% 0.0% 0.0% skip:62.8%
[libx264 @ 0xc18f90]mb B I16..4: 1.9% 0.0% 0.0% B16..8: 6.6% 0.1% 0.0% direct: 1.0% skip:90.4% L0:42.0% L1:53.0% BI: 5.0%
[libx264 @ 0xc18f90]final ratefactor: 37.22
[libx264 @ 0xc18f90]SSIM Mean Y:0.9398214
[libx264 @ 0xc18f90]kb/s:507.3
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libtheora --enable-postproc --enable-shared --enable-pthreads --enable-x11grab --enable-swscale
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Apr 18 2009 20:24:32, gcc: 4.3.3
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (24000/1001)
Input #0, matroska, from 'Underworld.mkv':
Duration: 02:01:07.48, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16
Stream #0.2(eng): Subtitle: 0x0000
Stream #0.3: Attachment: 0x0000
Output #0, mov, to '/home/bubba/hd-movies/converted/Underworld.mov':
Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=10-51, pass 2, 500 kb/s, 90k tbn, 23.98 tbc
Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, s16, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
[libx264 @ 0x771f90]using SAR=1/1
[libx264 @ 0x771f90]using cpu capabilities: MMX2 SSE2Slow
[libx264 @ 0x771f90]profile Main, level 4.1
Press [q] to stop encoding
[matroska @ 0x630a60]Unknown entry 0xC00kB time=357.57 bitrate= 665.8kbits/s
[matroska @ 0x630a60]Unknown entry 0x1897ECB2
[matroska @ 0x630a60]Unknown entry 0xEB
[matroska @ 0x630a60]Unknown entry 0xD4
[matroska @ 0x630a60]Unknown entry 0x80
[matroska @ 0x630a60]Unknown entry 0xEA
[matroska @ 0x630a60]Unknown entry 0x26C567
[matroska @ 0x630a60]Unknown entry 0x1B59D1B9
[matroska @ 0x630a60]Unknown entry 0xF8
[matroska @ 0x630a60]Unknown entry 0x6712
[matroska @ 0x630a60]Unknown entry 0xEA
[matroska @ 0x630a60]Unknown entry 0xC0
[matroska @ 0x630a60]Unknown entry 0x2ED241
[matroska @ 0x630a60]Unknown entry 0xED
[h264 @ 0x6586a0]concealing 1461 DC, 1461 AC, 1461 MV errorste= 665.6kbits/s
[matroska @ 0x630a60]Invalid EBML number size tag 0x0c at pos 302544327 (0x120875c7)
frame= 8595 fps= 14 q=-1.0 Lsize= 29377kB time=358.65 bitrate= 671.0kbits/s
video:21898kB audio:7245kB global headers:1kB muxing overhead 0.802050%
[libx264 @ 0x771f90]slice I:126 Avg QP:30.55 size: 10249
[libx264 @ 0x771f90]slice P:5607 Avg QP:33.14 size: 3359
[libx264 @ 0x771f90]slice B:2862 Avg QP:34.62 size: 802
[libx264 @ 0x771f90]consecutive B-frames: 43.2% 33.3% 5.9% 17.6%
[libx264 @ 0x771f90]mb I I16..4: 90.2% 0.0% 9.8%
[libx264 @ 0x771f90]mb P I16..4: 28.1% 0.0% 0.3% P16..4: 17.3% 1.6% 0.1% 0.0% 0.0% skip:52.6%
[libx264 @ 0x771f90]mb B I16..4: 1.8% 0.0% 0.0% B16..8: 8.6% 0.1% 0.0% direct: 0.6% skip:88.9% L0:47.6% L1:49.5% BI: 2.9%
[libx264 @ 0x771f90]ref P L0 65.6% 19.0% 15.4%
[libx264 @ 0x771f90]ref B L0 77.2% 22.8%
[libx264 @ 0x771f90]SSIM Mean Y:0.9479867
[libx264 @ 0x771f90]kb/s:500.3
Offline
If you want to play that on your 360, just leave the video stream intact and change the Audio from ac3 into aac. Name it with the .mov extension and the xbox will play it. I just use Avidemux for this.
Last edited by rsambuca (2009-05-22 22:09:12)
Offline
If you want to play that on your 360, just leave the video stream intact and change the Audio from ac3 into aac. Name it with the .mov extension and the xbox will play it.
If it's that simple:
ffmpeg -i <INPUT>.mkv -vcodec copy -ab <DESIRED_BITRATE> -acodec libfaac <OUTPUT>.mp4
Offline
I tried that and this is what I got:
[bubba@ra HD Movies]$ ffmpeg -i Underworld.mkv -vcodec copy -ab 500kb -acodec libfaac underworld2.mov
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libtheora --enable-postproc --enable-shared --enable-pthreads --enable-x11grab --enable-swscale
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Apr 18 2009 20:24:32, gcc: 4.3.3
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (24000/1001)
Input #0, matroska, from 'Underworld.mkv':
Duration: 02:01:07.48, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16
Stream #0.2(eng): Subtitle: 0x0000
Stream #0.3: Attachment: 0x0000
Output #0, mov, to 'underworld2.mov':
Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 90k tbn, 1k tbc
Stream #0.1(eng): Audio: libfaac, 48000 Hz, 5.1, s16, 500 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[NULL @ 0xb90020]error, non monotone timestamps 125 >= 83
av_interleaved_write_frame(): Error while opening file
[bubba@ra HD Movies]$ ls
300 1080P.mp4 300.mkv Memento.mkv Sin City.mkv Text File The Shawshank Redemption.mkv Underworld.mkv
I tried it using sudo and got the same error :-/
Last edited by brando56894 (2009-05-23 07:50:52)
Offline
Two things here. Either there's a problem within the container of the video you are trying to encode or there's a problem with the matroska code in the version of FFmpeg that you're using. Modern releases of FFmpeg should have the bugs in its matroska code worked out. But, the error message that you received in the opening post is from FFmpeg's matroska code. One thing that you can try is to remux the codecs into the container using something other than FFmpeg like mkvtoolnix. Just have both your input and output videos mkv.
Second, if you're using the line that I posted above, FFmpeg should not being using x264 at all. In the output in the last post it clearly states that it's using libx264, so its re-encoding the input source.
Offline
Bump to say that I'm probably wrong on all accounts. It seems that there are in fact issues with Mplayer in respect to matroska containers right now. I can't seem to get anything encoded today with FFmpeg or mkvtoolnix to playback on Mplayer. This is new. I just did similar operations a few weeks ago without any problems. I'm guess that it's Mplayer since all sorts of things seem to be broken in Mplayer right now.
Also, it looks as if FFmpeg may be using x264's lossless mode to remux H264 streams into new containers. This is also new. Up until this thread I've never seen this before.
***Disregard my last post unless you live in an alternate reality dating back weeks ago***
Offline
i was having the same problem like this in windows when i tried to use a program called convertHD (or something like that) i would try and convert (recode?) an mkv to mp4 and it would get to about 80 mins into the movie and stop. I emailed the creator a few times and he said it was a problem with ffmpeg, but this was months ago.
i noticed that i can open my mkv's in regular mplayer (via the console ex: mplayer [video].mkv) and it would work fine but if i tried to open a video up with smplayer it would pop up an error box that said something to the effect of "error code 1"
Offline
I just tried using ffmpeg and it doesn't work currently for me either.
I tried avidemux, and it still worked. I used Video -> copy, Audio -> faac, 192kbit, stereo, in mp4 container named with a .mov extension for the xbox. These settings work for me. Since it is leaving the video portion intact, it only takes a few seconds for a 42min tv show. When opening the mkv file the first time in Avidemux, it says something like "B Frames being detected, do you want to use safe mode?" Select NO, or Cancel for this.
I stream to the XBox360 using ushare.
Last edited by rsambuca (2009-05-23 18:44:10)
Offline
I just got confirmation from Dark Shikari (x264 and FFmpeg developer) that huge portions of Mplayer are broken with GCC 4.4.0. I can image that everything else is somewhat borked too.
--EDIT--
The FFmpeg part was a mistake. It wasn't mine this time. Hurray!
Offline
Oh ok, I still find it kind of odd that mkvs play with the command line mplayer but wont play with smplayer. I try the avidemux method rsambuca and let you know if I have any problems.
Offline
rsambuca wrote:If you want to play that on your 360, just leave the video stream intact and change the Audio from ac3 into aac. Name it with the .mov extension and the xbox will play it.
If it's that simple:
ffmpeg -i <INPUT>.mkv -vcodec copy -ab <DESIRED_BITRATE> -acodec libfaac <OUTPUT>.mp4
I believe that the 360 requires 2 audio channels or less for AAC, so you need to add the -ac 2 option. Your input 5.1 and may choke the 360:
ffmpeg -i <INPUT>.mkv -vcodec copy -ab <DESIRED_BITRATE> -acodec libfaac -ac 2 <OUTPUT>.mp4
Offline
same problem as before
[bubba@ra HD Movies]$ sudo ffmpeg -i Underworld.mkv -vcodec copy -ab 384000 -acodec libfaac -ac 2 underworld.mp4
FFmpeg version 0.5, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --prefix=/usr --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libfaac --enable-libfaad --enable-libxvid --enable-libx264 --enable-libtheora --enable-postproc --enable-shared --enable-pthreads --enable-x11grab --enable-swscale
libavutil 49.15. 0 / 49.15. 0
libavcodec 52.20. 0 / 52.20. 0
libavformat 52.31. 0 / 52.31. 0
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 7. 1 / 0. 7. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Apr 18 2009 20:24:32, gcc: 4.3.3
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (48000/1001) -> 23.98 (24000/1001)
Input #0, matroska, from 'Underworld.mkv':
Duration: 02:01:07.48, start: 0.000000, bitrate: N/A
Stream #0.0(eng): Video: h264, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0.1(eng): Audio: ac3, 48000 Hz, 5.1, s16
Stream #0.2(eng): Subtitle: 0x0000
Stream #0.3: Attachment: 0x0000
Output #0, mp4, to 'underworld.mp4':
Stream #0.0(eng): Video: libx264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], q=2-31, 90k tbn, 1k tbc
Stream #0.1(eng): Audio: libfaac, 48000 Hz, stereo, s16, 384 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Stream #0.1 -> #0.1
Press [q] to stop encoding
[NULL @ 0x2150b60]error, non monotone timestamps 125 >= 83
av_interleaved_write_frame(): Error while opening file
Offline
Instead of using -vcodec copy, try -vcodec libx264 -sameq. I don't remember whether or not the sameq switch works for H264 though.
--OR--
You can try to see if FFmpeg's x264 presets work without making any command line edits. For two pass:
ffmpeg -i <INPUT> -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b <DESIRED_BITRATE> -bt <DESIRED_BITRATE> -threads 0 <OUTPUT>.mp4
ffmpeg -i <INPUT> -ac 2 -ar 48000 -acodec libfaac -ab 384k -pass 2 -vcodec libx264 -vpre hq -b <DESIRED_BITRATE> -bt <DESIRED_BITRATE> -threads 0 <OUTPUT>.mp4
Offline
Have you tried Avidemux yet? It does the job in less than a minute.
You can then wait a while to see if ffmpeg gets its compatibility with gcc 4.0 worked out.
Offline
I just tried it but ran into several problems while trying to get the video to the xbox.
1. the video is 4.4gb, i only have a 4gb flash drive.
2. I set up ushare and the local webpage shows that its configured correctly yet the xbox doesnt see any computers on the network, even though an xbox live connection test showed that everything was fine
3. I tried using a crossover cable to directly connect the xbox and my pc, i ran the "check pc connection" test and it failed
to test the video I could boot into window but I want to get this set in linux also. this is more of a general problem but for some reason ushare fails to start when being run as a daemon (sudo /etc/rc.d/ushare start) but seems to work fine if I start it manually from the console (ushare -f /etc/ushare.conf)
Last edited by brando56894 (2009-05-31 02:19:23)
Offline
Unfortunately you are running into some problems that I have never experienced...
1. I don't use a flash drive, so I have never had to worry about files sizes.
3. I have both the XBox and my PC using wired ethernet connected to my router. Never had a problem getting them to connect.
I have always started ushare from a terminal using
ushare -x &
The '&' lets it run in the background so you can close the terminal window and ushare will still be running. It sometimes spits out an error, but it always still works for me.
Offline
usuallly thats how i have it connected (pc--->router---->xbox). I have underworld: rise of the lycans thats 720p and was only 1.4gb so I used avidemux with your recommended settings and after it was done I put it on my flash drive and brought it down to the xbox and got the same "unsupported codec" error. I just opened it in smplayer and the movie itself works but when I opened the converted file in avidemux I get all these errors and it closes:
Last edited by brando56894 (2009-06-01 21:57:24)
Offline
Pages: 1