Bash Script: Abfragen ob Ton in einer Datei vorhanden und funktioniert?

  • Hallo!

    Ich habe mir ein kleines Skript gebastelt mit dem ich meine DVD-Sammlung ein bisschen reduzieren und auf meinem VDR speichern kann.

    Das Skript nutzte lsdvd, ** und HandBrakeCLI.

    Manche Hersteller machen es einem nicht ganz einfach und so kommt es ab und an vor, das kein Ton vorhanden ist oder sich der Film nicht starten läßt.

    Derzeit gucke ich nach 1,5h ob sich die Datei, manuell, abspielen läßt um dann ggf. die Datei gleich zu löschen.

    Aber wozu ein Skript basteln wenn es einem die lästige Arbeit nicht abnimmt?

    Welche Möglichkeit habe ich nun mittels avconv (ffmpeg) zu gucken ob der Film spielt und Ton hat?

    Derzeit frage ich ab, ob die Datei zu klein ist.

    Das löst aber nur das Problem, wenn die Sicherung zwischendurch abbricht.


    - Programmaufrufe die kritisch sein könnten, habe ich entfernt (Urheberrechtsverletzung)! Evtl. werden dadurch Variablen nicht gefüttert!


    Gruß

    Uwe

    VDR: ASUS P5DL/EPU, 1x FF TT2.1, 1x Budged Philips Semiconductors SAA7134/SAA7135HL Video Broadcast Decoder, 1x WLAN USB, NVIDIA GT610

    DEBIAN 9.latest e-Tobi amd64, VDR 2.4.0 xineliboutput-sxfe

  • Google translator is crap so I apologize if this isn't what you're looking for.. If you're just trying to verify that a file has both a video stream and audio stream, you can do that with:

    Code
    fname=/path/to/some/file.mkv
    
    for i in audio video; do
        [[ $(ffprobe -v quiet -of flat -show_streams "$fname" |grep -oE "codec_type=\"$i\"") ]] || { echo "ERROR: $i stream missing in $fname!"; exit 1; }
    done


    To check if the file plays ok, you can just play X seconds at Y location and check the player log to see if it exited without error. I use mpv-player so in my case I could do:

    Code
    /usr/local/bin/mpv --no-cache --fullscreen --no-config --input-file=/dev/stdin --input-terminal=no -v --vo=vdpau --hwdec=vdpau --ao=alsa --audio-device=default --start=-10 "$fname" &>/logs/mpv.log
    
    [[ $(grep 'finished playback, success' /logs/mpv.log) ]] || { echo "ERROR: $fname failed playback"; exit 1; }


    That will play the last 10 seconds of the video and check the log for successful playback.

  • Hi!

    Thanks for the Code, the direction is right! ;)

    I changed from ffprobe to avprobe and removed "-of flat".


    + for i in audio video

    ++ grep -oE 'codec_type="audio"'

    ++ avprobe -v quiet -show_streams /srv/samba/filme/Spielfilme/TED.m4v

    + [[ -n '' ]]

    + echo 'ERROR: audio stream missing in /srv/samba/filme/Spielfilme/TED.m4v!'

    ERROR: audio stream missing in /srv/samba/filme/Spielfilme/TED.m4v!

    + exit 1


    In the shell it works! It's late, tomorrow i will get the mistake!

    VDR: ASUS P5DL/EPU, 1x FF TT2.1, 1x Budged Philips Semiconductors SAA7134/SAA7135HL Video Broadcast Decoder, 1x WLAN USB, NVIDIA GT610

    DEBIAN 9.latest e-Tobi amd64, VDR 2.4.0 xineliboutput-sxfe

  • Lang lang ist her, aber nun ist die Kontrolle ob es Ton gibt fertig.

    Irgendwie fehlte die Zeit.

    Code
    function kontrolle(){
    # Test ob die Datei Ton hat
    fname=/${verz_out}/Spielfilme/$film_title.m4v
    for i in audio video; do    
    [[ $(avprobe -v quiet -show_streams "$fname" |grep -oE "codec_type=$i") ]] || { echo "ERROR: $i stream missing in $fname!"; exit 1; }
    done
    }

    VDR: ASUS P5DL/EPU, 1x FF TT2.1, 1x Budged Philips Semiconductors SAA7134/SAA7135HL Video Broadcast Decoder, 1x WLAN USB, NVIDIA GT610

    DEBIAN 9.latest e-Tobi amd64, VDR 2.4.0 xineliboutput-sxfe

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!